Google Pay
Fetch Google Pay configuration from the gateway, run the Google Pay JS session on your payment page, and authorize the resulting token with CCAUTHCAP.
Google Pay overview
This section covers sending credit card transactions to the gateway using Google Pay.
To accept Google Pay, the web pages that host your payment forms must have their domains registered. The Processor and Merchant Account you use must also support Google Pay; contact your gateway support representative for more information.
For more information on Google Pay itself, see Google's own documentation: an overview of Google Pay, the Google Pay Integration Checklist, and the Google Pay Branding Guidelines, along with Google's list of payment methods that support Google Pay (your allowedCardNetworks is determined by your merchant account configuration), Google's list of countries/regions where Google Pay is available (the gateway supports the currencies enabled by your merchant account configuration), and Google's list of supported browsers.
Test cards will not work when testing Google Pay in a production environment. A real PAN must be used.
Integration flow
These are the steps to integrate Google Pay with the gateway:
- Fetch your Google Pay configuration data from the gateway.
- Add the Google Pay library to your payment page.
- Customize the Google Pay button.
- Handle the Google Pay loaded event.
- Present the Google Pay button.
- Handle the Google Pay button click.
- Handle payment authorization.
- Submit the authorized payment data.
Each step is discussed below with example code. The example code is illustrative only and does not represent code that can be used as-is in a production environment.
Fetching your Google Pay configuration
You need configuration data from the gateway to set up the Google Pay session after the customer clicks the Google Pay button.
Requests must be made in JSON format.
Request parameters
| Field Name | Description |
|---|---|
REQ_USERNAME Required |
API credential username. |
REQ_PASSWORD Required |
API credential password. |
DOMAIN_NAME Required |
Domain name where the payment page is hosted/served from. |
CLIENT_ID Required |
Client ID. |
REQUEST_ACTION Required |
GOOGLEPAYCONFIG. Used to instruct the endpoint to provide the proper Google Pay configuration for your unique information. |
All parameters are required.
Sample body request
{
"request_login": "googlepayClient@Inovio.com",
"request_password": "Test123",
"request_action": "GOOGLEPAYCONFIG",
"domain_name": "paymentpagedomain.com",
"client_id": "100"
}
Sample response
{
"GOOGLEPAY_CLI_CONF_ID": 1,
"REQ_ID": 2744,
"CLIENT_ID": 100,
"DOMAIN_LIST": [
{
"DOMAIN_NAME": "paymentpagedomain.com",
"DOMAIN_STATUS": "ACTIVE"
}
],
"hostConfig": {
"merchantId": "BC...JW",
"environment": "TEST",
"merchantName": "Inovio",
"gatewayId": "inoviopay",
"gatewayMerchantId": "string-string"
}
}
Provide this response on your payment page as the merchantConfig parameter.
Adding the Google Pay library
Import the Google Pay JavaScript library into your payment page, and add an empty <div> titled gpay-container. This div is the placeholder where the Google Pay button appears; you can place it anywhere on your page.
<!DOCTYPE html>
<html lang="en">
<script>
function onGPayApiLoaded() {
googlePayHandler.initialize({
gpayButtonContainerId: 'gpay-container' // The ID of the div where the button should appear
});
}
</script>
<body>
<div id="gpay-container"></div>
<script type="text/javascript" src="main.js"></script>
<script async src="https://pay.google.com/gp/p/js/pay.js" onload="onGPayApiLoaded()"></script>
</body>
</html>
The <div id="gpay-container"></div> is your designated spot for the button. The pay.js script tag asynchronously loads the Google Pay library. The onload="onGooglePayLoaded()" attribute ensures your onGooglePayLoaded() function (which checks whether Google Pay is ready) runs as soon as the library finishes loading.
Handling the Google Pay loaded event
The onGooglePayLoaded() function is called when the Google Pay API script has finished loading. It is the handshake with the Google Pay service, ensuring everything is in order before you present the payment option to your customers.
function onGooglePayLoaded() {
const req = deepCopy(baseGooglePayRequest);
getGooglePaymentsClient()
.isReadyToPay(req)
.then(function (res) {
if (res.result) {
renderGooglePayButton();
} else {
console.log('Google Pay is not ready for this user.');
}
})
.catch(console.error);
}
Configuring Google Pay
The baseGooglePayRequest object defines the fundamental configuration for all Google Pay requests.
const baseGooglePayRequest = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'],
},
tokenizationSpecification: {
type: "PAYMENT_GATEWAY",
parameters: {
"gateway": "inoviopay",
"gatewayMerchantId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
},
],
merchantInfo,
};
Object.freeze(baseGooglePayRequest);
let paymentsClient = null;
function getGooglePaymentsClient() {
if (paymentsClient === null) {
paymentsClient = new google.payments.api.PaymentsClient({
environment: 'TEST', // Environment configuration
merchantInfo,
paymentDataCallbacks: {
onPaymentAuthorized: onPaymentAuthorized,
onPaymentDataChanged: onPaymentDataChanged,
},
});
}
return paymentsClient;
}
Key properties that shape the Google Pay experience:
apiVersionandapiVersionMinor: tell Google Pay which version of the Google Pay API you are using.allowedPaymentMethods: array declaring what types of payments you accept.parameters(within theCARDtype):allowedAuthMethods: defines the authentication methods your integration supports:PAN_ONLY: used for cards saved directly to a user's Google account. Google Pay returns the actual card number. To use 3D Secure withPAN_ONLY, submit your third party 3-D Secure details with the authorization; the gateway will not prevent a transaction from being sent to the processor without 3DS on the transaction request.CRYPTOGRAM_3DS: used for cards tokenized via the Google Wallet app. Instead of the real card number, a device-specific token is used. A 3-D Secure cryptogram is generated on the user's device, providing stronger security and often shifting liability for fraud to the card issuer. Inovio recommends using thisallowedAuthMethodsvalue only.allowedCardNetworks: lists all the major card networks your Merchant Account is set up to accept (American Express, Discover, Mastercard, Visa, and/or more). See Google's official Google Pay documentation for details.
tokenizationSpecification: configuration for how payment credentials are secured and sent to your payment processor.type: "PAYMENT_GATEWAY": indicates that the payment gateway handles tokenization on your behalf.parameters: gateway-specific details essential for secure processing, provided to you when you request your configuration data from the gateway:gateway: the name of your payment gateway (for exampleinoviopay).gatewayMerchantId: your unique ID provided by the gateway.
Object.freeze(baseGooglePayRequest): prevents accidental changes to your base Google Pay configuration after it is set.paymentsClientstarts asnull;getGooglePaymentsClient()uses lazy initialization, creating thePaymentsClientinstance only when needed.environment:'TEST'is for development and debugging; change to'PRODUCTION'when you're ready to go live.paymentDataCallbacks: functions to handle events during the Google Pay flow:onPaymentAuthorized: called after the user has successfully authorized a payment. This is where you send the payment data to the payment service provider for processing.onPaymentDataChanged: fires if the user changes their payment data (such as selecting a different shipping address or payment method) within the Google Pay sheet, letting you dynamically update the order total or shipping options.
Rebilling and card on file
The gateway response returns a CUST_ID and PMT_ID on a successful Google Pay authorization, the same as it does for normal transactions. To authorize against the generated Google Pay payment record, pass the same CUST_ID and PMT_ID on all subsequent rebills or unscheduled merchant-initiated card-on-file transaction requests.
Google Pay is not implemented in any of the four SDKs. A WalletToken variant (walletType: 'applepay' | 'googlepay') is declared in each language's type system, but PaymentMethods only constructs card, token and savedCard in v1, there is no constructor that produces a wallet payment method, so sale()/authorize() cannot be handed a PMT_WALLET_CRYPTOGRAM token today. Send the authorization as a raw HTTP request per the example above, or see the SDKs. Rebilling against the resulting CUST_ID/PMT_ID does work through the SDK once you have them, using the same SavedCard path as Card on File.