- 18 Oct 2024
- 7 Minutes to read
Google Pay™
- Updated on 18 Oct 2024
- 7 Minutes to read
Google Pay™
Google Pay is a digital payments platform that allows you to make secure payments with credit or debit cards linked to your account, either in apps and websites. It facilitates fast and secure transactions without the need to manually enter data on each purchase.
Supported operations
Operation | Description |
---|---|
Locks funds on the customer’s card. | |
Completes the transaction and transfers the funds. | |
Combines authorization and capture in one step. | |
Returns the full amount of a transaction. | |
Returns part of the captured amount. | |
Reverses an authorization that was not captured. |
Authentication methods
This parameter defines how transactions for cards that the user uses to pay will be authenticated. In Google Pay, there are two main methods of authentication:
PAN_ONLY
: This authentication method uses the Primary Account Number (PAN), which is the standard 16-digit number on a credit/debit card. In this method, Google Pay doesn't perform additional authentication beyond what the card-issuing bank can do. It's what you typically find when you use the details of a card saved in Google Pay without additional crypto.CRYPTOGRAM_3DS
: This method uses 3D Secure (3DS) with a cryptogram. It's a more secure way to process payments because it adds an extra layer of authentication (such as a password or code sent to the user's phone). This method is more secure and is usually necessary to enable Google Pay in many cases, as it protects the merchant from fraud.
Configuration example: allowedAuthMethods
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS']
Recommendation: If you want to accept as many cards and methods as possible, you'll want to include both (
PAN_ONLY
andCRYPTOGRAM_3DS
). OrkestaPay will automatically handle Google Pay security authentication on the backend.
Supported card networks
The following card networks are supported:
AMEX
: Supported globally.DISCOVER
: Supported in the US.MASTERCARD
: Supported globally.VISA
: Supported globally.
This parameter defines the credit/debit card networks that you will accept through Google Pay.
Configuration example: allowedCardNetworks
allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA']
Recommendation: If you want to accept as many cards as possible, include all relevant networks such as
AMEX
,DISCOVER
,MASTERCARD
, andVISA
.
Compatibility
For more information on Google Pay availability, refer to:
Web integration guide
To integrate Google Pay as a payment method with OrkestaPay, you need to follow the steps below:
1. Set up Google Pay™ as your payment method
To integrate Google Pay, you must first make a series of configurations from the OrkestaPay portal.
Refer to our provider configuration guide for instructions on setting up Google Pay.
2. Tokenize Google Pay™ payment data
To tokenize payment data, follow the following steps:
Include the Google Pay API: Use the Google Pay script in your web application.
Define a payment object: This defines the accepted payment methods, country, and currency.
Render the Google Pay payment button: Place the Google Pay button on your frontend.
Transaction handling: After a successful payment request, Google Pay returns a token which can be processed by OrkestaPay.
Information
For more information on the Google Pay integration, visit its official documentation: Google Pay API.
Code Example
Include the Google Pay API and define an element that serves as a container for the Google Pay button.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Pay Integration</title>
</head>
<body>
<!-- Container where the Google Pay button will be displayed -->
<div id="container"></div>
<!-- Include Google Pay API -->
<script async
src="https://pay.google.com/gp/p/js/pay.js"
onload="onGooglePayLoaded()"></script>
<!-- Include the script.js file -->
<script src="/js/script.js"></script>
</body>
</html>
Define payment object and handle Google Pay (script.js)
In the following code snippet there are certain parameters that need to be replaced:
gateway: orkestapay
gatewayMerchantId: <merchant_id>
merchantId: <merchant_id>
merchantName: <merchant_name>
gateway
It is a fixed value, it will always be "orkestapay".
merchant_id
you can get it from the Developers > Authentication section in the OrkestaPay portal, you can locate it under the name of "Merchant Identifier". You can visit our API keys guide.
merchant_name
is the name under which your business is registered in OrkestaPay.
let paymentsClient = null;
function onGooglePayLoaded() {
paymentsClient = new google.payments.api.PaymentsClient({ environment: "TEST" });
const isReadyToPayRequest = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: "CARD",
parameters: {
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
allowedCardNetworks: ["AMEX", "DISCOVER", "MASTERCARD", "VISA", "JCB", "INTERAC"],
},
},
],
};
paymentsClient
.isReadyToPay(isReadyToPayRequest)
.then(function (response) {
if (response.result) {
addGooglePayButton();
} else {
console.log("Google Pay is not available");
}
})
.catch(function (err) {
console.error("Error verifying Google Pay: ", err);
});
}
function addGooglePayButton() {
const button = paymentsClient.createButton({
onClick: onGooglePayButtonClicked,
});
document.getElementById("container").appendChild(button);
}
function onGooglePayButtonClicked() {
const paymentDataRequest = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [
{
type: "CARD",
parameters: {
allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
allowedCardNetworks: ["AMEX", "DISCOVER", "MASTERCARD", "VISA"],
},
tokenizationSpecification: {
type: "PAYMENT_GATEWAY",
parameters: {
gateway: "orkestapay",
gatewayMerchantId: "<REPLACE_WITH_YOUR_MERCHANT_ID>",
},
},
},
],
merchantInfo: {
merchantId: "<REPLACE_WITH_YOUR_MERCHANT_ID>",
merchantName: "<REPLACE_WITH_YOUR_MERCHANT_NAME>",
},
transactionInfo: {
totalPriceStatus: "FINAL",
totalPrice: "10.00",
currencyCode: "USD",
countryCode: "US",
totalPriceLabel: "Total",
},
};
paymentsClient
.loadPaymentData(paymentDataRequest)
.then(function (paymentData) {
console.log("Payment successful: ", JSON.stringify(paymentData, null, 2));
// Here you would send the paymentData to the OrkestaPay payment method service.
})
.catch(function (err) {
console.error("Payment error: ", err);
});
}
Explanation:
paymentsClient: You initialize the Google Pay client to handle payments.
isReadyToPay: Checks if your device and browser can handle Google Pay.
createButton: Generates the Google Pay button, which is added to the DOM.
loadPaymentData: Executed when the user clicks the button, and the transaction is processed.
Note
This code is a basic example that you should adapt to your real environment.
Response example (paymentData)
{
"apiVersion": 2,
"apiVersionMinor": 0,
"paymentMethodData": {
"description": "Visa •••• 1111",
"info": {
"assuranceDetails": {
"accountVerified": true,
"cardHolderAuthenticated": false
},
"cardDetails": "1111",
"cardNetwork": "VISA"
},
"tokenizationData": {
"token": "{\"signature\":\"MEUCIAkAOzt2OolhLUWW7TvQH8/EajdOc5EEyDWgmQkCgEunAiEAxUSnKq0lTxbxBHn3BM/UO1bBNJvLIRhh2z1cZ7kYLxw\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEXVTmk8AG/HvaFb5vCsIxEV1B/PHelQ+EhU1VH8ozMWo6essiWUTb5zqL0k6E3vtKU15mYFor8hXEmXymQlCfyA\\\u003d\\\u003d\\\",\\\"keyExpiration\\\":\\\"1727542536035\\\"}\",\"signatures\":[\"MEUCIEP9xvk1hfXUDx2vW2JVT9JtAyVP9/wSkg9yL1maVM79AiEAs9vk9VtApISA7/akbYlT0tajyHRuUVnVk3lXK/LdYTs\u003d\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"4KqU5aFZfNpz8gyznScksJA3e0dTeELhx8i9ZGMQhWwEC1XfBY8+oju0qRwnPW4hR4A/qTPLSwDMJCiyvWmG5g4s036hIdbnGltgM5exFvgdKcrMPkco/dMLKf1lC9ptEu4Pm0yd3y4c12lX3BKENcJiBm6rMSfI8O8aUbKb5AUZTFlckptX20jDpeKbxf3dYYvFT3LwqQiSsAkFSHE5M9DYt5d2TczsE8IshfJ4sQ09FkNa9nmRi6Oht1lPYyVncTZ/FGhahPw4UMWdZyIGqi4ftkSwXTK5GuzREKD02MX1uG2W5yVJ4SufkHR2dKTUbv0bkEDDhTdJ33Pvnk6g4416Qi8nCDhHn9Z6SUlWAEBl0XWSvCGtYfXfRnu2oEytHCXdwcIeBtEHV5oIXOE7S9Vsf7SQPt1TLFcOerB703rigI+wpDZ+CjolRvAWA3gpAjakjA7mDLb3/k5OaP7cnbOtVTZjvgGHxTwqvJkp1/41+ZBgRq7KpE8gXYDt5MK2ITUOiIK2Zkczp0COV5NpPcrBpnZveBPm3TRlpavDAGEshU4R2ap3CGpx3sH/xuTMOdSCn3JXyRA3xW9LITc\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BJFp23+Gzshyg1VcNQQ5xTX9u0VgzRhWhNB3kJzVv0WafbUXLA6zEPFaZH1ipc+rZeNAXV4jZbceuhZfAEyXFFY\\\u003d\\\",\\\"tag\\\":\\\"bqrAdO2uEhxqqak+9TKBMy2LjIjBE8mU42iSWPtHLU0\\\u003d\\\"}\"}",
"type": "PAYMENT_GATEWAY"
},
"type": "CARD"
}
}
3. Request payment
It is now necessary to register your payment method in OrkestaPay with the Google Pay response. With the payment_method_id
payment method service's response, you can continue with the regular payment process with OrkestaPay from the backend.
Request example
curl --request POST \
--url https://api.sand.orkestapay.com/v1/payment-methods \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer REPLACE_WITH_YOUR_ACCESS_TOKEN' \
--data '
{
"type": "GOOGLE_PAY",
"google_pay": {
"type": "GOOGLE_PAY",
"wallet_type": "GOOGLE_PAY",
"api_version": 2,
"api_version_minor": 0,
"payment_method_data": {
"description": "Visa •••• 1111",
"type": "CARD",
"tokenization_data": {
"type": "PAYMENT_GATEWAY",
"token": "{\"signature\":\"MEUCIQCP24dzCRs4lN+muhIwb45+Mt24faAQMtWo+Bu0twVLwAIgBbIj/BvilyScLI4dRrTd/Vd7cUbQQ3VqnZhXA/2m6Og\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE/k0+CQ5+L3XDORE9Ossb0xw/BfwSNsqr0g37jTD77nZ+mSy6q6K/UqexWob3FtZqJFFZPzKTsjcmXytTpwf9Sg\\\u003d\\\u003d\\\",\\\"keyExpiration\\\":\\\"1727551338576\\\"}\",\"signatures\":[\"MEUCIQC7rY33WXbZAOFfSbgFnUjJWl6XORXWByOLNC66YSXoiwIgWsv7gMcwziLBy+m3wzjn02yzMLPUX1zUsjdDvfp/Onw\u003d\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"JbnqW1vx1Zac8NxACauZMFAEDu6H3Wdj3xzwOfY6TQyYHApc1S4rmAY0Bf6vjHC3xVAvyvFmCvpH4dC2Bs7D8+VovlxcIitg/BsB8L3QQ9feX0ubyOvSAPHBrmkITJanGUHE8jWZfmvf0/rZOlQICyApQjlD7E9xLffOqxoNcGdIQCV0BKU+8KPvmm98GIzeakHWfgz6T7hjK4T0Q9EYKaqv3F1LW1Yj2mLOc+U1H/8y1x3IGU9O5ndM18WnlBhn2dZ0x8b52lGlGqStanmXnOEJmgW46vTCS/euLyEv/CV600MLSCBvnqmRg0tTy/mejJJQp2mZPXCluYIwkOzs5LSDiaS5pJO9rFgCwBKeewB29JZqtQMMGZzWSrpqCIU/RtQiB4+ccwkMgQTrYAnizhJimkmTyMEbzKePBswGa2y/4siMt6EVlD2OQlmH6CGE1VAW69H0j3kVcyEhbW8Dn1yEvnN09yg2qw36pDIXN7dP+RiGcMBiw03Y5PN4CWHeU+Y7+xTkhjKiD3haQptI5U14noB9w+eZkHmfnAWZ9P12QsTUwqWYbm5nPXxd51IKQ73hZP/TdCyMbDcxz8koQ+sTyBMUbRTDHJS+nrJX4C+XbC4\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BA3u/47gIJkZet6f+AXHQyFB8lmA0scImgmCPy4l0BFGauc5i/KJ7KRPrRgT8LkYk97ZE3xaeLmE35wT4aNgqlw\\\u003d\\\",\\\"tag\\\":\\\"3NsGtjrLVKzcXhkjF/wNH6dpKLEZ1BdATm1StfYiuvk\\\u003d\\\"}\"}"
},
"info": {
"card_network": "VISA",
"card_details": "1111"
}
}
}
}
'
Response example
{
"payment_method_id": "pym_c00b8da28757446380c2a5e0ef4dae8c",
"type": "GOOGLE_PAY",
"card": {
"bin": "411111",
"last_four": "1111",
"brand": "VISA",
"card_type": "DEBIT",
"holder_name": "",
"holder_last_name": "",
"expiration_month": "12",
"expiration_year": "2026",
"one_time_use": true
},
"billing_address": {
"type": "back-end",
"city": "Longmont",
"state": "Lesleystad",
"country": "UY",
"first_name": "Juliana",
"last_name": "Reynolds",
"email": "Kennedi46@yahoo.com",
"line_1": "08994 Bosco Dale",
"line_2": "Gaylord Valleys",
"zip_code": "76127"
},
"status": "ACTIVE",
"created_at": "1726876003520",
"updated_at": "1726876003520"
}
Information
To learn more about the payment method creation service, visit our API documentation.
Information
To learn more about the direct payment integration with OrkestaPay, visit our guide Payment integration.
Other Google Pay™ resources
Google provides a set of additional resources to help you with your implementations: