Overview
This document describes how to integrate Google Pay with Oceanpayment via a server-to-server connection, including payment parameter submission, transaction processing, and result delivery.
For other Google Pay integration methods, see the Google Pay integration guide.
Before You Begin
- For server-to-server Google Pay integration, the merchant must register a Google Pay developer account, use the Payment Token flow to obtain a card information token, and pass the token to Oceanpayment as a parameter.
- Google Pay supports developer registration by entities in China (CN), but merchant onboarding and online payment capabilities may be subject to Google Pay’s regional eligibility policies. In production, some acquiring, settlement, and merchant review capabilities are available only to entities in supported regions, such as HK, SG, EU, and US. We recommend choosing an entity in a Google Pay-supported region for merchant configuration based on your business needs.
Flowchart
Request
1. Register with Google Developer
- Visit https://pay.google.com/about/business.
- Register using a company Gmail or Google Workspace account.
- Select a business account.
2. Create a Merchant ID
After registration, a Merchant ID will be generated. Find it in Google Pay Console > API access > Merchant Info.
3. Configure a Google Pay API Key
- Create a project in Google Cloud Console.
- Enable Google Pay API for Web / Android.
- Obtain an API key.
4. Configure the Merchant Domain Allowlist
- Sign in to Google Developer and go to Google Pay API > Web integration.
- Submit the domain allowlist and screenshots of the payment flow.
5. Obtain a Payment Token
After the user authorizes the payment, the merchant obtains the Google Pay Payment Token. See the Google Pay tutorial for a complete example.
You can use Oceanpayment’s MID for merchantInfo. Contact Oceanpayment Technical Support to obtain this configuration. In this case, the Merchant Domain Allowlist in step 4 will be configured by an Oceanpayment developer.
- Request
const paymentsClient = new google.payments.api.PaymentsClient({ environment: 'TEST' });
const request = {
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [{
type: 'CARD',
parameters: {
allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
allowedCardNetworks: ['VISA', 'MASTERCARD'],
},
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'oceanpayment',
'gatewayMerchantId': 'oceanpayment',
},
},
}],
merchantInfo: {
merchantName: 'OceanPayment',
merchantId: 'BCR2DN4TWW...',
},
transactionInfo: {
totalPriceStatus: 'FINAL',
totalPrice: '10.00',
currencyCode: 'USD',
},
};
paymentsClient.loadPaymentData(request).then(paymentData => {
const token = paymentData.paymentMethodData.tokenizationData.token;
// Send the token to the server for transaction processing
});
- Response
//Google Pay Payment Token
{
"apiVersion": 2,
"apiVersionMinor": 0,
"paymentMethodData": {
"type": "CARD",
"description": "Visa •••• 1111",
"info": {
"cardNetwork": "VISA",
"cardDetails": "1111"
},
"tokenizationData": {
"type": "DIRECT",
"token": "{\"signature\":\"MEQCIB...\",\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"...\\\",\\\"ephemeralPublicKey\\\":\\\"...\\\",\\\"tag\\\":\\\"...\\\"}\"}"
}
}
}
6. card_type Parameter
Convert the returned paymentMethodData.info.cardNetwork value to a supported Oceanpayment card_type enum value before passing it as a parameter.
paymentMethodData.info.cardNetwork | card_type |
|---|---|
| VISA | VISA |
| MASTERCARD | MASTERCARD |
| MAESTRO | MAESTRO |
| JCB | JCB |
| ELO | ELO |
| DISCOVER | DISCOVER |
| CHINAUNIONPAY | CHINAUNIONPAY |
| CARTESBANCAIRES | CARTESBANCAIRES |
| AMEX | AMEX |
- Request
-d 'card_type=VISA' \
7. Submit the Payment Request
The merchant’s server submits the required parameters via direct integration and passes the paymentData.paymentMethodData.tokenizationData.token object from the Google Pay Payment Token as the value of pay_accountNumber.
cURL -X POST 'https://test-secure.oceanpayment.com/gateway/direct/pay'
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'account=995149' \
-d 'terminal=99514901' \
-d 'signValue=6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' \
-d 'backUrl=https://www.abc.com/back.php' \
-d 'noticeUrl=https://www.abc.com/notice.php' \
-d 'order_number=NO12345678' \
-d 'order_currency=USD' \
-d 'order_amount=0.01' \
-d 'methods=GooglePay' \
-d 'order_notes=' \
-d 'pay_accountNumber={\"signature\":\"MEQCIB...\",\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"...\\\",\\\"ephemeralPublicKey\\\":\\\"...\\\",\\\"tag\\\":\\\"...\\\"}\"}' \
-d 'card_type=VISA' \
-d 'billing_firstName=test' \
-d 'billing_lastName=test' \
-d 'billing_email=test@gmail.com' \
-d 'billing_phone=13800138000' \
-d 'billing_country=US' \
-d 'billing_state=AL' \
-d 'billing_city=Washington D.C.' \
-d 'billing_address=705A big Road' \
-d 'billing_zip=529012' \
-d 'billing_ip=127.0.0.1' \
-d 'productNum=1' \
-d 'productName=Red Dress' \
-d 'productSku=#001' \
-d 'productPrice=0.01' \
QuickPay
Pass the Payment Token to Oceanpayment using the pay_accountNumber parameter to create a subscription through the QuickPay direct integration API.
Response
- Check the
pay_urlfield in the payment response to determine whether 3DS verification is required. See the full list of response parameters.
- Response
<?xml version="1.0" encoding="UTF-8"?>
<response>
<notice_type>transaction</notice_type>
<push_dateTime>2025-12-19 09:52:47</push_dateTime>
<account>995149</account>
<terminal>99514901</terminal>
<signValue>D6315600AE0002C1468DC9B943E17E90B314E73581393ABC332B92985E41B100</signValue>
<methods>GooglePay</methods>
<order_number>NO12345678</order_number>
<card_country>PL</card_country>
<order_currency>USD</order_currency>
<order_amount>0.01</order_amount>
<order_notes></order_notes>
<card_number>411111***1111</card_number>
<card_type>Visa</card_type>
<payment_country></payment_country>
<payment_id>231219095247018026021</payment_id>
<payment_authType>3</payment_authType>
<payment_status>-1</payment_status>
<payment_details>80093:3D Authorized Service not completed</payment_details>
<payment_solutions></payment_solutions>
<payment_risk></payment_risk>
<payment_amount></payment_amount>
<payment_exchangeRate></payment_exchangeRate>
<auth_reason></auth_reason>
<auth_code></auth_code>
<pay_userId></pay_userId>
<pay_url></pay_url>
</response>
- If
xml->pay_urlis empty, no 3DS verification is required, andxmlcontains the payment result. An asynchronous notification is sent tonoticeUrl. - If
xml->pay_urlis not empty, 3DS verification is required. Redirect the user topay_urlto complete verification. The payment result will then be sent tobackUrlagain. By default, receive it using$_POST. An asynchronous notification is also sent tonoticeUrl.- Redirect the user to
pay_url:
- Redirect the user to
HTTP/1.2 301 Moved Permanently
Location: {pay_url}
Payment Status
See Payment Status for details.
Asynchronous Notification
You also need to receive the transaction’s asynchronous notification via noticeUrl.
Signature
See Signature Generation and Verification for details.