Stay organized with collections
Save and categorize content based on your preferences.
The Google Pay API can be used in conjunction with other supported
payment methods in
PaymentRequest.
Step 1: Create a PaymentDataRequest object
Configure a
PaymentDataRequest
object specifying your payment gateway and accepted methods of payment.
We recommend you obtain shipping address, email address, and phone number
through the browser's PaymentRequestoptions argument,
not the Google Pay API, for consistency across payment methods.
Use the Google Pay API to receive only the payment credentials and
optional billing address.
constgooglePaymentDataRequest={environment:'TEST',apiVersion:2,apiVersionMinor:0,merchantInfo:{// A merchant ID is available after approval by Google.// @see {@link https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist}// merchantId: '12345678901234567890',merchantName:'Example Merchant'},allowedPaymentMethods:[{type:'CARD',parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"]},tokenizationSpecification:{type:'PAYMENT_GATEWAY',// Check with your payment gateway on the parameters to pass.// @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway}parameters:{'gateway':'example','gatewayMerchantId':'exampleGatewayMerchantId'}}}]};
Step 2: Declare Google Pay API support
Add the Google Pay API payment method identifier and its configuration to
the methodData parameter passed to PaymentRequest.
The following example shows an implementation of the Google Pay API with
other supported payment methods in PaymentRequest:
Payment method parameter list
The Google Pay API configuration passed in PaymentRequest is similar to the
PaymentDataRequest
object used by the Google Pay API JavaScript client library with a few exceptions:
An environment property should be set on the object matching a string value described in
PaymentOptions
The transactionInfo property should be omitted. Total price and currency should instead be specified in the details argument passed to PaymentRequest
Additional object properties specified for the Google Pay API payment method in a PaymentRequest payment method data property:
Property
Type
Necessity
Description
environment
string
optional
PRODUCTION: return chargeable methods of payment when
a valid Google merchant ID is specified and configured for the domain
TEST: dummy payment methods returned suitable for
testing (default)
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[[["Google Pay can be integrated with other payment methods using the Payment Request API, primarily supported by Chrome."],["To ensure wider compatibility, use the Google Pay API JavaScript client library with a branded Google Pay button."],["Implementing Google Pay involves creating a PaymentDataRequest object to specify payment details and configuring the Payment Request API to include Google Pay as a supported method."],["The Google Pay API configuration in Payment Request is similar to the PaymentDataRequest object in the Google Pay API JavaScript library, with minor differences in environment and transaction information handling."]]],["This guide outlines using the Google Pay API within the `PaymentRequest` API. Key actions include: creating a `PaymentDataRequest` object to define payment gateway and accepted methods, such as card types and authentication methods. Add Google Pay's identifier and configuration to the `methodData` parameter for `PaymentRequest`. This configuration involves setting environment (e.g., 'TEST'), API versions, and merchant information. Shipping details should be requested through `PaymentRequest` options. Configure `environment` and use the `details` argument for pricing.\n"]]