Google Pay
Integration Prerequisites
- Before testing
Google Pay
, please join the Google Pay Test Card Suite Group to add test cards - When using
Google Pay
inH5
payments, due to potential security issues withWebView
, the payment process needs to be redirected to a browser. Please ensure your application can handle the redirect back after a successful Google Pay payment
API Request Parameters
Important Note
Google Pay supports both subscription and standard credit card payments:
- For standard credit card payments: Set
subProductType: 'DIRECT'
in the Payment Intent Creation request - For subscription payments: Set
subProductType: 'SUBSCRIBE'
in the Payment Intent Creation request
SDK Integration Process
The Google Pay integration process consists of three main phases as illustrated below:
1. Payment Intent Creation
In this phase:
- Client submits order information to the merchant server
- Merchant server sends a payment request to Onerway with transaction details including
merchantNo
,orderAmount
, andtxnOrderMsg
parameters txnOrderMsg
must containreturnUrl
(for synchronous notification) andnotifyUrl
(for webhook notification)- Onerway creates a transaction record and returns a
transactionId
andredirectUrl
- The initial transaction status is
Unfinished
(U)
2. SDK Payment Process
In this phase:
- Client loads the Onerway SDK JavaScript library
- Client initializes the SDK with the
transactionId
,redirectUrl
andmode: 'GooglePay'
- SDK renders the Google Pay button embedded in the merchant's website/app
- Customer clicks the Google Pay button and completes payment through Google's interface
- The payment result is returned directly without requiring 3DS verification in most cases
3. Payment Result Notification
In this phase:
Synchronized notification:
- SDK receives the transaction result and triggers the
onPaymentCompleted
oronError
callback function - The callback provides essential result parameters including
transactionId
andstatus
- SDK receives the transaction result and triggers the
Asynchronous notification (webhook):
- Simultaneously, Onerway sends detailed payment result data to the
notifyUrl
via HTTPPOST
- The webhook contains complete transaction information including
transactionId
,status
,paymentMethod
,walletTypeName
, andsignature
for verification - Webhook data is more comprehensive than the synchronized notification and should be used as the source of truth
- Simultaneously, Onerway sends detailed payment result data to the
Webhook acknowledgment:
- Merchant server must respond with
transactionId
to acknowledge receipt of the webhook - If no successful response is received, Onerway will retry sending the webhook up to
3
times at 30-minute intervals - Implement idempotent processing to handle potential duplicate notifications
- Merchant server must respond with
Google Pay Configuration Options
Property | Type | Required | Description |
---|---|---|---|
googlePayButtonType | String | No | Type of Google Pay button to display. Supported values: book , buy , checkout , donate , order , pay , plain , subscribe |
googlePayButtonColor | String | No | Google Pay button theme. Supported values: black (default), white |
googlePayEnvironment | String | No | Google Pay environment. Supported values: TEST , PRODUCTION |
buttonWidth | String | No | Button width, e.g., 200px or 100% |
buttonHeight | String | No | Button height, e.g., 40px |
buttonRadius | String | No | Button border radius, e.g., 4px |
Supported Locales
Google Pay supports the following locales for localization:
Language Code | Language Name | Apple Pay Support | Google Pay Support |
---|---|---|---|
ar | Arabic | Yes | Yes |
ca | Catalan | Yes | Yes |
cs | Czech | Yes | Yes |
da | Danish | Yes | Yes |
de | German | Yes | Yes |
el | Greek | Yes | Yes |
en | English | Yes | Yes |
es | Spanish | Yes | Yes |
fi | Finnish | Yes | Yes |
fr | French | Yes | Yes |
hr | Croatian | Yes | Yes |
id | Indonesian | Yes | Yes |
it | Italian | Yes | Yes |
ja | Japanese | Yes | Yes |
ko | Korean | Yes | Yes |
ms | Malay | Yes | Yes |
no | Norwegian | Yes | Yes |
nl | Dutch | Yes | Yes |
pl | Polish | Yes | Yes |
pt | Portuguese | Yes | Yes |
ru | Russian | Yes | Yes |
sk | Slovak | Yes | Yes |
sv | Swedish | Yes | Yes |
th | Thai | Yes | Yes |
tr | Turkish | Yes | Yes |
uk | Ukrainian | Yes | Yes |
zh | Simplified Chinese | Yes | Yes |
vi | Vietnamese | Yes | No |
he | Hebrew | Yes | No |
hi | Hindi | Yes | No |
hu | Hungarian | No | Yes |
ro | Romanian | No | Yes |
zh-TW | Traditional Chinese | No | Yes |
bg | Bulgarian | No | Yes |
et | Estonian | No | Yes |
sr | Serbian | No | Yes |
sl | Slovenian | No | Yes |
API Usage Examples
{
"billingInformation": "{\"address\":\"824 Blind Lane\",\"city\":\"North Ameliaside\",\"country\":\"US\",\"email\":\"john.doe@example.com\",\"firstName\":\"John\",\"identityNumber\":\"14364522468\",\"lastName\":\"Doe\",\"phone\":\"18057477053\",\"postalCode\":\"12308-1270\",\"province\":\"CO\"}",
"merchantCustId": "CustId-I5PE-DN25",
"merchantNo": "800209",
"merchantTxnId": "gpay-195307a0-f5de-4e9d-ad3d-faf1c6ac9d10",
"merchantTxnTime": "2025-05-05 13:14:23",
"orderAmount": "35.99",
"orderCurrency": "USD",
"productType": "CARD",
"shippingInformation": "{\"address\":\"259 Wilton Street\",\"city\":\"Denaton\",\"country\":\"US\",\"email\":\"john.doe@example.com\",\"firstName\":\"John\",\"identityNumber\":\"20373861755\",\"lastName\":\"Doe\",\"phone\":\"15690923060\",\"postalCode\":\"29150-8270\",\"province\":\"CO\"}",
"sign": "698917d17492a3205ccff0d030d84cc6fef9ab903edf50998560cc374f3b419c",
"subProductType": "DIRECT",
"txnOrderMsg": "{\"accept\":\"*/*\",\"appId\":\"1727880846378401792\",\"colorDepth\":\"24\",\"contentLength\":\"16384\",\"javaEnabled\":true,\"language\":\"en-US\",\"products\":\"[{\\\"currency\\\":\\\"USD\\\",\\\"name\\\":\\\"Smartphone Case\\\",\\\"num\\\":\\\"1\\\",\\\"price\\\":\\\"35.99\\\",\\\"type\\\":\\\"accessory\\\"}]\",\"returnUrl\":\"https://merchant-site.com/return\",\"notifyUrl\":\"https://merchant-site.com/webhook\",\"screenHeight\":\"780\",\"screenWidth\":\"320\",\"timeZoneOffset\":\"-660\",\"transactionIp\":\"158.63.117.41\",\"userAgent\":\"Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36\"}",
"txnType": "SALE"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"respCode": "20000",
"respMsg": "Success",
"data": {
"transactionId": "1919259367895859200", // Use this for SDK initialization
"responseTime": "2025-05-05 13:14:26",
"txnTime": null,
"txnTimeZone": "+08:00",
"orderAmount": "35.99",
"orderCurrency": "USD",
"txnAmount": null,
"txnCurrency": null,
"status": "U",
"redirectUrl": "https://sandbox-checkout-sdk.onerway.com", // Use this for SDK initialization
"contractId": null,
"tokenId": null,
"eci": null,
"periodValue": null,
"codeForm": null,
"presentContext": null,
"actionType": null,
"subscriptionManageUrl": null,
"sign": "119a387fb282fe9d8eb82f86a4287e582bc833a71bdd42767be665be031964d8"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
SDK Initialization
After receiving the transactionId
and redirectUrl
from the Payment Intent Creation API, initialize the SDK with the following steps:
// Import the Onerway SDK script
const script = document.createElement('script');
script.src = 'https://checkout-sdk.onerway.com/v3/';
document.body.appendChild(script);
// Create container for SDK rendering
const container = document.createElement('div');
container.id = 'onerway_checkout';
document.body.appendChild(container);
// Initialize the SDK with Google Pay configuration
script.onload = function() {
const transactionId = '1919259367895859200'; // From payment intent creation response
const redirectUrl = 'https://sandbox-checkout-sdk.onerway.com'; // From payment intent creation response
const pacypay = new Pacypay(transactionId, {
container: 'onerway_checkout', // Container ID for SDK rendering
locale: 'en', // Language preference
environment: 'sandbox', // 'sandbox' or 'production'
mode: 'GooglePay', // Must be 'GooglePay' for Google Pay transactions
redirectUrl: redirectUrl, // From payment intent creation response
config: {
googlePayButtonType: 'buy', // Button type: 'book', 'buy', 'checkout', etc.
googlePayButtonColor: 'black', // Button color: 'black' or 'white'
googlePayEnvironment: 'TEST', // 'TEST' or 'PRODUCTION'
buttonWidth: '100%', // Button width
buttonHeight: '44px', // Button height
buttonRadius: '4px', // Button border radius
},
onPaymentCompleted: function(result) {
// Handle payment result
const paymentData = result.data;
const respCode = result.respCode;
const respMsg = result.respMsg;
if(respCode === '20000') {
switch(paymentData.status) {
case 'S': // Success
console.log('Payment successful');
// Update UI, redirect to success page, etc.
break;
case 'F': // Failure
console.log('Payment failed');
// Show error message, offer retry option, etc.
break;
default:
console.log('Unexpected status:', paymentData.status);
}
} else {
console.error('Error processing payment:', respMsg);
}
},
onError: function(error) {
console.error('SDK error:', error);
// Handle SDK initialization errors
}
});
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
SDK Callback Responses
{
"respCode": "20000",
"respMsg": "Success",
"data": {
"transactionId": "1919315843586850816",
"responseTime": "2025-05-05 16:59:18",
"txnTime": "2025-05-05 16:58:50",
"txnTimeZone": "+08:00",
"orderAmount": "10.00",
"orderCurrency": "USD",
"txnAmount": null,
"txnCurrency": null,
"status": "S", // Successful payment
"redirectUrl": null,
"contractId": null,
"tokenId": null,
"eci": "05",
"periodValue": null,
"codeForm": null,
"presentContext": null,
"actionType": null,
"subscriptionManageUrl": null,
"sign": "5a1b0c3d2e4f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Webhook Notifications
{
"notifyType": "TXN",
"transactionId": "1925095661049876480",
"txnType": "SALE",
"merchantNo": "800209",
"merchantTxnId": "1747813544000",
"responseTime": "2025-05-21 15:46:09",
"txnTime": "2025-05-21 15:45:46",
"txnTimeZone": "+08:00",
"orderAmount": "45.00",
"orderCurrency": "USD",
"status": "S",
"eci": "7",
"cardBinCountry": "US",
"reason": "{\"respCode\":\"20000\",\"respMsg\":\"Success\"}",
"sign": "2311cb58580432f4f993ce56efecbe9cf8772242f83db61e0628467a46c566d9",
"paymentMethod": "VISA",
"walletTypeName": "GooglePay",
"channelRequestId": "8002091925095737629216771"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Implementation Best Practices
- Browser Compatibility: Always check for Google Pay compatibility before showing the payment option
- Mobile Integration: For mobile apps, consider using Google Pay's native Android integration for a smoother experience
- Testing: Test thoroughly with Google Pay test cards in the TEST environment before going to production
- Error Handling: Implement robust error handling for a smooth user experience
- Device Detection: Only show Google Pay as an option on compatible devices and browsers
- Transaction Verification: Always verify transaction results through webhook notifications
- WebView Considerations: Be aware of the security limitations when implementing Google Pay in WebViews
- Button Placement: Follow Google Pay's brand guidelines for optimal button placement and styling
Troubleshooting
If you encounter issues with Google Pay integration:
- Browser Support: Ensure you're using a supported browser (Chrome is recommended)
- Test Cards: Confirm you're using valid Google Pay test cards from the test card suite
- Environment Settings: Check that
googlePayEnvironment
is set correctly based on your integration stage - Domain Verification: Ensure your domain is properly registered for Google Pay
- Error Logs: Check browser console for JavaScript errors during SDK initialization
- Redirect URL: Ensure the redirect URL parameter matches the one from the payment intent creation response
- WebView Issues: If using in a mobile app WebView, ensure proper configuration or consider browser redirection
- Transaction Status: Always verify payment status through server-side webhook notifications
For additional assistance, contact Onerway support with your merchant ID and transaction details.