Accept Apple Pay and Google Pay with the API
Accept Apple Pay and Google Pay with the API by passing the wallet's payment token to Pay.com from your server.
To accept Apple Pay or Google Pay through the Pay.com API, you render the wallet's button on your frontend and receive a payment token from the wallet when the customer authorizes the payment. Your server then passes the token to Pay.com to create the charge, either decrypted (as a network token) or encrypted (exactly as the wallet returned it).
How it works
When the customer authenticates on their device, the wallet's payment token contains the card's DPAN (Device Primary Account Number), a one-time cryptogram, and an ECI (Electronic Commerce Indicator) value that proves the cardholder authenticated on-device.
When a customer authorizes a payment with Face ID, Touch ID, or passcode, Apple Pay returns an encrypted paymentData object that contains the DPAN, the cryptogram, and the ECI value.
Apple Pay always uses Cryptogram 3DS authentication. The device-level biometric verification satisfies 3DS requirements, so no additional bank challenge is triggered.
There are two ways to send the token to Pay.com:
| Path | How it works | When to use |
|---|---|---|
| You decrypt | Your server decrypts the token and sends the DPAN, cryptogram, and ECI to Pay.com as a network_token. For Apple Pay, you decrypt the paymentData blob using your Apple Pay payment processing certificate. | You need full control over the payload, or you want to inspect the token data before submitting. |
| Pay.com decrypts | Your server passes the encrypted token to Pay.com as the wallet returns it, and Pay.com decrypts it. Send Apple Pay's paymentData with source_data.type: "applepay", or Google Pay's signature, intermediateSigningKey, protocolVersion, and signedMessage with source_data.type: "googlepay". For Apple Pay, your backend also validates the merchant through POST /v1/sessions/applepay. Step 1 shows the requests. Pay.com.js (checkout.headless('applepay'), checkout.headless('googlepay'), or Universal checkout) does this for you. | You want a simpler integration. Requires a real device session and cannot be tested server-side. |
In your app
Take wallet payments in the drop-in or on your own screen.
Requirements
Before processing wallet payments via the API:
- Your environment is configured.
- You have access to your API credentials.
- Your API key is enabled for raw payment data, which Apple Pay, Google Pay, and network token details need. See PCI compliant keys.
- Apple Pay is turned on in the Pay.com dashboard. See Turn on payment methods.
- Register every domain that shows the Apple Pay button with Pay.com, which registers it with Apple for you. See Apple Pay. If you decrypt the token yourself, you use your own Apple merchant ID and validate the merchant with Apple instead (see step 1).
Create a wallet charge
Send the wallet's token to Pay.com from your server, then track the charge's outcome.
- 1
Send the charge request
Once the customer authorizes the payment, call
POST /v1/chargesfrom your server.amountis in minor units (the smallest currency unit), so10000in the examples is $100.00 (or €100.00 ineur).Use the Apple Pay JS SDK on your frontend to prompt the customer for payment. Once the customer authorizes with Face ID, Touch ID, or passcode, Apple returns a
PKPaymentobject. How you validate the merchant and send the charge depends on who decrypts the token.On either path, map the billing address from the
onpaymentauthorizedevent intosource_data.billing_details:Apple Pay field Pay.com parameter payment.billingContact.addressLines[0]line1payment.billingContact.addressLines[1]line2payment.billingContact.localitycitypayment.billingContact.postalCodepostal_codepayment.billingContact.administrativeAreastatepayment.billingContact.countryCodecountryApple Pay opens the payment sheet only after your page completes merchant validation. In your
ApplePaySessiononvalidatemerchanthandler, call your backend. Your backend callsPOST /v1/sessions/applepaywith the domain that shows the Apple Pay button:{ "domain": "checkout.example.com" }The response is Apple's merchant session object. Return it to the browser unchanged and pass it to
session.completeMerchantValidation(). The domain must be registered with Pay.com first (see Apple Pay).When the customer authorizes the payment, send the token from the
onpaymentauthorizedevent to your backend. Setsource_data.typeto"applepay"and pass the fields of the token'spaymentDataobject insource_data.applepayas Apple returns them:version,data,signature, andheader(withephemeralPublicKey,publicKeyHash, andtransactionId). You can also pass the token'spaymentMethodobject (displayName,network,type). Pay.com decrypts the token and processes the payment as an Apple Pay card payment.POST https://api.sandbox.pay.com/v1/charges{ "amount": 10000, "currency": "usd", "source_data": { "type": "applepay", "applepay": { "version": "EC_v1", "data": "<paymentData.data>", "signature": "<paymentData.signature>", "header": { "ephemeralPublicKey": "<paymentData.header.ephemeralPublicKey>", "publicKeyHash": "<paymentData.header.publicKeyHash>", "transactionId": "<paymentData.header.transactionId>" }, "paymentMethod": { "displayName": "Visa 4242", "network": "Visa", "type": "debit" } }, "billing_details": { "name": "John Smith", "email": "john.smith@example.com", "address": { "line1": "123 Main Street", "city": "San Francisco", "state": "CA", "postal_code": "94102", "country": "US" } } }, "customer_reference_id": "cust-john-smith-001", "description": "Apple Pay payment for Order #12348", "reference": "order-12348" }The response has the same shape as the one under You decrypt.
- 2
Listen for webhooks
Subscribe to these events to track the outcome of each charge, and verify every signature before acting on them:
charge.succeeded: The funds were captured successfully.charge.failed: The charge was declined by the issuer or wallet provider.
Next steps
- Create a charge with 3DS: Handle the 3DS authentication flow that
PAN_ONLYtransactions may trigger. - Hold and capture: Reserve wallet funds before finalizing a charge.
- Refund a charge: Return settled wallet funds to the customer.
- Webhooks: Verify signatures and handle charge events reliably.