requestApplePayToken method

Future<Map<String, dynamic>?> requestApplePayToken({
  1. required String merchantIdentifier,
  2. required String countryCode,
  3. required String currencyCode,
  4. required String amount,
  5. required String orderDescription,
  6. required List<String> supportedNetworks,
  7. required List<String> merchantCapabilities,
  8. List<String> validatePayerFields = const [],
})

Presents the native Apple Pay sheet and, once the payer authorizes the payment, returns a map shaped {"paymentToken": {...}, "billingContact": {...}}:

  • paymentToken matches Mobibox's expected S2S CARD payment_token value: {"paymentData": {...}, "paymentMethod": {...}, "transactionIdentifier": "..."}.
  • billingContact (present only if PassKit actually collected one) has givenName/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

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 [],
}) {
  return instance.requestApplePayToken(
    merchantIdentifier: merchantIdentifier,
    countryCode: countryCode,
    currencyCode: currencyCode,
    amount: amount,
    orderDescription: orderDescription,
    supportedNetworks: supportedNetworks,
    merchantCapabilities: merchantCapabilities,
    validatePayerFields: validatePayerFields,
  );
}