Google Pay

Google Pay is an e-wallet that allows shoppers to make payments in e-commerce stores and apps using their credit and debit cards stored in their Google Accounts and Android devices in a safe and easy way.

Prerequisites

In order to use Google Pay, your store must be previously registered and integrated with Google Pay. In addition to that, you must also:

  1. Agree to Google’s terms of service;
  2. Follow the steps in this documentation to throughly integrate Google Pay into your app;
  3. Hire API E-commerce Cielo;
  4. Hire Cielo 3.0 as the acquirer;
  5. Integrate with API E-commerce Cielo.

PART 1: Integrating Google Pay

In this initial step, must set up your project and implement Google Pay in your Android application.

Step 1 - Configure your Project

To set up your project, follow the instructions described in the Google Pay Setup Guide.

In this step, you must add dependencies either by importing the library from Google Play Services or choosing the APIs you want to compile. And then, to enable Google Pay in your Android application, you will have to modify the "AndroidManifest.xml" file of your project according to the instructions given on the page.

Step 2 - Implement Google Pay

To integrate Google Play into your app, follow all the steps described in the Google Pay Tutorial Guide.

For the correct integration of Google Pay via Cielo, it is necessary to pay attention to the points below:

Gateway Definition

In step "Step 2: Request a payment token for your payment provider", follow the model indicated as "GATEWAY" and assign the value "PAYMENT_GATEWAY" to the type parameter and the value "cielo" to the gateway parameter, according to the given example:

private static JSONObject getTokenizationSpecification() {
  JSONObject tokenizationSpecification = new JSONObject();
  tokenizationSpecification.put("type", "PAYMENT_GATEWAY");
  tokenizationSpecification.put(
      "parameters",
      new JSONObject()
          .put("gateway", "cielo")
          .put("gatewayMerchantId", "exampleMerchantId"));
  return tokenizationSpecification;
}

Fill in the gatewayMerchantId parameter with your store's identifier, generated by the gateway. The store identifier follows the format "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" (type GUID / size 36).

Card brands definition

In "Step 3: Define supported payment card networks", configure according to the flags accepted by the wallet.

Environment definition

In "Step 5: Create a PaymentsClient instance", use the value "WalletConstants.ENVIRONMENT_TEST" for the test environment.

Shopping Data definition

In "Step 7: Create a PaymentDataRequest object", use the "BRL" value for the currencyCode parameter. The merchantName field is the name that the shopper will see throughout the Google Pay payment process. Thus, the use of a recognizable friendly name is recommended.

Payment data recovery

In "Step 9: Handle the response object", the Activity.RESULT_OK event is described, in which an object is returned with all the payment data, including payment tokens.

From the PaymentData, the PaymentMethodToken object is obtained, by calling the getPaymentMethodToken() method. Click here for more information.

Next, you must get the string that contains payment tokens from the GetToken() method of the PaymentMethodToken object. Click here for more information.

The string obtained in the previous step has a structure like the one shown below. Click here for more information.

{
  "protocolVersion": "ECv1",
  "signature": "TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
  "signedMessage": "{\"encryptedMessage\":
  \"ZW5jcnlwdGVkTWVzc2FnZQ==\",\"ephemeralPublicKey\":
  \"ZXBoZW1lcmFsUHVibGljS2V5\",\"tag\": \"c2lnbmF0dXJl\"}"
}
ParameterTypeDescription
signedMessagestringSigned message.
signaturestringMessage signature.

Save the signedMessage and signature data, which will be required for authorization via the API E-commerce Cielo in STEP 2, described below.

PART 2: Authorization with Token

Authorization with the Google Pay token happens in the same way as standard credit card authorization. However, instead of providing card details openly, the token received by Google Pay must be provided, as shown in the example:

⚠️

The following integration should be used when sending encrypted card data. If the merchant sends the authorization request with decrypted card data, please refer to Decrypted card .

Request

{
  "MerchantOrderId": "2014111708",
  "Customer": {
    (…)
  },
  "Payment": {
    "Type": "CreditCard",
    "Amount": 100,
    "Installments": 1,
    "Wallet": {
      "Type": "AndroidPay",
      "WalletKey": "{\"encryptedMessage\": \"ZW5jcnlwdGVkTWVzc2FnZQ==\",\"ephemeralPublicKey\": \"ZXBoZW1lcmFsUHVibGljS2V5\",\"tag\": \"c2lnbmF0dXJl\"}",
      "AdditionalData": {
        "Signature": "ZXBoZW1lcmFsUHVibGljS2V5"
      }
    }
  }
}
Header ParametersDescriptionType and Size
MerchantIdStore identifier at Cielo 3.0. For the Sandbox environment, use 63D6ACCB-2734-4236-AB5D-843A9DAC44C7.GUID (36)
MerchantKeyAPI key for Cielo 3.0. For the Sandbox environment, use ZCVHDJWKTGOZXADDYJFURIDIKHEMRYQAQDYEJMQK.String (24)
ParametersDescriptionType and size
MerchantOrderIdOrder identification number.String (50)
CustomerNode with the shopper's data.Refer to API E-commerce Cielo.
Payment.TypePayment method type. Possible values: "CreditCard" / "DebitCard".String (100)
Payment.AmountTransaction amount in cents.Number (15)
Payment.InstallmentsNumber of installments.Number (2)
Payment.Wallet.Typeallet provider name. For Google Pay, use "AndroidPay".String (15)
Payment.Wallet.WalletKeyProvide the signedMessage received from Google Pay.String
Payment.Wallet.AdditionalData.SignatureProvide the signature received from Google Pay.String

The wallet authorization response will have the same fields presented in Create an e-wallet payment using encrypted card, however with the addition of the Payment.Wallet node repeating the same fields used in the authorization, as described above.

PART 3: Production Data Request

In order to complete the process, first validate the steps performed in PARTS 1 and 2. Then, request your access credentials for deployment.

Step 1 - Branding Guideline

Verify whether the branding guidelines have been thoroughly followed.

Step 2 - Checklist and Credentials Request

Check that all items in the integration checklist have been attended. After everything is validated, request your access credentials for the production environment.