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 React Native Components integration, v2.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 call
resolvewith updated summary items, updated shipping methods, or errors. The Apple Pay sheet shows what you pass. - 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. amountThe cost of this shipping method. identifierYour own identifier for this shipping method. The Component returns this value to you in onShippingMethodChange, so set it if you need to tell your shipping methods apart.detailA description that the Apple Pay sheet shows under the label, for example the carrier or the delivery time. startDateThe earliest delivery date, in ISO 8601 date format. endDateThe latest delivery date, in ISO 8601 date format. -
Add the following to the
applepayobject in yourAdyenCheckoutconfiguration, in addition to the parameters that every Apple Pay integration needs:Parameter Required Description summaryItemsThe items that make up the payment. The last item is the total that the Apple Pay sheet shows to the shopper. shippingMethodsThe shipping methods that you created in step 1. requiredShippingContactFieldsThe shipping fields that you need from the shopper to fulfill the order. Possible values: postalAddress, name, phoneticName, phone, email. 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. Apple Pay amounts are not in minor units. Adyen uses integer minor units, and Apple uses decimal values. Make sure that the last summary item matches the amount that you submit to Adyen.
-
Add the callbacks that you want to handle.
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
onShippingContactChangecallback. It receives the shopper'sApplePayPaymentContactand aresolvefunction. -
Call
resolvewith anApplePayShippingContactUpdateRequestthat contains the following:Parameter Required Description paymentSummaryItemsThe updated summary items. If you omit this, the Component keeps the current items. shippingMethodsThe shipping methods that you offer for this address. If you omit this, the Component keeps the current methods. 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, pass 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
onShippingMethodChangecallback. It receives the selectedApplePayShippingMethodand aresolvefunction. -
Call
resolvewith anApplePayShippingMethodUpdateRequestthat contains the following:Parameter Required Description paymentSummaryItemsThe updated summary items, including the cost of the selected shipping method. If you omit this, the Component keeps the current items.
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
onCouponCodeChangecallback. It receives the coupon code and aresolvefunction. -
Call
resolvewith anApplePayCouponCodeUpdateRequestthat contains the following:Parameter Required Description paymentSummaryItemsThe updated summary items, including the discount. If you omit this, the Component keeps the current items. shippingMethodsThe shipping methods that you offer with this coupon code applied. If you omit this, the Component keeps the current methods. 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, pass 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 anApplePayPaymentAuthorization, which contains the billing contact, the shipping contact, and the shipping method that the shopper selected, plus anactionsobject. -
Call one of the following on the
actionsobject:Action Description actions.resolve()Continue with the payment. actions.reject(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:
-
Check that Apple Pay is available on the device. Call
AdyenApplePay.isAvailable, passing:- The Apple Pay payment method: the object with
typeapplepay from your /paymentMethods response. - Your
AdyenCheckoutconfiguration.
The method resolves to true when the shopper can pay with Apple Pay.
- The Apple Pay payment method: the object with
-
Render an
ApplePayButtonwhen Apple Pay is available:Parameter Required Description onPressCalled when the shopper selects the button. Start the Component from here. themeThe button theme. Possible values: WHITE, WHITE_OUTLINE, BLACK, AUTOMATIC. Default: WHITE. typeThe label on the button, for example BUY, CHECKOUT, ORDER, or PLAIN. Default: BUY. radiusThe corner radius of the button. styleA React Native style to apply to the button. -
In
onPress, start the Component with theapplepaypayment method type. Use thestartfunction from theuseAdyenCheckouthook.
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 an ApplePayError 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. | |
message |
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. |
| contactField | 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. The value depends on the error type:
| Error type | Set field to |
|---|---|
| shippingAddress or billingAddress | A CNPostalAddress key, for example postalCode, city, street, country, or countryCode. |
| contactField | A PKContactField name, for example phoneNumber, emailAddress, name, or postalAddress. |
Code samples
The following code samples show the steps on this page in full.