Google Pay™ API Integration

Google Pay™ allows customers to pay using their credit and debit cards stored inside their Google Account. This article describes how you can accept Google Pay payments using PayPlus LLC.

How it works

After full integration with Google Pay, a payment button will appear on your checkout page. The payment flow is as follows:

  1. The user clicks the Google Pay payment button and sees a payment sheet with a list of supported payment methods.
  2. The user selects a payment method, and Google Pay securely returns a payment token for that method to your website.
  3. Your website submits the payment token, along with details about the purchase, to its backend.
  4. To execute the payment, the backend processes the purchase and sends the payment token to PayPlus LLC.
  5. PayPlus LLC will process your payment and return a link to the payment results.

Getting Started

To start using Google Pay, follow these steps:

Configuration & Code

1. Specify Payment Provider

You must specify the payment service provider and the Merchant ID.

const tokenizationSpecification = {
    type: 'PAYMENT_GATEWAY',
    parameters: {
        'gateway': 'payplusllc',
        'gatewayMerchantId': 'Your Merchant ID in PayPlus LLC system'
    }
};

2. Supported Networks & Auth Methods

const allowedCardNetworks = ["MASTERCARD", "VISA"];
const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];

In case of "PAN_ONLY" payment authorization, a 3DS verification will be required. A link to the 3DS page will be returned in the response to the request. After that, redirect the payer to the 3DS page.

3. Environment

Specify the work environment as 'TEST' or 'PRODUCTION'.

const paymentsClient =
    new google.payments.api.PaymentsClient({environment: 'TEST'});

4. Processing the Payment

After receiving the encrypted payment data from Google, you must send it to our server via API.

API Endpoint: POST /api/google-pay-process

Request Parameters:

Parameter Type Description
order string Unique order identifier
amount string Purchase amount (e.g. "25.00")
currency string Currency code (e.g. "USD")
googlePayToken string Token received from Google Pay API

Example Implementation:

function processPayment(paymentData) {
    fetch('/api/google-pay-process', {
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
        body: JSON.stringify({
            order: "ExampleOrderName",
            amount: "25",
            currency: "USD",
            googlePayToken: paymentData.paymentMethodData.tokenizationData.token
        })
    })
    .then(response => response.json())
    .then(data => window.location.href = data.url)
    .catch(error => console.error('Error:', error));
}