After initiating the Apple Pay payment on your website or mobile application, you should receive a token in the onPaymentAuthorized event.
Retrieve the paymentData
from the token and convert it to a string. Pass this to your server, and then submit it in an /payments
request to Adyen.
Adyen supports 3DS only. To specify this in the ApplePay request, pass the merchantCapabilities
parameter set to 3DS (when creating an ApplePay session) : var request = { merchantCapabilities: ['supports3DS'] }
Step 1: Stringify the paymentData from the token
ApplePay returns more data than we need for authorisation, for example a shipping address, but only the PaymentData
is necessary for authorisation. Take this data from the token and convert the JSON to a String:
session.onpaymentauthorized = function(event) {
var token = JSON.stringify(event.payment.token.paymentData);
};
Step 2: Submit the API request
Submit the token
from the previous step in your payments request. Specify applePayToken
in your /payments request.
{
"amount": {
"currency": "USD",
"value": 1000
},
"reference": "Your order number",
"paymentMethod": {
"type": "applepay",
"applePayToken": "{hint:token from step 1}VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU...{/hint}"
},
"returnUrl": "https://your-company.com/...",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
}