Antom, leading provider of tailored payment solutions

Accept payments with Google Pay

Through the Google Pay service, buyers can make payments using the credit or debit cards stored in their Google Pay accounts. When using the Native API method, the merchant frontend needs to directly integrate the Google Pay SDK. After obtaining the card asset information, call Antom’s pay (One-time Payments) API to initiate payment. For details on integrating the Google Pay SDK, refer to Google Pay for Payments (Web) or Google Pay for Payments (Android).

User experience

The following figures demonstrate the user experience of paying with Google Pay:
Web
Mobile

Integration preparations

Before you start integrating, read the Integration Guide and API Overview documents to understand the integration steps of the server-side API and the precautions for calling the API. Furthermore, ensure that the following prerequisites are met:
  • Obtain a client ID
  • Complete the key configuration
  • Complete the configuration of paymentNotifyUrl to receive the asynchronous notification
  • Integrate the server-side SDK package, install the server-side library, and initialize a request instance. For more details, refer to Server-side SDKs.

Integration Steps

Follow these steps to start the integration:
  1. Decrypt paymentToken
  2. Initiate an authorized payment
  3. (Optional) Redirect to the 3DS authentication page
  4. Obtain the authorization result
  5. Capture

Step 1: Decrypt paymentToken

After you obtain paymentToken, you can choose one of the following methods to decrypt the token and call the pay (One-time Payments) API to initiate an authorized payment request.
  • Hosted decryption: Antom manages certificates and performs decryption on your behalf, so you do not need to be PCI-qualified.
  • Merchant decryption: You manage your own certificates and perform decryption operations yourself, and this mode requires that you are PCI-qualified.
Note: For more information about PCI DSS compliance requirements, see PCI DSS standard.

Step 2: Initiate an authorized payment ​
Server-side

The parameters required for initiating an authorized payment differ depending on the decryption method used. Refer to the corresponding instructions based on the decryption method you adopt.
Hosted decryption
The following illustrates the payment flow for Antom-hosted decryption of paymentToken:
After you integrate the Google Pay SDK, use Antom's configuration in Google Pay to interact.
Below is the acquirer information of Antom for Google Pay:
text
gateway: alipayintl
gatewayMerchantId:  The merchant ID that the merchant obtains from Antom after onboarding in the corresponding environment (PROD/SANDBOX).
The following is a sample code of the interaction:
Web
java
const tokenizationSpecification = {
    type: 'PAYMENT_GATEWAY',
    parameters: {
    'gateway': "alipayintl",
    'gatewayMerchantId': "2188XXXXXXXX"
    }
};
Android
java
private static JSONObject getGatewayTokenizationSpecification() throws JSONException {
  return new JSONObject() {
    {
      put("type", "PAYMENT_GATEWAY");
      put(
        "parameters",
        new JSONObject() {
          {
            put("gateway", "alipayintl");
            put("gatewayMerchantId", "2188XXXXXXXX");
          }
        }
      );
    }
  };
}
After you obtain paymentToken and have Antom decrypt it, initiate the payment using Antom’s card authorization payment capability. You can pass the decrypted paymentToken through the paymentMethod.paymentMethodMetaData.googlePayConfiguration parameter in the pay (One-time Payments) API.
Follow Step 1: Initiate an authorized payment to call the pay (One-time Payments) API and submit the payment request. You need to pass in the basic parameters, order parameters, and device parameters in the payment request. While you do not need to pass in card payment parameters, but you need to pass in the following parameters:
Parameter name
Required
Description
paymentMethod.paymentMethodType
Yes
Payment method enumeration values. For Google Pay, pass in GOOGLEPAY.
paymentMethod.paymentMethodMetaData.googlePayConfiguration.googlePayToken
Yes
Pass in paymentToken you obtained.
For more information about the parameters used to initiate an authorized payment, refer to Step 1: Initiate an authorized payment.
java
public static void payByGooglePayServer2Server() {
  AlipayPayRequest alipayPayRequest = new AlipayPayRequest();
  alipayPayRequest.setProductCode(ProductCodeType.CASHIER_PAYMENT);

  // replace with your paymentRequestId
  String paymentRequestId = UUID.randomUUID().toString();
  alipayPayRequest.setPaymentRequestId(paymentRequestId);

  // set amount
  Amount amount = Amount.builder().currency("SGD").value("4200").build();
  alipayPayRequest.setPaymentAmount(amount);

  // set paymentMethod
  PaymentMethod paymentMethod = PaymentMethod.builder().paymentMethodType("GOOGLEPAY").build();
  alipayPayRequest.setPaymentMethod(paymentMethod);

  // set Google Pay related parameters-hosted decryption
  Map<String, String> googlePayToken = new HashMap<String, String>();
  googlePayToken.put("googlePayToken", "{\"signature\":\"**\".....}");
  paymentMethodMetaData.put("googlePayConfiguration", googlePayToken);
  paymentMethod.setPaymentMethodMetaData(paymentMethodMetaData);

  // replace with your orderId
  String orderId = UUID.randomUUID().toString();

  // set buyer info
  Buyer buyer = Buyer.builder().referenceBuyerId("yourBuyerId").build();

  // set order info
  Order order = Order.builder()
    .referenceOrderId(orderId)
    .orderDescription("antom testing order")
    .orderAmount(amount)
    .buyer(buyer)
    .build();
  alipayPayRequest.setOrder(order);

  // set env info
  Env env = Env.builder().terminalType(TerminalType.WEB).clientIp("1.2.3.4").build();
  alipayPayRequest.setEnv(env);

  // replace with your notify url
  alipayPayRequest.setPaymentNotifyUrl("https://www.yourNotifyUrl.com");

  // replace with your redirect url
  alipayPayRequest.setPaymentRedirectUrl("https://www.yourMerchantWeb.com");

  // pay
  AlipayPayResponse alipayPayResponse = null;
  try {
    alipayPayResponse = CLIENT.execute(alipayPayRequest);
  } catch (AlipayApiException e) {
    String errorMsg = e.getMessage();
    // handle error condition
  }
}
The following shows the sample code of a request:
json
{
  ..................
  
  "paymentMethod": {
    "paymentMethodType": "GOOGLEPAY",
    "paymentMethodMetaData": {
      "googlePayConfiguration":{
        "googlePayToken":"{\"signature\":\"**\".....}"
      }
    },
  },
   ..................
}
For the complete sample code, refer to Step 1: Initiate an authorized payment.
Merchant decryption
The following illustrates the payment flow for merchant-decrypted paymentToken:
After integrating the Google Pay SDK, you can obtain paymentToken through direct tokenization. For more details, refer to Google Pay Developer. Once you have obtained paymentToken, use Antom’s card authorized payment capability to initiate the payment.For more information about the parameters used to initiate an authorized payment, refer to Step 1: Initiate an authorized payment.
Note: Using this mode requires that you are PCI-qualified.
The following are key parameters for initiating a authotized payment request:
Parameter name
Required
Description
paymentMethod.paymentMethodType
Yes
Payment method enumeration values. For Google Pay, pass in GOOGLEPAY.
paymentMethod.paymentMethodMetaData.cardNo
Yes
Pass in the value of the paymentMethodDetails.pan parameter you obtained.
paymentMethod.paymentMethodMetaData.expiryMonth
Yes
Pass in the value of the paymentMethodDetails.expirationMonth parameter you obtained.
paymentMethod.paymentMethodMetaData.expiryYear
Yes
Pass in the value of the paymentMethodDetails.expirationYear parameter you obtained.
paymentMethod.paymentMethodMetaData.mpiData.cavv
No
Pass in the value of the paymentMethodDetails.cryptogram parameter you obtained.
paymentMethod.paymentMethodMetaData.mpiData.eci
No
Pass in the value of the paymentMethodDetails.eciIndicator parameter you obtained.
The following sample code shows how to call the pay (One-time Payments) API:
java
public static void payByGooglePayServer2Server() {
  AlipayPayRequest alipayPayRequest = new AlipayPayRequest();
  alipayPayRequest.setProductCode(ProductCodeType.CASHIER_PAYMENT);

  // replace with your paymentRequestId
  String paymentRequestId = UUID.randomUUID().toString();
  alipayPayRequest.setPaymentRequestId(paymentRequestId);

  // set amount
  Amount amount = Amount.builder().currency("SGD").value("4200").build();
  alipayPayRequest.setPaymentAmount(amount);

  // set paymentMethod- PAN_ONLY scenario
  PaymentMethod paymentMethod = PaymentMethod.builder().paymentMethodType("CARD").build();

  // set paymentMethod- CRYPTOGRAM_3DS scenario
  //PaymentMethod paymentMethod = PaymentMethod.builder().paymentMethodType("GOOGLEPAY").build();

  alipayPayRequest.setPaymentMethod(paymentMethod);

  // set Google Pay related parameters-merchant decryption
  Map<String, Object> paymentMethodMetaData = new HashMap<String, Object>();
  paymentMethodMetaData.put("cardNo", "***********");
  paymentMethodMetaData.put("expiryMonth", "11");
  paymentMethodMetaData.put("expiryYear", "30");

  // Set MpiData info- CRYPTOGRAM_3DS scenario required
  // MpiData mapiDate=new MpiData();
  // mapiDate.setCavv("AAAAAA...");
  // mapiDate.setEci("eci indicator");
  // paymentMethodMetaData.put("mpiData",mapiDate);

  paymentMethod.setPaymentMethodMetaData(paymentMethodMetaData);

  // replace with orderId
  String orderId = UUID.randomUUID().toString();

  // set buyer info
  Buyer buyer = Buyer.builder().referenceBuyerId("yourBuyerId").build();

  // set order info
  Order order = Order.builder()
    .referenceOrderId(orderId)
    .orderDescription("antom testing order")
    .orderAmount(amount)
    .buyer(buyer)
    .build();
  alipayPayRequest.setOrder(order);

  // set env info
  Env env = Env.builder().terminalType(TerminalType.WEB).clientIp("1.2.3.4").build();
  alipayPayRequest.setEnv(env);

  // replace with your notify url
  alipayPayRequest.setPaymentNotifyUrl("https://www.yourNotifyUrl.com");

  // replace with your redirect url
  alipayPayRequest.setPaymentRedirectUrl("https://www.yourMerchantWeb.com");

  // pay
  AlipayPayResponse alipayPayResponse = null;
  try {
    alipayPayResponse = CLIENT.execute(alipayPayRequest);
  } catch (AlipayApiException e) {
    String errorMsg = e.getMessage();
    // handle error condition
  }
}
The following code shows a sample of the obtained Google Pay message and how to call the Antom's pay (One-time Payments) API to initiate a payment request. It includes two card transaction authentication scenarios,PAN_ONLY and CRYPTOGRAM_3DS:
  • PAN_ONLY: This authentication method is associated with the payment cards stored in the user’s Google Account.
  • CRYPTOGRAM_3DS: This authentication method is associated with the cards stored as Android device tokens.
PAN_ONLY
The obtained Google Pay message:
json
"paymentMethod": "CARD",
"paymentMethodDetails": {
  "authMethod": "PAN_ONLY",
  "pan": "1111222233334444",
  "expirationMonth": 10,
  "expirationYear": 2020
},  "gatewayMerchantId": "some-merchant-id",  "messageId": "some-message-id",
"messageExpiration": "1577862000000"
}
The following shows the sample code of a request:
json
{
  ........
  "paymentMethod": {
    "paymentMethodType": "CARD",
    "paymentMethodMetaData": { 
      "cardNo":"1111222233334444",
      "expiryYear":"2020",
      "expiryMonth":"10"
    },
  },

  .........
}
For the complete sample code, refer to Step 1: Initiate an authorized payment.
CRYPTOGRAM_3DS
The obtained Google Pay message:
json
{
  "paymentMethod": "CARD",
  "paymentMethodDetails": {
    "authMethod": "CRYPTOGRAM_3DS",
    "pan": "1111222233334444",
    "expirationMonth": 10,
    "expirationYear": 2020,
    "cryptogram": "AAAAAA...",
    "eciIndicator": "eci indicator"
  },

  "messageId": "some-message-id",
  "messageExpiration": "1577862000000"
}
The following shows the sample code of a request:
json
{
  ........
  "paymentMethod": {
    "paymentMethodType": "GOOGLEPAY", 
    "paymentMethodMetaData": { 
      "cardNo":"1111222233334444",
      "expiryYear":"2020",
      "expiryMonth":"10"
    },
    "mpiData":{
      "cavv":"AAAAAA..."
      "eci":"eci indicator"
    },
  },

  .........
}
For the complete sample code, refer to Step 1: Initiate an authorized payment.

(Optional) Step 3: Redirect to the 3DS authentication page
Client-side

Once the merchant server obtains the normalUrl returned by the response of pay (One-time Payments), it should pass normalUrl to the frontend, which will then redirect the buyer to the 3DS authentication page. For details, see Step 2: Redirect to the 3DS authentication page.
For the processing logic and decision-making regarding 3DS authentication in Google Pay payments, refer to the 3D Secure 2 section of Card payment features.

Step 4: Obtain the authorization result
Server-side

After the buyer completes payment or the payment times out, you can obtain the payment result either by receiving asynchronous notifications from Antom or by proactively querying the result. For detailed steps, refer to Step 3: Obtain the authorization result.

Step 5: Capture
Server-side

After successful authorization, Antom will automatically initiate capture for you, or you can choose to initiate capture manually. After capture, you can obtain the capture result either via asynchronous notification or active query. You should decide whether to ship goods based on the capture result. For specific steps, refer to Capture.

After payments

Cancellation
Server-side

For successful payments, if the buyer requests cancellation or a refund on the same day, you can use Antom’s cancellation capability to cancel the order or release funds. Orders not yet completed can also be cancelled directly. For details, refer to Cancel.

Refund
Server-side

To learn about Antom refund rules and how to initiate a refund for a successful transaction, see Refund for more information.

Dispute
Server-side

Antom provides dispute resolution services for contested transactions. For more information, refer to Dispute Guidance and Dispute resolution.

Reconciliation
Server-side

After the transaction is completed, use the financial reports provided by Antom for reconciliation. For more information on how to reconcile and the settlement rules of Antom, refer to Reconciliation .

Additional content

Card payment features

Card payment features also apply to Google Pay. The following table outlines the support status of these features for Google Pay:
Type
Supported
Conditions
Conditional
  • Not supported in CIT (Cardholder-Initiated Transaction) scenarios. It is recommended to store cards via Google accounts.
  • Supported in MIT (Merchant-Initiated Transaction) scenarios.
Yes
None.
Yes
  • If you set the paymentMethodMetaData.googlePayConfiguration.allowedAuthMethods parameter to CRYPTOGRAM_3DS (or use the default value), and 3DS authentication has already been completed on the Google Pay side, Antom will follow the standard third-party 3DS processing flow. As a result, no additional 3DS experience will be triggered by the payment method within the Checkout Page. For details, refer to Google Pay - Enabling liability shift for eligible Visa device token transactions globally.
  • If you set the paymentMethodMetaData.googlePayConfiguration.allowedAuthMethods parameter to both CRYPTOGRAM_3DS and PAN_ONLY (or use the default value), and 3DS authentication has not been completed on the Google Pay side, Checkout Page will determine whether 3DS authentication is required based on the values you provide for the is3DSAuthentication and enableAuthenticationUpgrade parameters.
Yes
None.
Yes
None.
No
None.