Google Pay

Wallet payment using a tokenized card stored in the customer's Google account. The encrypted payment token is obtained from the Google Pay JS API on the client side — it is never constructed manually.

Before you send this request: Initialize the Google Pay API in the browser, call loadPaymentData(), and extract the paymentMethodData.tokenizationData.token from the response. Pass that token as tokenization_data.encrypted_data.token below.

const paymentClient = new PaymentClient(config);

// googlePayToken: the JSON string from paymentMethodData.tokenizationData.token
const response = await paymentClient.authorize({
    merchantTransactionId: "txn_001",
    amount: { minorAmount: 1000, currency: Currency.USD },
    paymentMethod: {
        googlePay: {
            type: "CARD",
            description: "Visa 1111",
            info: {
                cardNetwork: "VISA",
                cardDetails: "1111",
            },
            tokenizationData: {
                encryptedData: {
                    tokenType: "PAYMENT_GATEWAY",
                    token: googlePayToken,
                },
            },
        },
    },
    captureMethod: CaptureMethod.AUTOMATIC,
    address: { billingAddress: {} },
    authType: AuthenticationType.NO_THREE_DS,
    returnUrl: "https://example.com/return",
});

Last updated

Was this helpful?