Google Pay for API only
Last updated: August 28, 2024
To accept Google Pay payments, you must:
- Tokenize the Google Pay payment data.
- Request a Google Pay payment.
- Follow the integration guides, depending on the platform you are integrating:
- Register your domain and obtain your Google merchant ID directly through the Google Pay & Wallet Console.
Note
Integrations using the Payments API do not support domain registration through the Enroll an entity to the Google Pay Service endpoint.
When you receive the payment data from Google, call the Request a token endpoint to tokenize the encrypted payment data.
The payment data is in the paymentMethodToken property of the Google Pay payment data response.
For more information about Google Pay payment requests, see Google Developer – Web object reference.
Note
To process Google Pay transactions, you must authenticate your request using the same public key you provided to the Google API in the tokenizationSpecification.parameters.gatewayMerchantId field.
Information
Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see API endpoints.
post
https://{prefix}.api.checkout.com/tokens
1{2"type": "googlepay",3"token_data": {4"protocolVersion": "ECv1",5"signature": "TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",6"signedMessage": "{\"encryptedMessage\": \"ZW5jcnlwdGVkTWVzc2FnZQ==\", \"ephemeralPublicKey\": \"ZXBoZW1lcmFsUHVibGljS2V5\", \"tag\": \"c2lnbmF0dXJl\"}"7}8}
1{2"type": "googlepay",3"token": "tok_ubfj2q76miwundwlk72vxt2i7q",4"expires_on": "2024-10-22T15:44:03Z"5}
Use the token in your payment request.
Call the Request a payment endpoint, setting the following fields, depending on the token format you want to use:
Information
Your base URL's {prefix} value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see API endpoints.
post
https://{prefix}.api.checkout.com/payments
Make a token payment request from your app or website's back-end server.
When you submit a payment data request to the Google API, you must include the following parameters:
gatewayset tocheckoutltdgatewayMerchantIdset to your public key
You also need to specify which card types and card schemes to support in the request.
1{2"type": "CARD",3"parameters": {4"allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],5"allowedCardNetworks": ["AMEX", "DISCOVER", "MASTERCARD", "VISA"]6},7"tokenizationSpecification": {8"type": "PAYMENT_GATEWAY",9"parameters": {10"gateway": "checkoutltd",11"gatewayMerchantId": "pk_sbox_o2nulev4vbo43i4qkb5p7lfijap"12}13}14}
If the approved field is true, your authorization was successful. A failed authorization can indicate the payment used an invalid or expired card, or a card with an insufficient available balance.
A successful response includes a payment_account_reference value, which is a unique reference to the underlying card for network tokens. If the card scheme provides an eci value, the response includes it. The value indicates the security level that the card scheme decided to request the payment with.
To test Google Pay payments, first create a test Checkout.com account.
You'll then be able to simulate different payment flows using our test cards in your sandbox environment.
Google also offers mock test cards, which you can add to your wallet.
If you perform a payment with a real card in Google's sandbox environment, Google Pay provides a test card in the encrypted payment data. This ensures that no actual transaction takes place. This automatic payment data encryption for testing is unique to Google Pay. Do not perform tests for any other payment method using real card numbers or card details in your sandbox environment.
Note
Google does not validate the Google merchant ID in Sandbox, but does validate it in Production. Register with the Google Pay & Wallet Console and obtain a valid merchant ID before moving to Production.