Aktualizacja do najnowszej wersji
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
W lipcu 2018 r. w Google Pay API wprowadzone zostały nowe struktury obiektów PaymentDataRequest
i IsReadyToPayRequest
. Ten przewodnik wyjaśnia, jak zaktualizować obiekty w formacie wersji 1 Google Pay API do obiektów w formacie wersji 2.
Formy płatności
W wersji 2 Google Pay API każdy obiekt żądania zawiera wersję interfejsu API.
Wersja 1 interfejsu Google Pay API obsługiwała tylko karty. Forma płatności CARD
jest jedną z wielu dostępnych opcji płatności w wersji 2 interfejsu Google Pay API. Witryny, które do tej pory miały ustawioną wartość allowedPaymentMethods
w CARD
, teraz muszą mieć ustawioną wartość allowedAuthMethods
w PAN_ONLY
. Witryny, które do tej pory miały ustawioną wartość allowedPaymentMethods
w TOKENIZED_CARD
, teraz muszą mieć ustawioną wartość allowedAuthMethods
w CRYPTOGRAM_3DS
.
Dozwolone sieci kart są podane razem z obsługiwanymi metodami uwierzytelniania kart w tych sieciach.
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'
]
}
}]
}
Dozwolone sieci kart i ich metody uwierzytelniania są zawarte w IsReadyToPayRequest
dla formy płatności CARD
.
Tokenizacja danych płatności kartą
Google Pay API zwraca zaszyfrowane dane karty, które są używane przez podaną bramę lub odszyfrowane na Twoich serwerach. W wersji 2 interfejsu Google Pay API tokenizacja formy płatności odbywa się wewnątrz formy płatności CARD
.
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'
}
}
}]
}
Identyfikator sprzedawcy w Google
W wersji 1 interfejsu Google Pay API identyfikator sprzedawcy w Google był właściwością najwyższego poziomu. Teraz znajduje się w obiekcie MerchantInfo
wraz z opcjonalną nazwą sprzedawcy.
apiVersion 1
{
merchantId: '12345678901234567890'
}
apiVersion 2
{
merchantInfo: {
merchantId: '12345678901234567890'
}
}
Adres rozliczeniowy
Opcjonalny adres rozliczeniowy i numer telefonu na potrzeby rozliczeń są powiązane z formą płatności CARD
.
Witryna może wysłać żądanie adresu rozliczeniowego – w takiej sytuacji konfiguracja spodziewanej odpowiedzi znajduje się w obiekcie BillingAddressParameters
.
apiVersion 1
{
cardRequirements: {
billingAddressRequired: true,
billingAddressFormat: 'FULL'
},
phoneNumberRequired: true
}
apiVersion 2
{
allowedPaymentMethods: [{
type: 'CARD',
parameters: {
billingAddressRequired: true,
billingAddressParameters: {
format: 'FULL',
phoneNumberRequired: true
}
}
}]
}
Adres dostawy
Opcjonalny adres dostawy nadal jest wymagany na najwyższym poziomie obiektu PaymentDataRequest
.
Nazwa shippingAddressRequirements
została zmieniona na shippingAddressParameters
.
Do tej pory odpowiedzi Google Pay API na żądanie numeru telefonu mogły zwracać numer telefonu jako część adresu dostawy. Numer telefonu na potrzeby dostawy nie jest już obsługiwany w żadnej wersji Google Pay API.
Trzeba zaktualizować funkcje przetwarzające odpowiedź, które oczekują podania numeru telefonu na potrzeby dostawy.
apiVersion 1
{
shippingAddressRequired: true,
shippingAddressRequirements: {
allowedCountryCodes: [
'US',
'CA'
]
}
}
apiVersion 2
{
shippingAddressRequired: true,
shippingAddressParameters: {
allowedCountryCodes: [
'US',
'CA'
]
}
}
Odpowiedź PaymentData
Odpowiedź obiektu PaymentData
dla witryn z właściwością apiVersion
o wartości 2
w PaymentDataRequest
zmieniła się i teraz jako jednej z dostępnych odpowiedzi dotyczących danych płatności używa kart.
Właściwości apiVersion
i apiVersionMinor
w obiekcie PaymentDataRequest
występują w odpowiedzi PaymentData
, aby określić spodziewany format.
apiVersion 1
{
// no version specified
}
apiVersion 2
{
apiVersion: 2,
apiVersionMinor: 0
}
Informacje o wybranej formie płatności i jej tokenizacji znajdują się we właściwości paymentMethodData
.
Z obiektu cardInfo
karty zostały usunięte dwie właściwości: cardClass
i 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'
}
}
}
Odpowiedź na zaszyfrowaną wiadomość
W witrynach, które używają typu tokenizacji formy płatności DIRECT
i obsługują formę płatności TOKENIZED_CARD
zgodnie z wersją 1 interfejsu API, trzeba zaktualizować sposób obsługi odszyfrowanej właściwości encryptedMessage
. Jest to konieczne, aby dalej przekazywać tokeny urządzeń z Androidem uwierzytelnianych za pomocą kryptogramu 3-D Secure i opcjonalnie za pomocą wskaźnika handlu elektronicznego (electronic commerce indicator, ECI) do bramy lub firmy obsługującej płatności. Karta to paymentMethod
z wartością CARD
. W paymentMethodDetails.authMethod
zawiera dodatkowe informacje o metodzie uwierzytelniania wybranej karty.
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"
}
}
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2024-10-16 UTC.
[null,null,["Ostatnia aktualizacja: 2024-10-16 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,["# Update to latest version\n\nThe 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---------------\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\n### apiVersion 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\n### apiVersion 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------------------------------\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\n### apiVersion 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\n### apiVersion 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------------------\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\n### apiVersion 1\n\n```javascript\n{\n merchantId: '12345678901234567890'\n}\n```\n\n### apiVersion 2\n\n```javascript\n{\n merchantInfo: {\n merchantId: '12345678901234567890'\n }\n}\n```\n\nBilling address\n---------------\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\n### apiVersion 1\n\n```javascript\n{\n cardRequirements: {\n billingAddressRequired: true,\n billingAddressFormat: 'FULL'\n },\n phoneNumberRequired: true\n}\n```\n\n### apiVersion 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----------------\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\n### apiVersion 1\n\n```javascript\n{\n shippingAddressRequired: true,\n shippingAddressRequirements: {\n allowedCountryCodes: [\n 'US',\n 'CA'\n ]\n }\n}\n```\n\n### apiVersion 2\n\n```javascript\n{\n shippingAddressRequired: true,\n shippingAddressParameters: {\n allowedCountryCodes: [\n 'US',\n 'CA'\n ]\n }\n}\n```\n\nPaymentData response\n--------------------\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\n### apiVersion 1\n\n```javascript\n{\n // no version specified\n}\n```\n\n### apiVersion 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\n### apiVersion 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\n### apiVersion 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--------------------------\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\n### apiVersion 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\n### apiVersion 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```"]]