Payment-method icon

Apple Pay express checkout

Configure the Apple Pay Component for express checkout in your Flutter app.

You can configure the Apple Pay Component for express checkout to offer your shoppers the option to pay with fewer steps. In the express checkout flow, you request the shopper's billing and shipping information from the Apple Pay sheet, which speeds up the checkout process.

Requirements

Requirement Description
Integration type An Advanced flow Flutter Components integration, v1.11.0 or later.
Limitations
  • Apple Pay express checkout is available on iOS only.
  • Coupon codes require iOS 15 or later.
Setup steps Before you begin, make sure that you have:

How it works

For express checkout, the shopper completes the payment inside the Apple Pay sheet. You configure the Apple Pay Component with the callbacks that update the sheet as the shopper makes their selections.

Integration steps

To offer express checkout with Apple Pay:

  1. Configure the Apple Pay sheet.
  2. Configure the callback to handle shipping contact changes.
  3. Configure the callback to handle shipping method changes.
  4. Configure the callback to handle coupon code changes.
  5. Configure the callback to validate the payment.
  6. Show the Apple Pay button on your product or cart screen.

Shopper checkout experience

When the shopper checks out with Apple Pay:

  1. The shopper selects the Apple Pay button, and the Apple Pay sheet opens.
  2. The shopper selects a shipping contact, selects a shipping method, or enters a coupon code. The Component calls the matching callback each time.
  3. In the callback, you return updated summary items, updated shipping methods, or errors. The Apple Pay sheet shows what you return.
  4. The shopper authorizes the payment with Face ID or Touch ID. The Component calls onAuthorize before the payment is submitted, so that you can run your own checks.
  5. You submit the payment from your server.
CnNlcXVlbmNlRGlhZ3JhbQogICAgcGFydGljaXBhbnQgU2hvcHBlcgogICAgcGFydGljaXBhbnQgU2hlZXQgYXMgQXBwbGUgUGF5IHNoZWV0CiAgICBwYXJ0aWNpcGFudCBDb21wb25lbnQgYXMgQXBwbGUgUGF5IENvbXBvbmVudAogICAgcGFydGljaXBhbnQgQXBwIGFzIFlvdXIgYXBwCiAgICBwYXJ0aWNpcGFudCBTZXJ2ZXIgYXMgWW91ciBzZXJ2ZXIKICAgIHBhcnRpY2lwYW50IEFkeWVuCgogICAgU2hvcHBlci0+PkNvbXBvbmVudDogMS4gU2VsZWN0IHRoZSBBcHBsZSBQYXkgYnV0dG9uCiAgICBDb21wb25lbnQtPj5TaGVldDogT3BlbiB0aGUgQXBwbGUgUGF5IHNoZWV0CiAgICBsb29wIEVhY2ggdGltZSB0aGUgc2hvcHBlciBjaGFuZ2VzIGEgc2VsZWN0aW9uCiAgICAgICAgU2hvcHBlci0+PlNoZWV0OiAyLiBTZWxlY3QgYSBzaGlwcGluZyBjb250YWN0IG9yIHNoaXBwaW5nIG1ldGhvZCwgb3IgZW50ZXIgYSBjb3Vwb24gY29kZQogICAgICAgIENvbXBvbmVudC0+PkFwcDogQ2FsbCB0aGUgbWF0Y2hpbmcgY2FsbGJhY2sKICAgICAgICBBcHAtLT4+Q29tcG9uZW50OiAzLiBSZXR1cm4gdXBkYXRlZCBzdW1tYXJ5IGl0ZW1zLCBzaGlwcGluZyBtZXRob2RzLCBvciBlcnJvcnMKICAgICAgICBDb21wb25lbnQtPj5TaGVldDogU2hvdyB0aGUgdXBkYXRlCiAgICBlbmQKICAgIFNob3BwZXItPj5TaGVldDogNC4gQXV0aG9yaXplIHRoZSBwYXltZW50IHdpdGggRmFjZSBJRCBvciBUb3VjaCBJRAogICAgQ29tcG9uZW50LT4+QXBwOiBDYWxsIG9uQXV0aG9yaXplCiAgICBBcHAtLT4+Q29tcG9uZW50OiBSZXR1cm4gdGhlIGF1dGhvcml6YXRpb24gcmVzdWx0CiAgICBDb21wb25lbnQtPj5BcHA6IFBheW1lbnQgZGF0YQogICAgQXBwLT4+U2VydmVyOiBQYXltZW50IGRhdGEKICAgIFNlcnZlci0+PkFkeWVuOiA1LiBTdWJtaXQgdGhlIHBheW1lbnQK

Configure the Apple Pay sheet

Configure the line items, the shipping methods that you offer, and the shopper details that you require:

  1. Create the shipping methods that you offer. Each shipping method is an ApplePayShippingMethod:

    Parameter Required Description
    label Required The name of the shipping method that the Apple Pay sheet shows, for example Standard shipping.
    detail Required A description that the Apple Pay sheet shows under the label, for example the carrier or the delivery time.
    amount Required The cost of this shipping method.
    identifier Required Your own identifier for this shipping method. The Component returns this value to you in onSelectShippingMethod.
    startDate The earliest delivery date.
    endDate The latest delivery date.
  2. Add the following to your ApplePayConfiguration, in addition to the parameters that every Apple Pay integration needs:

    Parameter Required Description
    applePaySummaryItems Required The items that make up the payment. The last item is the total that the Apple Pay sheet shows to the shopper. It must match the amount that you submit to Adyen.
    shippingMethods Required The shipping methods that you created in step 1.
    requiredShippingContactFields The shipping fields that you need from the shopper to fulfill the order.
    allowShippingContactEditing Set to true to let the shopper change the shipping address in the Apple Pay sheet.
    supportsCouponCode Set to true to show the coupon code field in the Apple Pay sheet. Requires iOS 15 or later.
    couponCode A coupon code to prefill in the coupon code field.
  3. Add the callbacks that you want to handle, and pass the ApplePayConfiguration to your ApplePayComponentConfiguration.

Configure the callback to handle shipping contact changes

If the shopper selects or changes their shipping address, offer the shipping methods that you support for that address and recalculate the total:

  1. Implement the onSelectShippingContact callback. It receives the shopper's ApplePayContact and the current summary items.

  2. Return an ApplePayShippingContactUpdate with the following:

    Parameter Required Description
    summaryItems Required The updated summary items. To leave the payment unchanged, return the currentSummaryItems that the Component passes to the callback.
    shippingMethods The shipping methods that you offer for this address.
    errors The errors to show in the Apple Pay sheet. The sheet stays open so that the shopper can correct the address.

    To reject an address that you cannot ship to, return an error instead of new shipping methods.

Configure the callback to handle shipping method changes

If the shopper selects a different shipping method, add the cost of that method to the total:

  1. Implement the onSelectShippingMethod callback. It receives the selected ApplePayShippingMethod and the current summary items.

  2. Return an ApplePayShippingMethodUpdate with the following:

    Parameter Required Description
    summaryItems Required The updated summary items, including the cost of the selected shipping method.

    You cannot return errors from this callback. Validate the shipping address in onSelectShippingContact instead.

Configure the callback to handle coupon code changes

If the shopper enters or changes a coupon code, apply a discount or tell the shopper that the code is not valid:

  1. Set supportsCouponCode to true to show the coupon code field.

  2. Implement the onChangeCouponCode callback. It receives the coupon code and the current summary items.

  3. Return an ApplePayCouponCodeUpdate with the following:

    Parameter Required Description
    summaryItems Required The updated summary items, including the discount. To leave the payment unchanged, return the currentSummaryItems that the Component passes to the callback.
    shippingMethods The shipping methods that you offer with this coupon code applied.
    errors The errors to show in the Apple Pay sheet. The sheet stays open so that the shopper can correct the code.

    To reject a code that is not valid, return an error instead of a discount.

Configure the callback to validate the payment

Before the payment is submitted, run your own checks on the shopper details that you collected in the Apple Pay sheet:

  1. Implement the onAuthorize callback. It receives an ApplePayAuthorizedPayment, which contains the payment token, the card network, and the contact details and shipping method that the shopper selected.

  2. Return one of the following:

    Result Description
    ApplePayAuthorizationResult.success() Continue with the payment.
    ApplePayAuthorizationResult.failure(errors: [...]) Stop the payment and show the errors in the Apple Pay sheet. The sheet stays open so that the shopper can correct the problem.

Show the Apple Pay button

Place the Apple Pay button where you want to offer express checkout, for example on your product or cart screen. The shopper selects Apple Pay there instead of going to your checkout, so Apple Pay is already the chosen payment method when the sheet opens.

To show the button:

  1. Get the Apple Pay payment method from your /paymentMethods response.

  2. Add an AdyenApplePayComponent to your screen:

    Parameter Required Description
    configuration Required Your ApplePayComponentConfiguration, which carries the ApplePayConfiguration that you built in the previous steps. Set amount on it, because the Advanced flow requires an amount.
    paymentMethod Required The Apple Pay payment method from step 1.
    checkout Required Your AdvancedCheckout, with the onSubmit handler that submits the payment.
    onPaymentResult Required Called with the PaymentResult when the payment finishes. Show the outcome to the shopper.
    style An ApplePayButtonStyle that sets the button theme, type, and cornerRadius.
    onUnavailable Called when Apple Pay is not available on the device.
    unavailableWidget The widget to show instead of the button when Apple Pay is not available.
    loadingIndicator The widget to show while the Component loads.
    width and height The button size. Values below Apple's minimum button size are raised to the minimum.

    The Component checks whether Apple Pay is available. Use onUnavailable and unavailableWidget to control what the screen shows when it is not.

Test and go live

Use Apple's test card numbers to test your integration.

For a full list of test cards and instructions how to add these to your test device, see Sandbox testing on Apple's Developer website.

Check the status of an Apple Pay test payment in your Customer Area > Payments > Payment list.

Going live

To process live Apple Pay payments, your API credential needs to have the API Clientside Encryption Payments role. You can check this in your live Customer Area or ask your Admin user to verify.

Set up Apple Pay on your Apple Pay Developer account for your live merchant identifier.

Apple Pay sheet errors

Use ApplePayPaymentError to tell the shopper what to correct. The Apple Pay sheet stays open and highlights the field that you specify.

Parameter Required Description
type Required The kind of error.
localizedDescription Required The message that the Apple Pay sheet shows to the shopper. Translate this into the shopper's language.
field The field that is not valid. The Apple Pay sheet highlights this field.

Error types

Value Use when
shippingAddress A field in the shipping address is not valid.
billingAddress A field in the billing address is not valid.
contact A contact field, such as the email address or the phone number, is not valid.
couponCode The coupon code is not valid.

Error fields

Set field to the part of the address or the contact that the shopper must correct.

Context Values
Address street, city, postalCode, administrativeArea, subAdministrativeArea, subLocality, country, countryCode
Contact name, phoneticName, emailAddress, phoneNumber, postalAddress

Code samples

The following code samples show the steps on this page in full.

See also