Are you looking for test card numbers?

Would you like to contact support?

No momento, esta página não está disponível em português
Payment-method icon

Custom integration (Web)

Learn how you can submit a payment through Adyen using your existing Apple Pay JavaScript APIs implementation.

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.

Step 1: Stringify the paymentData from the token

Apple Pay 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 and base64 encoded: 

session.onpaymentauthorized = function(event) {
  var token = btoa(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"
}