Add to checkout
Integrate Google Pay payments using Pay.com.js or the REST API.
Pay.com supports three integration paths for Google 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 Google Pay is enabled on your Pay.com account. See the Google Pay overview for prerequisites and dashboard configuration.
Integrate
Integrate Google Pay with Pay.com.js or directly with the API.
Universal checkout
Google Pay renders automatically in Universal checkout. No additional code is needed 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 Google Pay button and control when the payment sheet appears.
Google Pay is not available in all browsers. Call canMakePayments() after
initializing the checkout instance, and show the button only if the result
includes googlepay: true.
const canMakePaymentsResult = await checkout.canMakePayments()
// Example result: { applepay: false, googlepay: true }
if (canMakePaymentsResult.googlepay) {
// Show your Google Pay button
}Trigger the payment when the customer taps the button.
async function handleGooglePay() {
try {
await checkout.headless('googlepay')
} catch (error) {
console.log('Payment failed:', error.message)
}
}In your app
Show Google 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 Google Pay
through Pay.com checkout, use a supported browser with a Google account that
has a card saved to Google Pay.
| Scenario | Test action | Expected result |
|---|---|---|
| Successful payment | Authenticate through the Google Pay sheet | status: succeeded, wallet.type: "googlepay" in the response |
| Customer cancels | Dismiss the Google Pay sheet | The sheet closes and no charge is created. |
| Google Pay unavailable | Open checkout in a browser without Google Pay set up | canMakePayments() returns googlepay: false and the Google Pay button does not render. |