After initiating the Apple Pay payment on your mobile application, you receive a callback that includes a PKPayment
. This includes paymentData
, a stringified version of the payment token.
Submit this data in your payment request to Adyen.
Adyen supports 3DS only. To specify this in the Apple Pay request, pass the merchantCapabilities
parameter set to 3DS in the PKPaymentRequest: request.merchantCapabilities = PKMerchantCapability3DS;
Step 1: Stringify the paymentData from the token
When the request is completed, you receive a PKPayment which contains paymentData
. Apple Pay returns more data than we need for authorisation, for example a shipping address, but only the paymentData
is necessary for authorisation.
Convert the paymentData
to a String:
func paymentAuthorizationViewController(_ controller: PKPaymentAuthorizationViewController, didAuthorizePayment payment: PKPayment, completion: @escaping (PKPaymentAuthorizationStatus) -> Void) {
let token = String(data: payment.token.paymentData, encoding: .utf8)
}
Step 2: Submit the API request
Submit to /payments
endpoint
If you're using our /payments endpoint, submit the encoded token from step 1 as the value of applePayToken
in the paymentMethod
object:
{
"amount": {
"currency": "EUR",
"value": 2000
},
"reference": "YOUR_REFERENCE",
"paymentMethod": {
"type": "applepay",
"applePayToken": "VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU..."
},
"returnUrl": "https://your-company.com/...",
"merchantAccount": "YOUR_MERCHANT_ACCOUNT"
}
Submit to /authorise
endpoint
If you're using our /authorise endpoint, submit the encoded token from step 1 as the value of payment.token
in the additionalData
object:
{
"amount":{
"value":2000,
"currency":"EUR"
},
"reference":"YOUR_REFERENCE",
"merchantAccount":"YOUR_MERCHANT_ACCOUNT",
"additionalData":{
"payment.token":"VNRWtuNlNEWkRCSm1xWndjMDFFbktkQU..."
}
}