Stay organized with collections Save and categorize content based on your preferences.
This page describes how to use sample tokens to test your integration.
Generate sample tokensFor direct integrations, in order to test token decryption on your server, you can generate sample tokens if you set ENVIRONMENT_TEST
when you construct a PaymentsClient
instance.
When the PaymentsClient
instance is constructed with the environment set to ENVIRONMENT_TEST
, the calls to loadPaymentData
work as usual and request that the user selects one of their real cards. However, it never actually returns real information from the card that was selected, and instead, the token that results always has a constant payload.
ENVIRONMENT_TEST
, but you must add at least one chargeable card to your Google Account before you proceed. In addition, to generate sample tokens for tokenized cards, you need to install and add at least one supported payment method to the Google Pay app. Note: Google doesn't provide test cards. Reach out to your bank if you need chargeable test cards. Verify signature
The tokens produced in ENVIRONMENT_TEST
are encrypted with your test public key that was previously sent to Google.
The tokens are signed with Google's test keys. If you use Tink, ensure that .fetchSenderVerifyingKeysWith(GooglePaymentsPublicKeysManager.INSTANCE_TEST)
is set when you build a PaymentMethodTokenRecipient
object.
Once the sample token is decrypted, you receive the cleartext payload. The payload structure depends on whether the card that was selected is tokenized, which means added to Google Wallet. In addition, the payload for tokenized cards is different, which depends upon the card network. The payload for non-tokenized cards is always the same, regardless of the card network.
The following three fields might differ in your decrypted payload compared to the samples below:
messageExpiration
: This is set one week from the current time.messageId
: This is randomly generated for each payload.expirationYear
: This is set five years from the current year.The structure of the decrypted payload varies between two protocol versions, ECv1 and ECv2. If you implement a new integration, the version is ECv2. If you're uncertain about the protocol version, confirm it with your Google point of contact.
Non-tokenized card VisaThe following is an example of a decrypted payload for non-tokenized Visa cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1650574736277", "messageId": "AH2Ejtc88ZHJ-2aYBQWzHwvp6l0JsCHgxVt8s91A-ZUikaXNbcjsFm6gg9ExeVR-jzIyT-mJvA_ntvfRsDDOH2jnKMjdTtXIJvPt0NBUU45R7-gnjxkx-sI0ldcWvbDHsV0735yFDbWk", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "4111111111111111", "authMethod": "PAN_ONLY" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "4111111111111111" } }Mastercard
The following is an example of a decrypted payload for non-tokenized Mastercard cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1650574585777", "messageId": "AH2Ejte23Sp0DBWqKVQ1d8ICVQialPGgXSsTT4NnCjNy3i-jdJg6B_wllO8590dFfrLg16GqGcuSrEPjl-sQZ-K8sKCL62ahwh5kzUv4ggLwioImJmuEuKfAiEQBRW0L8zlo0Nv6LFuk", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "5555555555554444", "authMethod": "PAN_ONLY" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "5555555555554444" } }American Express
The following is an example of a decrypted payload for non-tokenized Amex cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1650574857349", "messageId": "AH2EjtcmoURSXm2RhZ8ihnJrsty-7Ewm3NEnJDM-Atw9ewbIPvuarglows0vtaCV33b4z3PpM5RsMklbpe0aNPK5_BanGxmp_JSsOEtZYuf4m3cHTtKnxpQeonN07XDK-DUPKAaRwLfY", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "378282246310005", "authMethod": "PAN_ONLY" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "378282246310005" } }Discover
The following is an example of a decrypted payload for non-tokenized Discover cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1650574781399", "messageId": "AH2EjteSxPPpbJOXKXzG1Cqkh1kzJz0UP1AG4w75n9q7gCtWsawfRlqtUZofjIBnKlbozvASxKkkdbjv2-rOfNGd_st4kFqPeb6O3IE-fXeIcHzH8x56tMRylEnfnrF6x01ET8KdUeLS", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "6011111111111117", "authMethod": "PAN_ONLY" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "6011111111111117" } }JCB
The following is an example of a decrypted payload for non-tokenized JCB cards:
ECv2{ { "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1650574736277", "messageId": "AH2Ejtc88ZHJ-2aYBQWzHwvp6l0JsCHgxVt8s91A-ZUikaXNbcjsFm6gg9ExeVR-jzIyT-mJvA_ntvfRsDDOH2jnKMjdTtXIJvPt0NBUU45R7-gnjxkx-sI0ldcWvbDHsV0735yFDbWk", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "4111111111111111", "authMethod": "PAN_ONLY" } }ECv1
{ { "messageExpiration": "1507738377032", "paymentMethod": "CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "4111111111111111" } } } }Tokenized card
A tokenized card is a card that's added to Google Wallet.
The decrypted payload of a tokenized card depends on the type of card selected. The following three examples show decrypted payloads for different types of tokenized cards.
VisaThe following is an example of a decrypted payload for tokenized Visa cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1561533871082", "messageId": "AH2Ejtc8qBlP_MCAV0jJG7ErQKeDrkEUtQ0N3QRvPXWJc-jgC0VTfgmarDRZvTwuzirQPdUjkMkiQ7tnDidZbtlQTO-mAgMIdXRMuYedhZXnCcokmkJOOnE7jBn-pvkyBncOgpPWFFn3", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "4895370012003478", "authMethod": "CRYPTOGRAM_3DS", "eciIndicator": "07", "cryptogram": "AgAAAAAABk4DWZ4C28yUQAAAAAA=" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "TOKENIZED_CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "dpan": "4895370012003478", "expirationMonth": 12, "authMethod": "3DS", "3dsCryptogram": "AgAAAAAABk4DWZ4C28yUQAAAAAA=", "3dsEciIndicator": "07" } }American Express
The following is an example of a decrypted payload for tokenized American Express cards:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1561534208255", "messageId": "AH2Ejtf3Lp6LzjK6BswXBvVKZapBJNgMUbVHF_TORaVi7lV0tvRfzvApsZm-RAXF_szQq9qS_BwLTgZGrXvk0ZydZwUISo4x6dxojDoz0fl7loXwZ8JApFrQWU__ExxljKY4Y4mu2aQz", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "370295136149943", "authMethod": "CRYPTOGRAM_3DS", "cryptogram": "JnPYbs6FkC1tiVLREAABoAAAkgA=" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "TOKENIZED_CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "dpan": "370295136149943", "expirationMonth": 12, "authMethod": "3DS", "3dsCryptogram": "JnPYbs6FkC1tiVLREAABoAAAkgA=" } }All other networks
The following is an example of a decrypted payload for tokenized cards for all the other networks:
ECv2{ "gatewayMerchantId": "some-merchant-id", "messageExpiration": "1561534208255", "messageId": "AH2EjterqtEqlB9vQvy2kJEugwCDYtMzVtLrVH26Qd1RDFK_EFsFmPdpPOqcCIedXNpAc6sCM61GuYM_bgVl930tU8I0Ar0WUx87MIw36skUC-IT_APvbx4qRqw9Hfu2W-7zY6LMdgZ5", "paymentMethod": "CARD", "paymentMethodDetails": { "expirationYear": 2028, "expirationMonth": 12, "pan": "5204240250197840", "authMethod": "CRYPTOGRAM_3DS", "cryptogram": "ALnt+yWSJdXBACMLLWMNGgADFA==" } }ECv1
{ "messageExpiration": "1507738377032", "paymentMethod": "TOKENIZED_CARD", "messageId": "AH2EjtcHYs1Ye-ZIZuZXd7eNO4QjQfZjBDtP2ti0tob_a5o22lHmGWHsBVYrrSylkFC3ZTsRdvMadQpwOGCIl7XxhTKcfElmgF7UFbcI8CeUZCWRmbTH5s7h69Baqr4FAM735VNThPiP", "paymentMethodDetails": { "expirationYear": 2028, "dpan": "5204240250197840", "expirationMonth": 12, "authMethod": "3DS", "3dsCryptogram": "ALnt+yWSJdXBACMLLWMNGgADFA==" } }
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-08-14 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-08-14 UTC."],[[["This page provides instructions for generating sample tokens to test Google Pay integrations."],["Sample tokens, generated in `ENVIRONMENT_TEST` mode, utilize real cards for selection but return constant, non-sensitive payload data."],["Decrypted payloads for sample tokens vary based on card type (tokenized or non-tokenized) and network, providing examples for Visa, Mastercard, Amex, Discover, and others."],["Tokenized cards, those added to Google Wallet, have distinct payload structures compared to non-tokenized cards."],["Two protocol versions, ECv1 and ECv2, determine the structure of the decrypted payload; new integrations should use ECv2."]]],["To test token decryption, set `ENVIRONMENT_TEST` when creating a `PaymentsClient`. `loadPaymentData` then prompts users to select a card, but returns sample tokens instead of real card details. Ensure a chargeable card is linked to the Google Account and a payment method is added to the Google Pay app. Tokens are encrypted with your test key and signed with Google's test keys. Decrypted payloads differ based on card tokenization (Google Wallet) and network, with the payload for non-tokenized cards being constant.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4