JSON request objects

  • Google Pay API utilizes IsReadyToPayRequest, PaymentDataRequest, and MerchantInfo request objects for payment processing.

  • IsReadyToPayRequest checks user payment capabilities, while PaymentDataRequest configures payment and user data requests within the app.

  • MerchantInfo provides merchant details for display in the Google Pay payment sheet.

  • Payment methods are specified using the PaymentMethod object, currently supporting card payments with configurable tokenization options.

  • Secure handling of payment data is achieved through tokenization, enabling integration with various payment gateways listed in the documentation.

This reference page describes the Google Pay API request object options to use with your application.

IsReadyToPayRequest

This object specifies which payment methods are supported.

Property Type Necessity Description
apiVersion number Required

Major API version.

The value is 2 for this specification.

apiVersionMinor number Required

Minor API version.

The value is 0 for this specification.

allowedPaymentMethods PaymentMethod[ ] Required

Specifies support for one or more payment methods supported by the Google Pay API.

A tokenizationSpecification isn't required to determine a viewer's readiness to pay. Provide all required parameters properties for each supported PaymentMethod.

existingPaymentMethodRequired boolean Optional

If set to true, then the isReadyToPay() class method will return true if the current viewer is ready to pay with one or more payment methods specified in allowedPaymentMethods.

Example

This example shows you how to support payment cards and Android device tokens from all supported card networks.

{
  "apiVersion": 2,
  "apiVersionMinor": 0,
  "allowedPaymentMethods": [
    {
      "type": "CARD",
      "parameters": {
        "allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
        "allowedCardNetworks": ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
      }
    }
  ]
}

PaymentDataRequest

Use this object to configure your app's support for the Google Pay API.

Property Type Necessity Description
apiVersion number Required Major API version. The value is 2 for this specification.
apiVersionMinor number Required Minor API version. The value is 0 for this specification.
merchantInfo MerchantInfo Optional Information about the merchant that requests payment data.
allowedPaymentMethods PaymentMethod[ ] Required Specifies support for one or more payment methods supported by the Google Pay API.
transactionInfo TransactionInfo Conditional

Details about the facilitation of the transaction based upon whether the user agrees to the transaction or not. Includes total price and price status.

Exactly, one of the transactionInfo, recurringTransactionInfo, deferredTransactionInfo, or automaticReloadTransactionInfo must be present.

recurringTransactionInfo RecurringTransactionInfo Conditional Details about enrollment for a recurring transaction.
deferredTransactionInfo DeferredTransactionInfo Conditional Details about enrollment for a deferred transaction.
automaticReloadTransactionInfo AutomaticReloadTransactionInfo Conditional Details about enrollment for automatic reload of a stored balance account.
emailRequired boolean Optional Set to true to request an email address.
shippingAddressRequired boolean Optional Set to true to request a full shipping address.
shippingAddressParameters ShippingAddressParameters Optional If shippingAddressParameters is set to true, specify shipping address restrictions.

Example

The following example shows you how to support payment cards and Android device tokens from all supported card networks. The payment cards are tokenized for an example gateway. The request is for a payment method to charge a final amount of 12.34 United States dollars.

{
  "apiVersion": 2,
  "apiVersionMinor": 0,
  "merchantInfo": {
    "merchantName": "Example Merchant"
  },
  "allowedPaymentMethods": [
    {
      "type": "CARD",
      "parameters": {
        "allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
        "allowedCardNetworks": ["AMEX", "DISCOVER", "INTERAC", "JCB", "MASTERCARD", "VISA"]
      },
      "tokenizationSpecification": {
        "type": "PAYMENT_GATEWAY",
        "parameters": {
          "gateway": "example",
          "gatewayMerchantId": "exampleGatewayMerchantId"
        }
      }
    }
  ],
  "transactionInfo": {
    "totalPriceStatus"