Requirements
| Requirement | Description |
|---|---|
| Integration type | Make sure that you have built an Advanced flow API-only integration. |
| Customer Area roles | Change payment methods role. |
| API credential roles | To process live Apple Pay payments make sure that you have the following role- API Clientside Encryption Payments role. |
| Setup steps | Before you begin, make sure that you have: Set up Apple Pay with your own or Adyen’s Apple Pay certificate. You can use Adyen’s Apple Pay certificate if you have a web integration, which makes it quicker to set up Apple Pay. If you have a mobile integration, use your own Apple Developer account and certificate which requires extra configuration steps. Added Apple Pay in your Customer Area. Read the Apple Pay documentation to learn about how you can offer Apple Pay on the web, or in your mobile app. |
Build your payment form for Apple Pay
After you have finished setting up Apple Pay, you can show Apple Pay as an available payment method in countries/regions where Apple Pay is supported. You can download logos for Apple Pay which you can use on your payment form. When the shopper selects Apple Pay, they are presented with a prompt to verify the payment using Touch ID or Face ID. If the shopper is using a Mac without Touch ID, they will be prompted to verify the payment using an iPhone or Apple Watch registered to the same iCloud account.-
Make a /paymentMethods request, specifying:
- countryCode: Countries/regions where Apple Pay is supported. For example, NL.
- amount.currency: Any supported currency. For example, EUR.
- channel: Set this to Web if the payment is being initiated from Safari, or iOS for in-app payments.
-
In the response, you receive:
type: applepay.merchantIdandmerchantName: If you use Adyen’s Apple Pay certificate, you need these details in the next step to complete the Apple Pay session validation.
{
"paymentMethods": [
...
{
"brands": [
"amex",
"mc"
],
"configuration": {
"merchantId": "com.test.merchant",
"merchantName": "Your Store"
},
"details": [
{
"key": "applepay.token",
"type": "applePayToken"
}
],
"name": "Apple Pay",
"type": "applepay"
},
...
]
}
Complete the Apple Pay session validation
This step is only required for web integrations. You do not need to complete the Apple Pay session validation for in-app payments. When the shopper selects to pay with Apple Pay, you get theonvalidatemerchant event handler. You then need to complete the Apple Pay session validation using the completeMerchantValidation method.
You can do this by using Adyen’s Apple Pay certificate, or you can use your own:
- Use Adyen's Apple Pay certificate
- Use your own Apple Pay certificate
- Use Adyen's Apple Pay certificate
- Use your own Apple Pay certificate
-
Make an
/applePay/sessionscall to retrieve the payment session for Apple Pay, and include:/applePay/sessions requestParameters Required Description displayName
The value of the configuration.merchantNamefield from the /paymentMethods response.domainName
The domain name you provided when you added Apple Pay in your Customer Area. This has to match the window.location.hostnameof the web shop.merchantIdentifier
The value of configuration.merchantIdfield from the /paymentMethods response.curl https://checkout-test.adyen.com/v64/applePay/sessions \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "displayName": "YOUR_MERCHANT_NAME", "domainName": "YOUR_DOMAIN_NAME", "merchantIdentifier": "YOUR_MERCHANT_ID" }' -
Decode the base64-encoded
dataobject you get in the response: /applePay/sessions response{ "data": "BASE_64_ENCODED_DATA" } -
Pass the decoded data as an object to the
completeMerchantValidationmethod to complete the Apple Pay session validation.
- Request a valid session from the Apple Pay server.
- Use the session object from the response to complete the Apple Pay session validation
Make a payment
-
After the shopper authorizes the payment, get the token from the Apple Pay framework and decrypt it in one of two ways:
- Let Adyen handle the decryption
- Handle the decryption yourself. This is only allowed if you are PCI-compliant.
-
Stringify and Base64-encode the entire
paymentDataobject. -
From your server, make a /payments request providing:
paymentMethod.type: applepayapplePayToken: The stringified and base64 encodedpaymentDatayou retrieved from the Apple framework.
curl
curl https://checkout-test.adyen.com/v72/payments \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'content-type: application/json' \ -d '{ "merchantAccount":"ADYEN_MERCHANT_ACCOUNT", "reference":"YOUR_ORDER_NUMBER", "amount":{ "currency":"EUR", "value":1000 }, "paymentMethod":{ "type":"applepay", "applePayToken": "QWIwMmI0YzAhQlFBQkFnQjMv.." }, "returnUrl":"https://your-company.example.com/checkout?shopperOrder=12xy.." }'Java
// Adyen Java API Library v27.0.0 import com.adyen.Client; import com.adyen.enums.Environment; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; // For the live environment, additionally include your liveEndpointUrlPrefix. Client client = new Client("ADYEN_API_KEY", Environment.TEST); // Create the request object(s) Amount amount = new Amount() .currency("EUR") .value(1000L); ApplePayDetails applePayDetails = new ApplePayDetails() .applePayToken("QWIwMmI0YzAhQlFBQkFnQjMv..") .type(ApplePayDetails.TypeEnum.APPLEPAY); PaymentRequest paymentRequest = new PaymentRequest() .reference("YOUR_ORDER_NUMBER") .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .paymentMethod(new CheckoutPaymentMethod(applePayDetails)) .returnUrl("https://your-company.example.com/checkout?shopperOrder=12xy.."); // Send the request PaymentsApi service = new PaymentsApi(client); PaymentResponse response = service.payments(paymentRequest, new RequestOptions().idempotencyKey("UUID"));PHP
// Adyen PHP API Library v19.0.0 use Adyen\Client; use Adyen\Environment; use Adyen\Model\Checkout\Amount; use Adyen\Model\Checkout\CheckoutPaymentMethod; use Adyen\Model\Checkout\PaymentRequest; use Adyen\Service\Checkout\PaymentsApi; $client = new Client(); $client->setXApiKey("ADYEN_API_KEY"); // For the live environment, additionally include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("EUR") ->setValue(1000); $checkoutPaymentMethod = new CheckoutPaymentMethod(); $checkoutPaymentMethod ->setApplePayToken("QWIwMmI0YzAhQlFBQkFnQjMv..") ->setType("applepay"); $paymentRequest = new PaymentRequest(); $paymentRequest ->setReference("YOUR_ORDER_NUMBER") ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setPaymentMethod($checkoutPaymentMethod) ->setReturnUrl("https://your-company.example.com/checkout?shopperOrder=12xy.."); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->payments($paymentRequest, $requestOptions);C#
// Adyen .net API Library v17.0.0 using Adyen; using Environment = Adyen.Model.Environment; using Adyen.Model; using Adyen.Model.Checkout; using Adyen.Service.Checkout; // For the live environment, additionally include your liveEndpointUrlPrefix. var config = new Config() { XApiKey = "ADYEN_API_KEY", Environment = Environment.Test }; var client = new Client(config); // Create the request object(s) Amount amount = new Amount { Currency = "EUR", Value = 1000 }; ApplePayDetails applePayDetails = new ApplePayDetails { ApplePayToken = "QWIwMmI0YzAhQlFBQkFnQjMv..", Type = ApplePayDetails.TypeEnum.Applepay }; PaymentRequest paymentRequest = new PaymentRequest { Reference = "YOUR_ORDER_NUMBER", Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", PaymentMethod = new CheckoutPaymentMethod(applePayDetails), ReturnUrl = "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request var service = new PaymentsService(client); var response = service.Payments(paymentRequest, requestOptions: new RequestOptions { IdempotencyKey = "UUID"});NodeJS (JavaScript)
// Adyen Node API Library v18.0.0 // Require the parts of the module you want to use const { Client, CheckoutAPI } = require('@adyen/api-library'); // Initialize the client object // For the live environment, additionally include your liveEndpointUrlPrefix. const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const paymentRequest = { merchantAccount: "ADYEN_MERCHANT_ACCOUNT", reference: "YOUR_ORDER_NUMBER", amount: { currency: "EUR", value: 1000 }, paymentMethod: { type: "applepay", applePayToken: "QWIwMmI0YzAhQlFBQkFnQjMv.." }, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." } // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });Go
// Adyen Go API Library v10.4.0 import ( "context" "github.com/adyen/adyen-go-api-library/v9/src/common" "github.com/adyen/adyen-go-api-library/v9/src/adyen" "github.com/adyen/adyen-go-api-library/v9/src/checkout" ) // For the live environment, additionally include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "EUR", Value: 1000, } applePayDetails := checkout.ApplePayDetails{ ApplePayToken: "QWIwMmI0YzAhQlFBQkFnQjMv..", Type: common.PtrString("applepay"), } paymentRequest := checkout.PaymentRequest{ Reference: "YOUR_ORDER_NUMBER", Amount: amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", PaymentMethod: checkout.ApplePayDetailsAsCheckoutPaymentMethod(&applePayDetails), ReturnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy..", } // Send the request service := client.Checkout() req := service.PaymentsApi.PaymentsInput().IdempotencyKey("UUID").PaymentRequest(paymentRequest) res, httpRes, err := service.PaymentsApi.Payments(context.Background(), req)Python
# Adyen Python API Library v12.5.1 import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the live environment, additionally include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "reference": "YOUR_ORDER_NUMBER", "amount": { "currency": "EUR", "value": 1000 }, "paymentMethod": { "type": "applepay", "applePayToken": "QWIwMmI0YzAhQlFBQkFnQjMv.." }, "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.." } # Send the request result = adyen.checkout.payments_api.payments(request=json_request, idempotency_key="UUID")Ruby
# Adyen Ruby API Library v9.5.1 require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the live environment, additionally include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { :merchantAccount => 'ADYEN_MERCHANT_ACCOUNT', :reference => 'YOUR_ORDER_NUMBER', :amount => { :currency => 'EUR', :value => 1000 }, :paymentMethod => { :type => 'applepay', :applePayToken => 'QWIwMmI0YzAhQlFBQkFnQjMv..' }, :returnUrl => 'https://your-company.example.com/checkout?shopperOrder=12xy..' } # Send the request result = adyen.checkout.payments_api.payments(request_body, headers: { 'Idempotency-Key' => 'UUID' })NodeJS (TypeScript)
The response contains the result of the payment.// Adyen Node API Library v18.0.0 // Require the parts of the module you want to use import { Client, CheckoutAPI, Types } from "@adyen/api-library"; // Initialize the client object // For the live environment, additionally include your liveEndpointUrlPrefix. const client = new Client({apiKey: "ADYEN_API_KEY", environment: "TEST"}); // Create the request object(s) const amount: Types.checkout.Amount = { currency: "EUR", value: 1000 }; const applePayDetails: Types.checkout.ApplePayDetails = { applePayToken: "QWIwMmI0YzAhQlFBQkFnQjMv..", type: Types.checkout.ApplePayDetails.TypeEnum.Applepay }; const paymentRequest: Types.checkout.PaymentRequest = { reference: "YOUR_ORDER_NUMBER", amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", paymentMethod: applePayDetails, returnUrl: "https://your-company.example.com/checkout?shopperOrder=12xy.." }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = checkoutAPI.PaymentsApi.payments(paymentRequest, { idempotencyKey: "UUID" });{ "pspReference": "881539337151149C", "resultCode": "Authorised" }
Present the payment result
Use theresultCode that you received in response to your /payments call to present the payment result to your shopper.The resultCode values you can receive for Apple Pay are:| resultCode | Description | Action to take |
|---|---|---|
| Authorised | The payment was successful. | Inform the shopper that the payment has been successful. |
| Refused | The payment was refused by the shopper’s bank. | Ask the shopper to try the payment again using a different payment method. |
Recurring payments
To make recurring Apple Pay payments, first create a shopper token and then make subsequent recurring transactions with the token.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 > Transactions > Payments.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.Enable Apple Pay either using Adyen’s Apple Pay certificate, which is quicker, or you can also use your own Apple Developer account and certificate which requires extra configuration steps:- Download and unzip the domain association file.
-
Host the domain association file on each domain you want to use, including subdomains. To host the file, use the exact file name apple-developer-merchantid-domain-association under the following path:
The file must:
/.well-known/apple-developer-merchantid-domain-association- Have
Content-Type: text/plainin the header. - Be externally accessible.
- Not be password protected.
- Not be behind a proxy or redirect.
- Have
-
Add Apple Pay in your live Customer Area
- You’ll be asked for Shop websites: your website URLs, for example
https://www.mystore.com. If you add more than one, separate them with a comma.
- You’ll be asked for Shop websites: your website URLs, for example
-
To update or add new Apple Pay domains:
- Go to live Customer Area > Payment Methods.
- Select the specific Apple Pay payment method you want to update.
-
In the sidebar on the right, go to the Apple Pay domains section to find a list of domains currently configured for this payment method. To update the domains, select the Edit button next to the Apple Pay domains heading.
A new sidebar opens where you can make the necessary changes. If there are any errors, this is indicated with red dot. -
To view and fix any errors, select Edit next to the affected domain.
- You must be assigned the Change payment methods role in Customer Area to be able to make domain updates.
- Domain configuration updates apply only to the generic Apple Pay payment method. Scheme-specific variants, like AMEX Apple Pay, Visa Apple Pay, and Mastercard Apple Pay, do not require domain configuration and are not supported by this flow.
- Set up Apple Pay on your Apple Pay Developer account for your live merchant identifier.
-
Configure your firewall’s allow-list:
- Allow Apple IP Addresses for Domain Verification
- Include
out.adyen.comin your configuration to allow communication from our network.
out.adyen.com, and then add those IP addresses to your allow-list. Beware that you still run the risk of a disruption if the IP addresses change.