Skip to Content
Docs

Apple Pay and Google Pay in Universal checkout

Show Apple Pay and Google Pay in Universal checkout with no extra code, when the session offers cards and the device supports the wallet.

Universal checkout shows the Apple Pay and Google Pay buttons with no extra code. A wallet's button shows when the payment session offers cards and the customer's device and browser support that wallet.

Requirements

Set up these before you offer wallets in Universal checkout.

  • Universal checkout runs on your checkout page. See Universal checkout.
  • Apple Pay and Google Pay are turned on in the Pay.com dashboard. See Turn on payment methods.
  • Every domain that shows Universal checkout is registered for Apple Pay. See Apple Pay.

Offer the wallets

The payment session decides which methods Universal checkout shows. Pass card in payment_method_types when you create the session with POST /v1/sessions/payment, and the session offers cards, Apple Pay, and Google Pay. Amounts are in minor units, so 2000 is $20.00.

curl https://api.sandbox.pay.com/v1/sessions/payment \
  -u ':sk-pay-com-sandbox-…' \
  -H 'Content-Type: application/json' \
  -d '{
    "currency": "usd",
    "amount": 2000,
    "customer_reference_id": "927071e4-464c-4f5d-a079-4aa097f922ca",
    "payment_method_types": ["card"]
  }'

Render Universal checkout with the session's client_secret, as you do for cards. Universal checkout checks the customer's device and browser and shows only the wallets they support.

const checkout = pay.checkout({
  clientSecret: session.client_secret,
  onSuccess: (payment) => console.log('Paid', payment.transaction),
  onFailure: (error) => console.log('Payment failed', error.message),
})

checkout.universal({ container: '#pay-com-checkout' })

Handle the result

A wallet payment ends the same way as a card payment. Pay.com.js calls onSuccess or onFailure, and your server confirms the charge with webhooks before it fulfills the order.

To test wallet payments in the sandbox, see Test Apple Pay and Test Google Pay.

Next steps

Was this page helpful?