Custom integration (In-App)

After initiating the ApplePay payment on your mobile application, you should receive a callback that includes a PKPayment. This includes paymentData, a stringified version of the payment token.

Submit this data in an /authorise request to Adyen.

Adyen supports 3DS only. To specify this in the ApplePay 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 paymentDataApplePay 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

The following example demonstrates how to submit an /authorise request. The value of the payment.token in the additionalData object is the encoded token from step 1.

{
   "amount":{
      "value":2000,
      "currency":"EUR"
   },
   "reference":"Your Reference Here",
   "merchantAccount":"TestMerchant",
   "additionalData":{
      "payment.token":"eyJkYXRhIjoiTkxUYVA5NUU0MlU1azlMYVpzRUpUSXVSQy4uLi4uLi4uLi4iLCJzaWduYXR1cmUiOiJNSUFHQ1NxR1NJYjNEUUVIQXFDQU1JQUNBLi4uLi4uLi4uLi4uIiwiaGVhZGVyIjp7InB1YmxpY0tleUhhc2giOiJqR0tjaHA2MVFkdFdtMEI0VXdmWGJVc0NvbDRtVjNWSW1ub2ZURmRKcXpBPSIsImVwaGVtZXJhbFB1YmxpY0tleSI6Ik1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRWo0Skp1enllTisuLi4uIiwidHJhbnNhY3Rpb25JZCI6IjU5Nzc5NWM1MmE5NjcxNjlhYjIyMTZlZGI1YjUwNGEyMGUyNzBlZTFiMmJiMzcyNjJjNWNmYTEwMTgwZmY2NjIifSwidmVyc2lvbiI6IkVDX3YxIn0="
   }
}

Once you completed the steps above and tested your integration, contact Support Team to configure live processing of Apple Pay payments.