addNewCard static method
Future<void>
addNewCard(
- BuildContext context, {
- required PaymentRequest paymentRequest,
- required void onAddCard(
- BuildContext sheetContext,
- CardData card
- void onCancel(
- BuildContext sheetContext
- CardData? initialCard,
- bool savedCardEditMode = false,
- String? recoveryErrorCode,
- String? recoveryErrorMessage,
Opens the add-card modal bottom sheet (AddCardForm) with SDK theme.
onAddCard receives the sheet BuildContext (e.g. to Navigator.pop) and
the entered CardData.
Implementation
static Future<void> addNewCard(
BuildContext context, {
required PaymentRequest paymentRequest,
required void Function(BuildContext sheetContext, CardData card) onAddCard,
void Function(BuildContext sheetContext)? onCancel,
CardData? initialCard,
/// When true with [initialCard], use saved-card edit UI (read-only PAN). Otherwise [initialCard] only pre-fills the add-card flow.
bool savedCardEditMode = false,
/// When reopening the form after `/sdk/payment` errors `E0021` (mobile) or `43` (email).
String? recoveryErrorCode,
String? recoveryErrorMessage,
}) {
return showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
backgroundColor: AppColors.transparent,
shape: PayorcSdkUiConstants.bottomSheetModalShape,
builder: (ctx) => wrapWithSdkTheme(
context,
AddCardForm(
paymentRequest: paymentRequest,
initialCard: initialCard,
savedCardEditMode: savedCardEditMode,
recoveryErrorCode: recoveryErrorCode,
recoveryErrorMessage: recoveryErrorMessage,
onAddCard: (card) => onAddCard(ctx, card.copyWith(cvv: '')),
onCancel: () {
if (onCancel != null) {
onCancel(ctx);
} else {
Navigator.of(ctx).pop();
}
},
),
),
);
}