Update to latest version
Stay organized with collections
Save and categorize content based on your preferences.
The Google Pay API introduced new object structures for
PaymentDataRequest
and
IsReadyToPayRequest
objects in July 2018. This guide explains how to update
objects formatted for Google Pay API version 1 to objects formatted for version 2.
Payment methods
An API version is specified with each request object in version 2 of the Google Pay API.
Version 1 of the Google Pay API supported cards as the only form of payment. The
CARD
payment method
is one of multiple possible payment method options in version 2 of the Google Pay API. Sites that
previously specified an allowedPaymentMethods
value of CARD
must now set
an allowedAuthMethods
value of PAN_ONLY
. Sites that previously specified
an allowedPaymentMethods
value of TOKENIZED_CARD
must now set an
allowedAuthMethods
value of CRYPTOGRAM_3DS
.
Allowed card networks are specified alongside supported authentication methods for cards on
those networks.
apiVersion 1
{
allowedPaymentMethods: [
'CARD',
'TOKENIZED_CARD'
],
cardRequirements: {
allowedCardNetworks: [
'AMEX',
'DISCOVER',
'JCB',
'MASTERCARD',
'VISA'
]
}
}
apiVersion 2
{
apiVersion: 2,
apiVersionMinor: 0,
allowedPaymentMethods: [{
type: 'CARD',
parameters: {
allowedAuthMethods: [
'PAN_ONLY',
'CRYPTOGRAM_3DS'
],
allowedCardNetworks: [
'AMEX',
'DISCOVER',
'JCB',
'MASTERCARD',
'VISA'
]
}
}]
}
Allowed card networks and their authentication methods are included in an
IsReadyToPayRequest
for a CARD
payment method.
Card payment data tokenization
The Google Pay API returns encrypted card data that's referenced by your specified gateway or
decrypted on your servers. Version 2 of the Google Pay API moves
payment method tokenization
inside the CARD
payment method.
apiVersion 1
{
paymentMethodTokenizationParameters: {
tokenizationType: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'example',
'gatewayMerchantId': 'exampleMerchantId'
}
}
}
apiVersion 2
{
allowedPaymentMethods: [{
type: 'CARD',
tokenizationSpecification: {
type: 'PAYMENT_GATEWAY',
parameters: {
'gateway': 'example',
'gatewayMerchantId': 'exampleMerchantId'
}
}
}]
}
Google merchant ID
A Google merchant ID was a top-level property in version 1 of the Google Pay API. Now, the
Google merchant ID is placed inside a
MerchantInfo
object
with an optional merchant name.
apiVersion 1
{
merchantId: '12345678901234567890'
}
apiVersion 2
{
merchantInfo: {
merchantId: '12345678901234567890'
}
}
Billing address
An optional billing address and a billing phone number are associated with a CARD
payment method.
If a site requests a billing address, any configuration related to the expected response is placed inside a
BillingAddressParameters
object.
apiVersion 1
{
cardRequirements: {
billingAddressRequired: true,
billingAddressFormat: 'FULL'
},
phoneNumberRequired: true
}
apiVersion 2
{
allowedPaymentMethods: [{
type: 'CARD',
parameters: {
billingAddressRequired: true,
billingAddressParameters: {
format: 'FULL',
phoneNumberRequired: true
}
}
}]
}
Shipping address
An optional shipping address requirement remains at the top level of the
PaymentDataRequest
object.
The shippingAddressRequirements
property has been renamed
shippingAddressParameters
.
Earlier Google Pay API responses might have returned a phone number as part of the shipping address
when a phone number was requested. A shipping phone number is no longer supported by the Google Pay API in any version.
Any response handlers that expect a shipping phone number must be updated.
apiVersion 1
{
shippingAddressRequired: true,
shippingAddressRequirements: {
allowedCountryCodes: [
'US',
'CA'
]
}
}
apiVersion 2
{
shippingAddressRequired: true,
shippingAddressParameters: {
allowedCountryCodes: [
'US',
'CA'
]
}
}
PaymentData response
The PaymentData
object response
for sites that set an apiVersion
property value of 2
in
PaymentDataRequest
has changed to reference cards as one of multiple possible payment data responses.
The apiVersion
and apiVersionMinor
properties included in the
PaymentDataRequest
object
appear in the
PaymentData
response to indicate
the expected format.
apiVersion 1
{
// no version specified
}
apiVersion 2
{
apiVersion: 2,
apiVersionMinor: 0
}
Information about a selected payment method and its tokenization is placed inside the
paymentMethodData
property.
Two properties have been removed from the card payment method's cardInfo
object:
cardClass
and cardImageUri
.
apiVersion 1
{
cardInfo: {
cardDescription: 'Visa •••• 1234',
cardNetwork: 'VISA',
cardDetails: 1234
},
paymentMethodToken: {
tokenizationType: 'PAYMENT_GATEWAY',
token: 'examplePaymentMethodToken'
}
}
apiVersion 2
{
paymentMethodData: {
type: 'CARD',
description: 'Visa •••• 1234',
info: {
cardNetwork: 'VISA',
cardDetails: '1234'
},
tokenizationData: {
type: 'PAYMENT_GATEWAY',
token: 'examplePaymentMethodToken'
}
}
}
Encrypted message response
Sites that specify a DIRECT
payment method tokenization type and accept an
API version 1 payment method of TOKENIZED_CARD
must update how they handle the
decrypted encryptedMessage
property. The site must do this to continue to forward
Android device tokens authenticated with a 3-D Secure cryptogram and optional electronic commerce
indicator (ECI) to your gateway or processor. Cards are a paymentMethod
of
CARD
, with additional information about the selected card's authentication method in
paymentMethodDetails.authMethod
.
apiVersion 1
{
"paymentMethod": "TOKENIZED_CARD",
"paymentMethodDetails": {
"authMethod": "3DS",
"dpan": "1111222233334444",
"expirationMonth": 10,
"expirationYear": 2020,
"3dsCryptogram": "AAAAAA...",
"3dsEciIndicator": "eci indicator"
}
}
apiVersion 2
{
"paymentMethod": "CARD",
"paymentMethodDetails": {
"authMethod": "CRYPTOGRAM_3DS",
"pan": "1111222233334444",
"expirationMonth": 10,
"expirationYear": 2020,
"cryptogram": "AAAAAA...",
"eciIndicator": "eci indicator"
}
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[[["\u003cp\u003eGoogle Pay API \u003ccode\u003ePaymentDataRequest\u003c/code\u003e and \u003ccode\u003eIsReadyToPayRequest\u003c/code\u003e objects have been updated with new structures in version 2, requiring updates to existing integrations.\u003c/p\u003e\n"],["\u003cp\u003eVersion 2 introduces explicit API versioning and expands payment methods beyond just cards, requiring adjustments to \u003ccode\u003eallowedPaymentMethods\u003c/code\u003e and \u003ccode\u003eallowedAuthMethods\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003ePayment method tokenization, Google merchant ID, billing address configuration, and shipping address parameters have been relocated within the new object structure.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ePaymentData\u003c/code\u003e response format has been revised to include API version information and nest card details within \u003ccode\u003epaymentMethodData\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eHandling of encrypted message responses for tokenized cards requires updates to accommodate the new \u003ccode\u003epaymentMethod\u003c/code\u003e and \u003ccode\u003epaymentMethodDetails\u003c/code\u003e structure.\u003c/p\u003e\n"]]],["The Google Pay API updated its object structures to version 2. Key changes include specifying the API version in each request and expanding payment methods beyond just `CARD`. Version 2 requires setting `allowedAuthMethods` to `PAN_ONLY` or `CRYPTOGRAM_3DS` instead of `allowedPaymentMethods`. Tokenization moved inside the `CARD` payment method, and the merchant ID is now within the `MerchantInfo` object. Billing and shipping address requirements are reorganized. Finally, `PaymentData` responses now specify the API version.\n"],null,["The Google Pay API introduced new object structures for\n[`PaymentDataRequest`](/pay/api/web/reference/request-objects#PaymentDataRequest) and\n[`IsReadyToPayRequest`](/pay/api/web/reference/request-objects#IsReadyToPayRequest) objects in July 2018. This guide explains how to update\nobjects formatted for Google Pay API version 1 to objects formatted for version 2.\n\nPayment methods\n\nAn API version is specified with each request object in version 2 of the Google Pay API.\n\nVersion 1 of the Google Pay API supported cards as the only form of payment. The\n`CARD` [payment method](/pay/api/web/reference/request-objects#PaymentMethod)\nis one of multiple possible payment method options in version 2 of the Google Pay API. Sites that\npreviously specified an `allowedPaymentMethods` value of `CARD` must now set\nan `allowedAuthMethods` value of `PAN_ONLY`. Sites that previously specified\nan `allowedPaymentMethods` value of `TOKENIZED_CARD` must now set an\n`allowedAuthMethods` value of `CRYPTOGRAM_3DS`.\n\nAllowed card networks are specified alongside supported authentication methods for cards on\nthose networks. \n\napiVersion 1 \n\n```javascript\n{\n allowedPaymentMethods: [\n 'CARD',\n 'TOKENIZED_CARD'\n ],\n cardRequirements: {\n allowedCardNetworks: [\n 'AMEX',\n 'DISCOVER',\n 'JCB',\n 'MASTERCARD',\n 'VISA'\n ]\n }\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n apiVersion: 2,\n apiVersionMinor: 0,\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n allowedAuthMethods: [\n 'PAN_ONLY',\n 'CRYPTOGRAM_3DS'\n ],\n allowedCardNetworks: [\n 'AMEX',\n 'DISCOVER',\n 'JCB',\n 'MASTERCARD',\n 'VISA'\n ]\n }\n }]\n}\n```\n\nAllowed card networks and their authentication methods are included in an\n[`IsReadyToPayRequest`](/pay/api/web/reference/request-objects#IsReadyToPayRequest) for a `CARD`\n[payment method](/pay/api/web/reference/request-objects#PaymentMethod \"Object reference: payment method\").\n\nCard payment data tokenization\n\nThe Google Pay API returns encrypted card data that's referenced by your specified gateway or\ndecrypted on your servers. Version 2 of the Google Pay API moves\n[payment method tokenization](/pay/api/web/reference/request-objects#PaymentMethodTokenizationSpecification \"Object reference: PaymentMethodTokenizationSpecification\")\ninside the `CARD` payment method. \n\napiVersion 1 \n\n```javascript\n{\n paymentMethodTokenizationParameters: {\n tokenizationType: 'PAYMENT_GATEWAY',\n parameters: {\n 'gateway': '\u003cvar translate=\"no\"\u003eexample\u003c/var\u003e',\n 'gatewayMerchantId': '\u003cvar translate=\"no\"\u003eexampleMerchantId\u003c/var\u003e'\n }\n }\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n allowedPaymentMethods: [{\n type: 'CARD',\n tokenizationSpecification: {\n type: 'PAYMENT_GATEWAY',\n parameters: {\n 'gateway': '\u003cvar translate=\"no\"\u003eexample\u003c/var\u003e',\n 'gatewayMerchantId': '\u003cvar translate=\"no\"\u003eexampleMerchantId\u003c/var\u003e'\n }\n }\n }]\n}\n```\n\nGoogle merchant ID\n\nA Google merchant ID was a top-level property in version 1 of the Google Pay API. Now, the\nGoogle merchant ID is placed inside a\n[`MerchantInfo`](/pay/api/web/reference/request-objects#MerchantInfo) object\nwith an optional merchant name. \n\napiVersion 1 \n\n```javascript\n{\n merchantId: '12345678901234567890'\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n merchantInfo: {\n merchantId: '12345678901234567890'\n }\n}\n```\n\nBilling address\n\nAn optional billing address and a billing phone number are associated with a `CARD` payment method.\nIf a site requests a billing address, any configuration related to the expected response is placed inside a\n[`BillingAddressParameters`](/pay/api/web/reference/request-objects#BillingAddressParameters) object. \n\napiVersion 1 \n\n```javascript\n{\n cardRequirements: {\n billingAddressRequired: true,\n billingAddressFormat: 'FULL'\n },\n phoneNumberRequired: true\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n allowedPaymentMethods: [{\n type: 'CARD',\n parameters: {\n billingAddressRequired: true,\n billingAddressParameters: {\n format: 'FULL',\n phoneNumberRequired: true\n }\n }\n }]\n}\n```\n\nShipping address\n\nAn optional shipping address requirement remains at the top level of the\n[`PaymentDataRequest`](/pay/api/web/reference/request-objects#PaymentDataRequest) object.\nThe `shippingAddressRequirements` property has been renamed\n[`shippingAddressParameters`](/pay/api/web/reference/request-objects#ShippingAddressParameters).\n\nEarlier Google Pay API responses might have returned a phone number as part of the shipping address\nwhen a phone number was requested. A shipping phone number is no longer supported by the Google Pay API in any version.\nAny response handlers that expect a shipping phone number must be updated. \n\napiVersion 1 \n\n```javascript\n{\n shippingAddressRequired: true,\n shippingAddressRequirements: {\n allowedCountryCodes: [\n 'US',\n 'CA'\n ]\n }\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n shippingAddressRequired: true,\n shippingAddressParameters: {\n allowedCountryCodes: [\n 'US',\n 'CA'\n ]\n }\n}\n```\n\nPaymentData response\n\nThe [`PaymentData`](/pay/api/web/reference/response-objects#PaymentData) object response\nfor sites that set an `apiVersion` property value of `2` in\n[`PaymentDataRequest`](/pay/api/web/reference/request-objects#PaymentDataRequest)\nhas changed to reference cards as one of multiple possible payment data responses.\nThe `apiVersion` and `apiVersionMinor` properties included in the\n[`PaymentDataRequest`](/pay/api/web/reference/request-objects#PaymentDataRequest) object\nappear in the\n[`PaymentData`](/pay/api/web/reference/response-objects#PaymentData) response to indicate\nthe expected format. \n\napiVersion 1 \n\n```javascript\n{\n // no version specified\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n apiVersion: 2,\n apiVersionMinor: 0\n}\n```\n\nInformation about a selected payment method and its tokenization is placed inside the\n[`paymentMethodData`](/pay/api/web/reference/response-objects#PaymentMethodData) property.\nTwo properties have been removed from the card payment method's `cardInfo` object:\n`cardClass` and `cardImageUri`. \n\napiVersion 1 \n\n```javascript\n{\n cardInfo: {\n cardDescription: 'Visa •••• 1234',\n cardNetwork: 'VISA',\n cardDetails: 1234\n },\n paymentMethodToken: {\n tokenizationType: 'PAYMENT_GATEWAY',\n token: 'examplePaymentMethodToken'\n }\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n paymentMethodData: {\n type: 'CARD',\n description: 'Visa •••• 1234',\n info: {\n cardNetwork: 'VISA',\n cardDetails: '1234'\n },\n tokenizationData: {\n type: 'PAYMENT_GATEWAY',\n token: 'examplePaymentMethodToken'\n }\n }\n}\n```\n\nEncrypted message response\n\nSites that specify a `DIRECT` payment method tokenization type and accept an\nAPI version 1 payment method of `TOKENIZED_CARD` must update how they handle the\ndecrypted `encryptedMessage` property. The site must do this to continue to forward\nAndroid device tokens authenticated with a 3-D Secure cryptogram and optional electronic commerce\nindicator (ECI) to your gateway or processor. Cards are a `paymentMethod` of\n`CARD`, with additional information about the selected card's authentication method in\n`paymentMethodDetails.authMethod`. \n\napiVersion 1 \n\n```javascript\n{\n \"paymentMethod\": \"TOKENIZED_CARD\",\n \"paymentMethodDetails\": {\n \"authMethod\": \"3DS\",\n \"dpan\": \"1111222233334444\",\n \"expirationMonth\": 10,\n \"expirationYear\": 2020,\n \"3dsCryptogram\": \"AAAAAA...\",\n \"3dsEciIndicator\": \"eci indicator\"\n }\n}\n```\n\napiVersion 2 \n\n```javascript\n{\n \"paymentMethod\": \"CARD\",\n \"paymentMethodDetails\": {\n \"authMethod\": \"CRYPTOGRAM_3DS\",\n \"pan\": \"1111222233334444\",\n \"expirationMonth\": 10,\n \"expirationYear\": 2020,\n \"cryptogram\": \"AAAAAA...\",\n \"eciIndicator\": \"eci indicator\"\n }\n}\n```"]]