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.
After full integration with Google Pay, a payment button will appear on your checkout page. The payment flow is as follows:
To start using Google Pay, follow these steps:
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'
}
};
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.
Specify the work environment as 'TEST' or 'PRODUCTION'.
const paymentsClient =
new google.payments.api.PaymentsClient({environment: 'TEST'});
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));
}