requestApplePayToken method
Future<Map<String, dynamic> ?>
requestApplePayToken({
- required String merchantIdentifier,
- required String countryCode,
- required String currencyCode,
- required String amount,
- required String orderDescription,
- required List<
String> supportedNetworks, - required List<
String> merchantCapabilities, - List<
String> validatePayerFields = const [],
override
Presents the native Apple Pay sheet and, once the payer authorizes the
payment, returns a map shaped {"paymentToken": {...}, "billingContact": {...}}:
paymentTokenmatches Mobibox's expected S2S CARDpayment_tokenvalue:{"paymentData": {...}, "paymentMethod": {...}, "transactionIdentifier": "..."}.billingContact(present only if PassKit actually collected one) hasgivenName/familyName/address/city/state/zip/countryCode/phoneNumber/emailAddress, sourced from the payer's Wallet contact - used to fill S2S CARD's required payer_* SALE fields.
Returns null if the payer cancels the sheet.
validatePayerFields names the payer fields (name, address, city,
zip, country, phone, email) that must be present on the billing
contact - when one is missing after the payer authorizes, the sheet
stays open with that field highlighted so they can complete it in-sheet
and re-authorize, instead of the payment failing after the sheet
closes. Callers should only list fields they have no fallback value for.
Implementation
@override
Future<Map<String, dynamic>?> requestApplePayToken({
required String merchantIdentifier,
required String countryCode,
required String currencyCode,
required String amount,
required String orderDescription,
required List<String> supportedNetworks,
required List<String> merchantCapabilities,
List<String> validatePayerFields = const [],
}) async {
final result = await methodChannel
.invokeMapMethod<String, dynamic>('requestApplePayToken', {
'merchantIdentifier': merchantIdentifier,
'countryCode': countryCode,
'currencyCode': currencyCode,
'amount': amount,
'orderDescription': orderDescription,
'supportedNetworks': supportedNetworks,
'merchantCapabilities': merchantCapabilities,
'validatePayerFields': validatePayerFields,
});
if (result == null) {
// Payer cancelled the Apple Pay sheet.
return null;
}
return Map<String, dynamic>.from(result);
}