{"_id":"5c2fcddaa9e2fd0033c1193a","project":"57336fd5a6a9c40e00e13a0b","version":{"_id":"5beb278ac442ab0213f009cf","project":"57336fd5a6a9c40e00e13a0b","__v":1,"forked_from":"5bbf93937ef195000329c63e","createdAt":"2018-04-23T14:36:48.535Z","releaseDate":"2018-04-23T14:36:48.535Z","categories":["5beb278ac442ab0213f0098a","5beb278ac442ab0213f0098b","5beb278ac442ab0213f0098c","5beb278ac442ab0213f0098d","5beb278ac442ab0213f0098e","5beb278ac442ab0213f0098f","5beb278ac442ab0213f00990","5beb278ac442ab0213f00991","5c3f542c12c4ac004bc51718"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"3.28 Release","version_clean":"8976.0.0-Basics","version":"8976-Basics"},"category":{"_id":"5beb278ac442ab0213f00991","version":"5beb278ac442ab0213f009cf","project":"57336fd5a6a9c40e00e13a0b","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-03T20:45:01.593Z","from_sync":false,"order":7,"slug":"topics","title":"Guides"},"user":"5beb1b96bc2003003ecd645e","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2019-01-04T21:19:22.158Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":9,"body":"[Google Pay™](https://developers.google.com/pay/api/) is a simple, secure payment experience allowing shoppers make first time and recurring purchases with major credit cards (such as Mastercard, Visa, American Express, Discover) saved to their Google Account, including ones from Google Play, YouTube, Chrome, or an Android device.\n\nIn addition, as a BlueSnap merchant, you don't need BlueSnap to set up your activation with Google Pay, simply sign up for a Google Pay developer account and start using it!\n\nThis guide covers the following topics:\n1. [Benefits](#section-benefits)\n2. [Supported markets](#section-supported-markets)\n3. [Implementing Google Pay in your website](#section-implementing-google-pay-in-your-website)\n4. [Implementing Google Pay in your Android app](#section-implementing-google-pay-in-your-android-app)\n5. [Testing in Sandbox](#section-testing-in-sandbox)\n6. [Processing Transactions](#section-processing-transactions)\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important!\",\n  \"body\": \"Before you get begin development, review the following as applicable:\\n* [Set up a web interface](https://developers.google.com/pay/api/web/guides/setup)\\n* [Set up an Android app interface](https://developers.google.com/pay/api/android/guides/setup).\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Benefits\"\n}\n[/block]\n* **A better way to pay**: Google Pay is a faster, more secure way to pay on sites and in apps using payment methods saved to a Google Account.\n\n* **Availability**: Google Pay is accepted in millions of places around the world. It's available on Android, iOS, and desktop, and you can use it in multiple browsers, including Chrome, Firefox, and Safari.\n\n* **Increased conversions**: Google Pay delivers frictionless checkout by eliminating the need to type billing and shipping details, increasing conversions by giving shoppers a better way to pay.\n\n* **Increased security**: Google Pay protects your payment information with multiple layers of security, including card network tokenization.\n\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n<br />\n[block:api-header]\n{\n  \"title\": \"Supported markets\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important!\",\n  \"body\": \"By integrating Google Pay, you agree to Google’s terms & conditions. Access [this site](https://payments.developers.google.com/terms/sellertos) for details.\"\n}\n[/block]\n##Supported merchant countries\nMerchants domiciled in the following regions will be able to accept Google Pay: \n* Australia\n* Europe\n* United States (US)\n\n##Issuers supporting Google Pay\nShoppers whose issuing banks are located on [this list](https://pay.google.com/about/banks/) will be eligible to purchase with Google Pay; however, shoppers using *tokenized *cards (cards stored on their Android device) can only use them in a subset of countries and on compatible Android devices.\n\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n<br />\n[block:api-header]\n{\n  \"title\": \"Implementing Google Pay in your website\"\n}\n[/block]\nWhen shoppers use Google Pay in your website, they simply select an item(s) to purchase, select Google Pay as their payment method, and complete the transaction.\n\n##**The shopper experience with Google Pay on the web** \n>**The shopper clicks the Google Pay button on your checkout page.**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/34fdd8c-web_flow_1.png\",\n        \"web_flow_1.png\",\n        500,\n        301,\n        \"#e2e2e2\"\n      ]\n    }\n  ]\n}\n[/block]\n>**The Google Pay payment page opens on top of the checkout page.**\n>Here, the shopper can select their payment method, or add or change any of their billing and shipping information.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/827fabf-web_flow_2.png\",\n        \"web_flow_2.png\",\n        500,\n        307,\n        \"#868788\"\n      ]\n    }\n  ]\n}\n[/block]\n>**After the shopper reviews and confirms the order, the checkout page provides a confirmation message.**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9571eb1-web_flow_3.png\",\n        \"web_flow_3.png\",\n        500,\n        301,\n        \"#d8d9d9\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"Refer to the [Google Pay brand guidelines](https://developers.google.com/pay/api/web/guides/brand-guidelines) and their [integration checklist](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist) when referencing their brand within your website.\"\n}\n[/block]\n##Website Implementation overview\n\nFollow the [implementation instructions](https://developers.google.com/pay/api/web/guides/setup) within the [Tutorial](https://developers.google.com/pay/api/web/guides/tutorial) section, which include creating a Google account and obtaining production access.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Important!\",\n  \"body\": \"Within [Google’s tutorial](https://developers.google.com/pay/api/web/guides/tutorial#tokenization), under “Choose a payment tokenization method,” you must specify **BlueSnap **as your payment gateway and supply your **BlueSnap merchant ID**, as shown in the example below.\\n\\n**Remember:**\\nYour `gatewayMerchantId` is different for BlueSnap Sandbox and Production. \\nBe sure to use the *correct* merchant ID to avoid processing errors.\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"const tokenizationSpecification = {\\n  type: 'PAYMENT_GATEWAY',\\n  parameters: {\\n    'gateway': 'bluesnap',\\n    'gatewayMerchantId': '<yourBlueSnapMerchantId>'\\n  }\\n};\",\n      \"language\": \"javascript\",\n      \"name\": \"BlueSnap as your payment gateway\"\n    }\n  ]\n}\n[/block]\n###Step 1: Add the Google Pay payment button\nFollow the instructions [here](https://developers.google.com/pay/api/web/guides/tutorial#add-button) to add a Google Pay payment button.\n\n###Step 2: Create a Google Pay wallet token\nYou must package the response you received from Google Pay as a base-64 encrypted string by performing the following task.\n\nIn your `onActivityResult` method, the result from the Google-Pay popup displays similar to the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"const paymentsClient = getGooglePaymentsClient();\\n  paymentsClient.loadPaymentData(paymentDataRequest)\\n      .then(function(paymentData) {\\n        // handle the response\\n        processPayment(paymentData);\\n      })\\n      .catch(function(err) {\\n        // show error in developer console for debugging\\n        console.error(err);\\n      });\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nYour `processPayment` function is called, *if* your shopper successfully completed the Google Pay flow. Within it, make sure you encrypt the Google Pay payment data into a payment token, which you will use in the BlueSnap API calls. It should look similar to the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"function processPayment(paymentData) {\\n\\n  var paymentToken = b64EncodeUnicode(JSON.stringify(paymentData));\\n  \\n  // :::at:::todo pass paymentToken to your gateway to process payment\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"This `paymentToken` should be sent to the BlueSnap API, as detailed in the [Processing Transactions](#section-processing-transactions) section.\"\n}\n[/block]\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n<br />\n[block:api-header]\n{\n  \"title\": \"Implementing Google Pay in your Android app\"\n}\n[/block]\nImplement Google Pay in your Android app using BlueSnap's [Android SDK](doc:android-sdk) to let shoppers purchase physical items (such as groceries and clothing) or services (such as gym memberships and hotel reservations).\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"Your Android app must be approved by Google before it’s available in the Google Play store.\"\n}\n[/block]\nIf you use BlueSnap’s Android SDK for your checkout, you don’t need to do any coding — just register with Google and enable this payment method in the BlueSnap Console!\n\nIf you prefer not to use BlueSnap's Android SDK, you can implement Google Pay in your Android app by following [Google's instructions](https://developers.google.com/pay/api/android/guides/setup).\n\n##**The shopper experience with Google Pay in your app** \n\n>**The shopper clicks the Google Pay button on your checkout page.**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/aeb77fe-app_flow_1.png\",\n        \"app_flow_1.png\",\n        321,\n        681,\n        \"#1b2c26\"\n      ]\n    }\n  ]\n}\n[/block]\n<br />\n>**The Google Pay pop-up opens on top of the checkout page.**\n>Here, the shopper can select their payment method, or add or change any of their billing and shipping information.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/868c19d-app_flow_2.png\",\n        \"app_flow_2.png\",\n        321,\n        679,\n        \"#7b7b7b\"\n      ]\n    }\n  ]\n}\n[/block]\n<br />\n>**After the shopper reviews and confirms the order, the checkout page provides a confirmation message.**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9591a63-app_flow_3.png\",\n        \"app_flow_3.png\",\n        323,\n        686,\n        \"#e9e9e9\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"Refer to the [Google Pay brand guidelines](https://developers.google.com/pay/api/android/guides/brand-guidelines) and their [integration checklist](https://developers.google.com/pay/api/android/guides/test-and-deploy/integration-checklist) when referencing their brand within your Android app.\"\n}\n[/block]\n##Android App Implementation overview\n\nIf you decide to implement Google Pay in your Android app on your own (*without* using BlueSnap's Android SDK), follow the [implementation instructions](https://developers.google.com/pay/api/android/guides/setup) within the [Tutorial](https://developers.google.com/pay/api/android/guides/tutorial) section, which include creating a Google account and obtaining production access.\n\n###Step 1: Add the Google Pay payment button\nFollow the instructions [here](https://developers.google.com/pay/api/android/guides/setup) to add a Google Pay payment button to your app.\n\n###Step 2: Supply your BlueSnap merchant ID\nUse the following code to supply your merchant ID.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"private static JSONObject getTokenizationSpecification() {\\n  JSONObject tokenizationSpecification = new JSONObject();\\n  tokenizationSpecification.put(\\\"type\\\", \\\"PAYMENT_GATEWAY\\\");\\n  tokenizationSpecification.put(\\n      \\\"parameters\\\",\\n      new JSONObject()\\n          .put(\\\"gateway\\\", \\\"bluesnap\\\")\\n          .put(\\\"gatewayMerchantId\\\", \\\"yourBlueSnapMerchantId\\\"));\\n\\n  return tokenizationSpecification;\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"Your `gatewayMerchantId` is specific for BlueSnap Sandbox and Production. Be sure to use the *correct *merchant ID to avoid processing errors.\"\n}\n[/block]\n###Step 3: Create a Google Pay wallet token\nYou must package the response you received from Google Pay as a base-64 encrypted string by performing the following task.\n\nIn your `onActivityResult` method where you get the result from the Google-Pay popup, which displays similar to the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"switch (requestCode) {\\n    case GOOGLE_PAY_PAYMENT_DATA_REQUEST_CODE: {\\n        switch (resultCode) {\\n            case Activity.RESULT_OK:\\n                PaymentData paymentData = PaymentData.getFromIntent(data);\\n                handleGooglePaySuccess(paymentData);\\n                break;\\n            case Activity.RESULT_CANCELED:\\n                // Nothing to here normally - the user simply cancelled without selecting a\\n                // payment method.\\n                break;\\n            case AutoResolveHelper.RESULT_ERROR:\\n                Status status = AutoResolveHelper.getStatusFromIntent(data);\\n                handleGooglePayError(status.getStatusCode());\\n                break;\\n        }\\n…\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nYour `handleGooglePaySuccess` function will be called, *if *your shopper successfully completed the Google Pay flow. Within it, make sure you encrypt the Google Pay payment data into a payment token, which you will use in BlueSnap API calls. It should look similar to the following:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"String paymentToken = createBlsTokenFromGooglePayPaymentData(paymentData);\\n/**\\n\\t     * Creates a base64 encoded token with the PaymentData\\n\\t     */\\n\\t    public String createBlsTokenFromGooglePayPaymentData(PaymentData paymentData) throws Exception {\\n\\t\\n\\t        final CardInfo cardInfo = paymentData.getCardInfo();\\n\\t\\n\\t        JSONObject result = new JSONObject();\\n\\t\\n\\t        // paymentMethodData\\n\\t        JSONObject paymentMethodData = new JSONObject();\\t\\n\\n\\t        // paymentMethodData -> description: A payment method and method identifier suitable for communication to a shopper in a confirmation screen or purchase receipt.\\n\\t        final String description = cardInfo.getCardDescription();\\n\\t        if (description != null) {\\n\\t            paymentMethodData.put(\\\"description\\\", description);\\n\\t        }\\n\\t\\n\\t        // paymentMethodData -> tokenizationData\\n\\t        final PaymentMethodToken paymentMethodToken = paymentData.getPaymentMethodToken();\\n\\t        JSONObject tokenizationData = new JSONObject();\\n\\t        tokenizationData.put(\\\"type\\\", paymentMethodToken.getPaymentMethodTokenizationType());\\n\\t        tokenizationData.put(\\\"token\\\", paymentMethodToken.getToken());\\n\\t        paymentMethodData.put(\\\"tokenizationData\\\", tokenizationData);\\n\\t\\n\\t        // paymentMethodData -> info\\n\\t        JSONObject info = new JSONObject();\\n\\t        paymentMethodData.put(\\\"info\\\", info);\\n\\t\\n\\t        // paymentMethodData -> info -> cardNetwork\\n\\t        final String cardNetwork = cardInfo.getCardNetwork();\\n\\t        if (cardNetwork != null) {\\n\\t            info.put(\\\"cardNetwork\\\", cardNetwork);\\n\\t        }\\n\\t\\n\\t        // paymentMethodData -> info -> cardDetails\\n\\t        final String cardDetails = cardInfo.getCardDetails();\\n\\t        if (cardDetails != null) {\\n\\t            info.put(\\\"cardDetails\\\", cardDetails);\\n\\t        }\\n\\t\\n\\t        // paymentMethodData -> info -> cardClass (1-3 or 0, should somehow translate to DEBIT/CREDIT)\\n\\t        final int cardClassCode = cardInfo.getCardClass();\\n\\t        String cardClass = null;\\n\\t        if (cardClassCode == WalletConstants.CARD_CLASS_CREDIT) {\\n\\t            cardClass = \\\"CREDIT\\\";\\n\\t        } else if (cardClassCode == WalletConstants.CARD_CLASS_DEBIT) {\\n\\t            cardClass = \\\"DEBIT\\\";\\n\\t        } else if (cardClassCode == WalletConstants.CARD_CLASS_PREPAID) {\\n\\t            cardClass = \\\"PREPAID\\\";\\n\\t        }\\n\\t        if (cardClass != null) {\\n\\t            info.put(\\\"cardClass\\\", cardClass);\\n\\t        }\\n\\t        // paymentMethodData -> info -> billingAddress\\n\\t        final JSONObject billingAddressJson = getUserAddressAsJson(cardInfo.getBillingAddress());\\n\\t        if (billingAddressJson != null) {\\n\\t            info.put(\\\"billingAddress\\\", billingAddressJson);\\n\\t        }\\n\\t\\n\\t        result.put(\\\"paymentMethodData\\\", paymentMethodData);\\n\\t\\n\\t        // email\\n\\t        final String email = paymentData.getEmail();\\n\\t        if (email != null) {\\n\\t            result.put(\\\"email\\\", email);\\n\\t        }\\n\\t\\n\\t        // googleTransactionId - not sure this is the right place in the json for it\\n\\t        final String googleTransactionId = paymentData.getGoogleTransactionId();\\n\\t        if (googleTransactionId != null) {\\n\\t            result.put(\\\"googleTransactionId\\\", googleTransactionId);\\n\\t        }\\n\\t        // shippingAddress\\n\\t        final JSONObject shippingAddressJson = getUserAddressAsJson(paymentData.getShippingAddress());\\n\\t        if (shippingAddressJson != null) {\\n\\t            result.put(\\\"shippingAddress\\\", shippingAddressJson);\\n\\t        }\\n\\t\\n\\t        String tokenForBls = result.toString();\\n\\t        String encodedToken = Base64.encodeToString(tokenForBls.getBytes(), Base64.NO_WRAP | Base64.URL_SAFE);\\n\\t\\n\\t        return encodedToken;\\n\\t    }\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"This `paymentToken` should be sent to the BlueSnap API, which is detailed in the [Processing Transactions](#section-processing-transactions) section.\"\n}\n[/block]\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n<br />\n[block:api-header]\n{\n  \"title\": \"Testing in Sandbox\"\n}\n[/block]\nGoogle Pay does not provide test cards; however, you can use a “live” card within Google’s [test environment](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist). In a test environment, Google Pay returns a dummy token, which can't be charged.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Notes:\",\n  \"body\": \"* Sandbox supports Google Pay tokens produced by either setting (TEST or PRODUCTION), but BlueSnap's Production environment only supports PRODUCTION Google tokens.\\n* While the Google Pay API is available in many markets, *tokenized* cards are only available in a subset of countries and only on compatible Android devices. Refer to Google’s [integration guide](https://developers.google.com/pay/api/web/guides/test-and-deploy/integration-checklist) before testing tokenized cards.\"\n}\n[/block]\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n<br />\n[block:api-header]\n{\n  \"title\": \"Processing Transactions\"\n}\n[/block]\nThis section covers how to send the payment token data to BlueSnap to process the transaction using the Payment API (either JSON or XML).\n\n##Processing transactions with the Payment API\n\nYou can *validate *if the Google Pay payment method is activated by viewing this setting in the BlueSnap Merchant Console.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"Google Pay is *activated* by default.\"\n}\n[/block]\n###Step 1: Validate that the Google Pay payment method is activated \nIn the Merchant Console, access the **Methods of payment settings** box and check if the **Google Pay** option is set to **Show**:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/54f4007-GP_methods_of_payment_settings.png\",\n        \"GP_methods_of_payment_settings.png\",\n        698,\n        237,\n        \"#f6f6f6\"\n      ],\n      \"sizing\": \"smart\"\n    }\n  ]\n}\n[/block]\n###Step 2: Process transactions with the Payment API\nThe payment token data is sent in the Encoded Payment Token property in the request.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Note:\",\n  \"body\": \"The Google Pay token might result in a regular Credit Card or a Tokenized Card (when the card is inserted in the Google Pay app and shoppers use their mobile to do the purchase). The API requests are the same in either case, but the responses might vary.\"\n}\n[/block]\n**Scenario 1: Shopper is new** \nFor sales involving new shoppers, you **must** include the Encoded Payment Token property in an Auth Only, Auth Capture, or Create Subscription request.\n* `encodedPaymentToken` for JSON\n* `encoded-payment-token` for XML\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{\\n    \\\"cardTransactionType\\\": \\\"AUTH_CAPTURE\\\",\\n    \\\"recurringTransaction\\\": \\\"ECOMMERCE\\\",\\n    \\\"softDescriptor\\\": \\\"DescTest\\\",\\n    \\\"amount\\\": 11.00,\\n    \\\"currency\\\": \\\"USD\\\",\\n    \\\"wallet\\\": {\\n      \\\"walletType\\\": \\\"GOOGLE_PAY\\\",\\n      \\\"encodedPaymentToken\\\": \\\"ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd\\\"\\n    }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Auth Capture request with Google Pay wallet - JSON\"\n    },\n    {\n      \"code\": \"curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \\\\\\n-H 'Content-Type: application/xml' \\\\\\n-H 'Accept: application/xml' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n<card-transaction xmlns=\\\"http://ws.plimus.com\\\">\\n  <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n  <recurring-transaction>ECOMMERCE</recurring-transaction>\\n  <soft-descriptor>DescTest</soft-descriptor>\\n  <amount>11.00</amount>\\n  <currency>USD</currency>\\n  <wallet>\\n    <wallet-type>GOOGLE_PAY</wallet-type>\\n    <encoded-payment-token>ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd</encoded-payment-token>\\n  </wallet>\\n</card-transaction>\",\n      \"language\": \"xml\",\n      \"name\": \"Auth Capture request with Google Pay wallet - XML\"\n    }\n  ]\n}\n[/block]\n**Scenario 2: Shopper is returning** \nFor sales involving returning shoppers, you **must** include the shopper's Vaulted Shopper ID **and** Encoded Payment Token property in an Auth Only, Auth Capture, or Create Subscription request.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{\\n   \\\"cardTransactionType\\\": \\\"AUTH_CAPTURE\\\",\\n    \\\"recurringTransaction\\\": \\\"ECOMMERCE\\\",\\n    \\\"softDescriptor\\\": \\\"DescTest\\\",\\n    \\\"amount\\\": 11.00,\\n    \\\"currency\\\": \\\"USD\\\",\\n    \\\"vaultedShopperId\\\": 1234,\\n    \\\"wallet\\\": {\\n      \\\"walletType\\\": \\\"GOOGLE_PAY\\\",\\n      \\\"encodedPaymentToken\\\": \\\"ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd\\\"\\n    }\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Auth Capture request with vaulted shopper and Google Pay wallet - JSON\"\n    },\n    {\n      \"code\": \"curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \\\\\\n-H 'Content-Type: application/xml' \\\\\\n-H 'Accept: application/xml' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n<card-transaction xmlns=\\\"http://ws.plimus.com\\\">\\n  <card-transaction-type>AUTH_CAPTURE</card-transaction-type>\\n  <recurring-transaction>ECOMMERCE</recurring-transaction>\\n  <soft-descriptor>DescTest</soft-descriptor>\\n  <amount>11.00</amount>\\n  <currency>USD</currency>\\n  <vaulted-shopper-id>1234</vaulted-shopper-id>\\n  <wallet>\\n    <wallet-type>GOOGLE_PAY</wallet-type>\\n    <encoded-payment-token>ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd</encoded-payment-token>\\n  </wallet>\\n</card-transaction>\",\n      \"language\": \"xml\",\n      \"name\": \"Auth Capture request with vaulted shopper and Google Pay wallet - XML\"\n    }\n  ]\n}\n[/block]\n<br />\n**For more information on these, refer to the following:**\n* Auth Capture: [JSON](/v8976-JSON/docs/auth-capture) or [XML](/v8976-XML/docs/auth-capture)\n* Auth Only: [JSON](/v8976-JSON/docs/auth-only) or [XML](/v8976-XML/docs/auth-only)\n* Create Subscription: [JSON](/v8976-JSON/docs/create-subscription) or [XML](/v8976-XML/docs/create-subscription)\n[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"Working with subscriptions?\",\n  \"body\": \"Check out BlueSnap's Subscription guide: [ JSON](/v8976-JSON/docs/subscription-management) or [XML](/v8976-XML/docs/subscription-management)\"\n}\n[/block]\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>","excerpt":"Learn how to accept Google Pay in your website or Android app.\nIf you still have questions after reading this guide, check out our answers to [common questions](https://support.bluesnap.com/docs/faqs-mobile-wallets#section-google-pay).","slug":"google-pay","type":"basic","title":"Google Pay™"}

Google Pay™

Learn how to accept Google Pay in your website or Android app. If you still have questions after reading this guide, check out our answers to [common questions](https://support.bluesnap.com/docs/faqs-mobile-wallets#section-google-pay).

Google Pay™ is a simple, secure payment experience allowing shoppers make first time and recurring purchases with major credit cards (such as Mastercard, Visa, American Express, Discover) saved to their Google Account, including ones from Google Play, YouTube, Chrome, or an Android device.

In addition, as a BlueSnap merchant, you don't need BlueSnap to set up your activation with Google Pay, simply sign up for a Google Pay developer account and start using it!

This guide covers the following topics:

  1. Benefits
  2. Supported markets
  3. Implementing Google Pay in your website
  4. Implementing Google Pay in your Android app
  5. Testing in Sandbox
  6. Processing Transactions

Important!

Before you get begin development, review the following as applicable:

Benefits

  • A better way to pay: Google Pay is a faster, more secure way to pay on sites and in apps using payment methods saved to a Google Account.

  • Availability: Google Pay is accepted in millions of places around the world. It's available on Android, iOS, and desktop, and you can use it in multiple browsers, including Chrome, Firefox, and Safari.

  • Increased conversions: Google Pay delivers frictionless checkout by eliminating the need to type billing and shipping details, increasing conversions by giving shoppers a better way to pay.

  • Increased security: Google Pay protects your payment information with multiple layers of security, including card network tokenization.

Back to Top

Supported markets

Important!

By integrating Google Pay, you agree to Google’s terms & conditions. Access this site for details.

Supported merchant countries

Merchants domiciled in the following regions will be able to accept Google Pay:

  • Australia
  • Europe
  • United States (US)

Issuers supporting Google Pay

Shoppers whose issuing banks are located on this list will be eligible to purchase with Google Pay; however, shoppers using tokenized cards (cards stored on their Android device) can only use them in a subset of countries and on compatible Android devices.

Back to Top

Implementing Google Pay in your website

When shoppers use Google Pay in your website, they simply select an item(s) to purchase, select Google Pay as their payment method, and complete the transaction.

The shopper experience with Google Pay on the web

The shopper clicks the Google Pay button on your checkout page.

The Google Pay payment page opens on top of the checkout page.
Here, the shopper can select their payment method, or add or change any of their billing and shipping information.

After the shopper reviews and confirms the order, the checkout page provides a confirmation message.

Note:

Refer to the Google Pay brand guidelines and their integration checklist when referencing their brand within your website.

Website Implementation overview

Follow the implementation instructions within the Tutorial section, which include creating a Google account and obtaining production access.

Important!

Within Google’s tutorial, under “Choose a payment tokenization method,” you must specify BlueSnap as your payment gateway and supply your BlueSnap merchant ID, as shown in the example below.

Remember:
Your gatewayMerchantId is different for BlueSnap Sandbox and Production.
Be sure to use the correct merchant ID to avoid processing errors.

const tokenizationSpecification = {
  type: 'PAYMENT_GATEWAY',
  parameters: {
    'gateway': 'bluesnap',
    'gatewayMerchantId': '<yourBlueSnapMerchantId>'
  }
};

Step 1: Add the Google Pay payment button

Follow the instructions here to add a Google Pay payment button.

Step 2: Create a Google Pay wallet token

You must package the response you received from Google Pay as a base-64 encrypted string by performing the following task.

In your onActivityResult method, the result from the Google-Pay popup displays similar to the following:

const paymentsClient = getGooglePaymentsClient();
  paymentsClient.loadPaymentData(paymentDataRequest)
      .then(function(paymentData) {
        // handle the response
        processPayment(paymentData);
      })
      .catch(function(err) {
        // show error in developer console for debugging
        console.error(err);
      });

Your processPayment function is called, if your shopper successfully completed the Google Pay flow. Within it, make sure you encrypt the Google Pay payment data into a payment token, which you will use in the BlueSnap API calls. It should look similar to the following:

function processPayment(paymentData) {

  var paymentToken = b64EncodeUnicode(JSON.stringify(paymentData));
  
  // @todo pass paymentToken to your gateway to process payment
}

Note:

This paymentToken should be sent to the BlueSnap API, as detailed in the Processing Transactions section.

Implementing Google Pay in your Android app

Implement Google Pay in your Android app using BlueSnap's Android SDK to let shoppers purchase physical items (such as groceries and clothing) or services (such as gym memberships and hotel reservations).

Note:

Your Android app must be approved by Google before it’s available in the Google Play store.

If you use BlueSnap’s Android SDK for your checkout, you don’t need to do any coding — just register with Google and enable this payment method in the BlueSnap Console!

If you prefer not to use BlueSnap's Android SDK, you can implement Google Pay in your Android app by following Google's instructions.

The shopper experience with Google Pay in your app

The shopper clicks the Google Pay button on your checkout page.


The Google Pay pop-up opens on top of the checkout page.
Here, the shopper can select their payment method, or add or change any of their billing and shipping information.


After the shopper reviews and confirms the order, the checkout page provides a confirmation message.

Note:

Refer to the Google Pay brand guidelines and their integration checklist when referencing their brand within your Android app.

Android App Implementation overview

If you decide to implement Google Pay in your Android app on your own (without using BlueSnap's Android SDK), follow the implementation instructions within the Tutorial section, which include creating a Google account and obtaining production access.

Step 1: Add the Google Pay payment button

Follow the instructions here to add a Google Pay payment button to your app.

Step 2: Supply your BlueSnap merchant ID

Use the following code to supply your merchant ID.

private static JSONObject getTokenizationSpecification() {
  JSONObject tokenizationSpecification = new JSONObject();
  tokenizationSpecification.put("type", "PAYMENT_GATEWAY");
  tokenizationSpecification.put(
      "parameters",
      new JSONObject()
          .put("gateway", "bluesnap")
          .put("gatewayMerchantId", "yourBlueSnapMerchantId"));

  return tokenizationSpecification;
}

Note:

Your gatewayMerchantId is specific for BlueSnap Sandbox and Production. Be sure to use the correct merchant ID to avoid processing errors.

Step 3: Create a Google Pay wallet token

You must package the response you received from Google Pay as a base-64 encrypted string by performing the following task.

In your onActivityResult method where you get the result from the Google-Pay popup, which displays similar to the following:

switch (requestCode) {
    case GOOGLE_PAY_PAYMENT_DATA_REQUEST_CODE: {
        switch (resultCode) {
            case Activity.RESULT_OK:
                PaymentData paymentData = PaymentData.getFromIntent(data);
                handleGooglePaySuccess(paymentData);
                break;
            case Activity.RESULT_CANCELED:
                // Nothing to here normally - the user simply cancelled without selecting a
                // payment method.
                break;
            case AutoResolveHelper.RESULT_ERROR:
                Status status = AutoResolveHelper.getStatusFromIntent(data);
                handleGooglePayError(status.getStatusCode());
                break;
        }

Your handleGooglePaySuccess function will be called, if your shopper successfully completed the Google Pay flow. Within it, make sure you encrypt the Google Pay payment data into a payment token, which you will use in BlueSnap API calls. It should look similar to the following:

String paymentToken = createBlsTokenFromGooglePayPaymentData(paymentData);
/**
	     * Creates a base64 encoded token with the PaymentData
	     */
	    public String createBlsTokenFromGooglePayPaymentData(PaymentData paymentData) throws Exception {
	
	        final CardInfo cardInfo = paymentData.getCardInfo();
	
	        JSONObject result = new JSONObject();
	
	        // paymentMethodData
	        JSONObject paymentMethodData = new JSONObject();	

	        // paymentMethodData -> description: A payment method and method identifier suitable for communication to a shopper in a confirmation screen or purchase receipt.
	        final String description = cardInfo.getCardDescription();
	        if (description != null) {
	            paymentMethodData.put("description", description);
	        }
	
	        // paymentMethodData -> tokenizationData
	        final PaymentMethodToken paymentMethodToken = paymentData.getPaymentMethodToken();
	        JSONObject tokenizationData = new JSONObject();
	        tokenizationData.put("type", paymentMethodToken.getPaymentMethodTokenizationType());
	        tokenizationData.put("token", paymentMethodToken.getToken());
	        paymentMethodData.put("tokenizationData", tokenizationData);
	
	        // paymentMethodData -> info
	        JSONObject info = new JSONObject();
	        paymentMethodData.put("info", info);
	
	        // paymentMethodData -> info -> cardNetwork
	        final String cardNetwork = cardInfo.getCardNetwork();
	        if (cardNetwork != null) {
	            info.put("cardNetwork", cardNetwork);
	        }
	
	        // paymentMethodData -> info -> cardDetails
	        final String cardDetails = cardInfo.getCardDetails();
	        if (cardDetails != null) {
	            info.put("cardDetails", cardDetails);
	        }
	
	        // paymentMethodData -> info -> cardClass (1-3 or 0, should somehow translate to DEBIT/CREDIT)
	        final int cardClassCode = cardInfo.getCardClass();
	        String cardClass = null;
	        if (cardClassCode == WalletConstants.CARD_CLASS_CREDIT) {
	            cardClass = "CREDIT";
	        } else if (cardClassCode == WalletConstants.CARD_CLASS_DEBIT) {
	            cardClass = "DEBIT";
	        } else if (cardClassCode == WalletConstants.CARD_CLASS_PREPAID) {
	            cardClass = "PREPAID";
	        }
	        if (cardClass != null) {
	            info.put("cardClass", cardClass);
	        }
	        // paymentMethodData -> info -> billingAddress
	        final JSONObject billingAddressJson = getUserAddressAsJson(cardInfo.getBillingAddress());
	        if (billingAddressJson != null) {
	            info.put("billingAddress", billingAddressJson);
	        }
	
	        result.put("paymentMethodData", paymentMethodData);
	
	        // email
	        final String email = paymentData.getEmail();
	        if (email != null) {
	            result.put("email", email);
	        }
	
	        // googleTransactionId - not sure this is the right place in the json for it
	        final String googleTransactionId = paymentData.getGoogleTransactionId();
	        if (googleTransactionId != null) {
	            result.put("googleTransactionId", googleTransactionId);
	        }
	        // shippingAddress
	        final JSONObject shippingAddressJson = getUserAddressAsJson(paymentData.getShippingAddress());
	        if (shippingAddressJson != null) {
	            result.put("shippingAddress", shippingAddressJson);
	        }
	
	        String tokenForBls = result.toString();
	        String encodedToken = Base64.encodeToString(tokenForBls.getBytes(), Base64.NO_WRAP | Base64.URL_SAFE);
	
	        return encodedToken;
	    }

Note:

This paymentToken should be sent to the BlueSnap API, which is detailed in the Processing Transactions section.

Testing in Sandbox

Google Pay does not provide test cards; however, you can use a “live” card within Google’s test environment. In a test environment, Google Pay returns a dummy token, which can't be charged.

Notes:

  • Sandbox supports Google Pay tokens produced by either setting (TEST or PRODUCTION), but BlueSnap's Production environment only supports PRODUCTION Google tokens.
  • While the Google Pay API is available in many markets, tokenized cards are only available in a subset of countries and only on compatible Android devices. Refer to Google’s integration guide before testing tokenized cards.

Processing Transactions

This section covers how to send the payment token data to BlueSnap to process the transaction using the Payment API (either JSON or XML).

Processing transactions with the Payment API

You can validate if the Google Pay payment method is activated by viewing this setting in the BlueSnap Merchant Console.

Note:

Google Pay is activated by default.

Step 1: Validate that the Google Pay payment method is activated

In the Merchant Console, access the Methods of payment settings box and check if the Google Pay option is set to Show:

Step 2: Process transactions with the Payment API

The payment token data is sent in the Encoded Payment Token property in the request.

Note:

The Google Pay token might result in a regular Credit Card or a Tokenized Card (when the card is inserted in the Google Pay app and shoppers use their mobile to do the purchase). The API requests are the same in either case, but the responses might vary.

Scenario 1: Shopper is new
For sales involving new shoppers, you must include the Encoded Payment Token property in an Auth Only, Auth Capture, or Create Subscription request.

  • encodedPaymentToken for JSON
  • encoded-payment-token for XML
curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{
    "cardTransactionType": "AUTH_CAPTURE",
    "recurringTransaction": "ECOMMERCE",
    "softDescriptor": "DescTest",
    "amount": 11.00,
    "currency": "USD",
    "wallet": {
      "walletType": "GOOGLE_PAY",
      "encodedPaymentToken": "ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd"
    }
}
curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \
-H 'Content-Type: application/xml' \
-H 'Accept: application/xml' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
<card-transaction xmlns="http://ws.plimus.com">
  <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
  <recurring-transaction>ECOMMERCE</recurring-transaction>
  <soft-descriptor>DescTest</soft-descriptor>
  <amount>11.00</amount>
  <currency>USD</currency>
  <wallet>
    <wallet-type>GOOGLE_PAY</wallet-type>
    <encoded-payment-token>ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd</encoded-payment-token>
  </wallet>
</card-transaction>

Scenario 2: Shopper is returning
For sales involving returning shoppers, you must include the shopper's Vaulted Shopper ID and Encoded Payment Token property in an Auth Only, Auth Capture, or Create Subscription request.

curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{
   "cardTransactionType": "AUTH_CAPTURE",
    "recurringTransaction": "ECOMMERCE",
    "softDescriptor": "DescTest",
    "amount": 11.00,
    "currency": "USD",
    "vaultedShopperId": 1234,
    "wallet": {
      "walletType": "GOOGLE_PAY",
      "encodedPaymentToken": "ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd"
    }
}
curl -v -X POST https://sandbox.bluesnap.com/services/2/transactions \
-H 'Content-Type: application/xml' \
-H 'Accept: application/xml' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
<card-transaction xmlns="http://ws.plimus.com">
  <card-transaction-type>AUTH_CAPTURE</card-transaction-type>
  <recurring-transaction>ECOMMERCE</recurring-transaction>
  <soft-descriptor>DescTest</soft-descriptor>
  <amount>11.00</amount>
  <currency>USD</currency>
  <vaulted-shopper-id>1234</vaulted-shopper-id>
  <wallet>
    <wallet-type>GOOGLE_PAY</wallet-type>
    <encoded-payment-token>ImRhdGEiOiJuY1AvRitIUy8zeG5bXhCMFd</encoded-payment-token>
  </wallet>
</card-transaction>



For more information on these, refer to the following:

Working with subscriptions?

Check out BlueSnap's Subscription guide: JSON or XML