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 |
|
| 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:
- Configure the Apple Pay sheet.
- Configure the callback to handle shipping contact changes.
- Configure the callback to handle shipping method changes.
- Configure the callback to handle coupon code changes.
- Configure the callback to validate the payment.
- Show the Apple Pay button on your product or cart screen.
Shopper checkout experience
When the shopper checks out with Apple Pay:
- The shopper selects the Apple Pay button, and the Apple Pay sheet opens.
- The shopper selects a shipping contact, selects a shipping method, or enters a coupon code. The Component calls the matching callback each time.
- In the callback, you return updated summary items, updated shipping methods, or errors. The Apple Pay sheet shows what you return.
- The shopper authorizes the payment with Face ID or Touch ID. The Component calls
onAuthorizebefore the payment is submitted, so that you can run your own checks. - You submit the payment from your server.
Configure the Apple Pay sheet
Configure the line items, the shipping methods that you offer, and the shopper details that you require:
-
Create the shipping methods that you offer. Each shipping method is an
ApplePayShippingMethod:Parameter Required Description labelThe name of the shipping method that the Apple Pay sheet shows, for example Standard shipping. detailA description that the Apple Pay sheet shows under the label, for example the carrier or the delivery time. amountThe cost of this shipping method. identifierYour own identifier for this shipping method. The Component returns this value to you in onSelectShippingMethod.startDateThe earliest delivery date. endDateThe latest delivery date. -
Add the following to your
ApplePayConfiguration, in addition to the parameters that every Apple Pay integration needs:Parameter Required Description applePaySummaryItemsThe 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. shippingMethodsThe shipping methods that you created in step 1. requiredShippingContactFieldsThe shipping fields that you need from the shopper to fulfill the order. allowShippingContactEditingSet to true to let the shopper change the shipping address in the Apple Pay sheet. supportsCouponCodeSet to true to show the coupon code field in the Apple Pay sheet. Requires iOS 15 or later. couponCodeA coupon code to prefill in the coupon code field. -
Add the callbacks that you want to handle, and pass the
ApplePayConfigurationto yourApplePayComponentConfiguration.
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:
-
Implement the
onSelectShippingContactcallback. It receives the shopper'sApplePayContactand the current summary items. -
Return an
ApplePayShippingContactUpdatewith the following:Parameter Required Description summaryItemsThe updated summary items. To leave the payment unchanged, return the currentSummaryItemsthat the Component passes to the callback.shippingMethodsThe shipping methods that you offer for this address. errorsThe 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:
-
Implement the
onSelectShippingMethodcallback. It receives the selectedApplePayShippingMethodand the current summary items. -
Return an
ApplePayShippingMethodUpdatewith the following:Parameter Required Description summaryItemsThe updated summary items, including the cost of the selected shipping method. You cannot return errors from this callback. Validate the shipping address in
onSelectShippingContactinstead.
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:
-
Set
supportsCouponCodeto true to show the coupon code field. -
Implement the
onChangeCouponCodecallback. It receives the coupon code and the current summary items. -
Return an
ApplePayCouponCodeUpdatewith the following:Parameter Required Description summaryItemsThe updated summary items, including the discount. To leave the payment unchanged, return the currentSummaryItemsthat the Component passes to the callback.shippingMethodsThe shipping methods that you offer with this coupon code applied. errorsThe 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:
-
Implement the
onAuthorizecallback. It receives anApplePayAuthorizedPayment, which contains the payment token, the card network, and the contact details and shipping method that the shopper selected. -
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:
-
Get the Apple Pay payment method from your /paymentMethods response.
-
Add an
AdyenApplePayComponentto your screen:Parameter Required Description configurationYour ApplePayComponentConfiguration, which carries theApplePayConfigurationthat you built in the previous steps. Setamounton it, because the Advanced flow requires an amount.paymentMethodThe Apple Pay payment method from step 1. checkoutYour AdvancedCheckout, with theonSubmithandler that submits the payment.onPaymentResultCalled with the PaymentResultwhen the payment finishes. Show the outcome to the shopper.styleAn ApplePayButtonStylethat sets the buttontheme,type, andcornerRadius.onUnavailableCalled when Apple Pay is not available on the device. unavailableWidgetThe widget to show instead of the button when Apple Pay is not available. loadingIndicatorThe widget to show while the Component loads. widthandheightThe button size. Values below Apple's minimum button size are raised to the minimum. The Component checks whether Apple Pay is available. Use
onUnavailableandunavailableWidgetto 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 |
The kind of error. | |
localizedDescription |
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.