Add to checkout
Integrate Apple Pay payments using Pay.com.js or the REST API.
Pay.com supports three integration paths for Apple Pay: Universal checkout, Headless checkout, and the server-to-server API. Choose based on how much control you need over the checkout experience.
Before starting, make sure Apple Pay is enabled on your Pay.com account and your domain is registered. See the Apple Pay overview for prerequisites and dashboard configuration.
Integrate
Integrate Apple Pay with Pay.com.js or directly with the API.
Universal checkout
Apple Pay renders automatically in Universal checkout. No additional code is required beyond the standard SDK initialization. See Universal checkout for setup instructions. Use Universal checkout when you want Pay.com to handle the entire payment flow, including the UI.
Headless checkout
Use Headless checkout when you want to control the user interface and let Pay.com handle the payment logic. You render your own Apple Pay button and control when the payment sheet appears.
Apple Pay is not available in all browsers. Call canMakePayments() after initializing the
checkout instance, and show the button only if the result includes
applepay: true.
const canMakePaymentsResult = await checkout.canMakePayments()
// Example result: { applepay: true, googlepay: false }
if (canMakePaymentsResult.applepay) {
// Show your Apple Pay button
}Trigger the payment when the customer taps the button.
async function handleApplePay() {
try {
await checkout.headless('applepay')
} catch (error) {
console.log('Payment failed:', error.message)
}
}In your app
Show Apple Pay in the drop-in or on your own screen.
Testing
Test against https://api.sandbox.pay.com/v1 with your sk-pay-com-sandbox- API key. Test
transactions never move real funds. See
Environments. To test Apple Pay
through Pay.com checkout, use a real Apple device with a card added to Apple
Wallet.
| Scenario | Test action | Expected result |
|---|---|---|
| Successful payment | Authenticate with Face ID, Touch ID, or the device passcode | status: succeeded, wallet.type: "applepay" in the response |
| Customer cancels | Tap Cancel on the Apple Pay sheet | The sheet closes and no charge is created. |
| Apple Pay unavailable | Open checkout in a browser or on a device where Apple Pay is not set up | canMakePayments() returns applepay: false and the Apple Pay button does not render. |