Using Google Pay

Google Pay is a service from Google that lets a user store sets of card details in their account and use them for purchases. These can be in-person purchases (with a suitable mobile device) or online purchases from a web browser.

Smart Router supports Google Pay as a payment option that you can offer to your customers.

Integrating with Google Pay

Google Pay uses a standard integration for web and mobile apps, but lets you choose from various payment gateways (including ProcessOut) when you generate the payment token. To get started, you must integrate Google Pay into your app and then use the instructions in the following sections of this page to enable payments with Smart Router.

Google provides extensive documentation about integrating Google Pay. A few useful entry points are listed below:

Android devices

Web

Smart Router specifics

As mentioned above, Google Pay lets you choose a payment gateway when you submit a request to tokenize a card. Set up the TokenizationSpecification object as follows:

"tokenizationSpecification": {
  "type": "PAYMENT_GATEWAY",
  "parameters": {
    "gateway": "processout",
    "gatewayMerchantId": "<your project ID (include the 'test-' prefix for sandbox mode transactions)>"
  }
}

Include this object as a field in your PaymentMethod object along with your choice of card parameters
as shown below. Note that Smart Router supports both the PAN_ONLY and CRYPTOGRAM_3DS authorization methods. Also, we do not restrict the choice of card networks because this is defined by the Payment Service Provider (PSP). You should contact your PSPs to find out which card networks they support.

{
  "type": "CARD",
  "parameters": {
    "allowedAuthMethods": [
      "PAN_ONLY",
      "CRYPTOGRAM_3DS"
    ],
    "allowedCardNetworks": [
      "AMEX",
      "DISCOVER",
      "JCB",
      "MASTERCARD",
      "VISA"
    ]
  },
  "tokenizationSpecification": {
    "type": "PAYMENT_GATEWAY",
    "parameters": {
      "gateway": "processout",
      "gatewayMerchantId": "<your project ID (include the 'test-' prefix for sandbox mode transactions)>"
    }
  }
}

See Google's tutorials for web and Android for more details about these objects and how they fit into the payment process.

Creating a ProcessOut card token using a Google Pay token

Google Pay returns a PaymentData object from a successful payment. For example:

{
  "apiVersion": 2,
  "apiVersionMinor": 0,
  "paymentMethodData": {
    "type": "CARD",
    "description": "Visa •••• 1234",
    "info": {
      "cardNetwork": "VISA",
      "cardDetails": "1234"
    },
    "tokenizationData": {
      "type": "PAYMENT_GATEWAY",
      "token": "<token that Smart Router uses>"
    }
  }
}

The paymentMethodData.tokenizationData.token field contains the actual JSON token that you need to process the payment. An example of the content is shown below. See Google's documentation about the payment method token structure to learn more about the meaning of the fields of the token object.

{
    "signature": "MEUCIQDi3Yy3uEf9EvOodY43dvlalWRp4t4kS/r3MJMFZZS09QIgS/3yLTSKjF+kmGJiXIKdfmaR8r8aaZEAcI4OlCySPs0=",
    "intermediateSigningKey": {
        "signedKey": "{\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEd0iHKh9XaxOKYFvGvrMHbXk3/Sig0ofeDBCiBmnu2Y5OvB2DU9Fyikd3sujtGm7WkfXbQ7rm5PLEr9jBXS7H2g\\u003d\\u003d\",\"keyExpiration\":\"1631090989783\"}",
        "signatures": [
            "MEYCIQCbTLYYpNmu/B2HVFuSHQ6kE/wa5g+eqTULpaRmc+2WGAIhAIQxFgxrgy3NAUXDVRv58wISpiyDrhQy8jx1HxtHWfpb"
        ]
    },
    "protocolVersion": "ECv2",
    "signedMessage": "{\"encryptedMessage\":\"sme1OeYeVwkc7lZfK1tT25KCrj1/pZDRXyCFvF9BCBXD6UQbP9+owMc1u7EIQ20j8i1uA2PIeivIxDfBkKMOgFdIyQliTuN4VO/x5r82gW0BOdRwwyWDL5TP+3HdGJ+hSMk/h1n6a1DmnNqjJKPe64Say4jlhOdY/X6k297Je9NO5eIsz/JBDfdl7KzNhARQsDFXaB03SrbtvEtOflQ9pWNDCuCKgDwL9cY5+OmqZrWW32F6N9RzeX9rpnq+p0t17n4F9ogstgQ52eh+El3BjR+78NimK2jLjFHHI5pWEpGlrshS+oQEgPS5tc4l2iES1IZIV2ZsfH7Gb1+ecBCgjhQyZQOw2fwB3jkVz5dOjASoYrTKRnJyNbWhIcjDmDSwzqq08JmX1KdShglZaCFYmIujKSV5Pa6ESUxrWuQU0T0FMzLEsOlJj1/muu2jEDVhBA4XVL3qmHHOQkU85cZU77JtbU1fMUypzPW6BGL5jQmGL5TDQa+5TDV0dHL8wLITRkbsa0VyLQtSLUSZ9A\\u003d\\u003d\",\"ephemeralPublicKey\":\"BBca3VePV8f6Y64YhTsuwsWo79EOKimbPnViqoHz+5WYR/1dtZu2kIMNsybNZlwnbi7n2keoVgEyh2vSRBEsW+o\\u003d\",\"tag\":\"PsKT9TGD6+f99dnnoZh0zTVge1U+s1cN1kn+g0cAUbc\\u003d\"}"
}

The following sections explain how to use this token in Android and web apps.

Android

Our Android SDK can create a standard ProcessOut card token from a Google Pay token. You can then use this to capture a payment or create a customer token. You must encode the JSON token as base64 data before using it to create a Card object. For example, the token above has the following base64 encoding:

eyJzaWduYXR1cmUiOiJNRVVDSVFEaTNZeTN1RWY5RXZPb2RZNDNkdmxhbFdScDR0NGtTL3IzTUpNRlpaUzA5UUlnUy8zeUxUU0tqRitrbUdKaVhJS2RmbWFSOHI4YWFaRUFjSTRPbEN5U1BzMFx1MDAzZCIsImludGVybWVkaWF0ZVNpZ25pbmdLZXkiOnsic2lnbmVkS2V5Ijoie1wia2V5VmFsdWVcIjpcIk1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRWQwaUhLaDlYYXhPS1lGdkd2ck1IYlhrMy9TaWcwb2ZlREJDaUJtbnUyWTVPdkIyRFU5Rnlpa2Qzc3VqdEdtN1drZlhiUTdybTVQTEVyOWpCWFM3SDJnXFx1MDAzZFxcdTAwM2RcIixcImtleUV4cGlyYXRpb25cIjpcIjE2MzEwOTA5ODk3ODNcIn0iLCJzaWduYXR1cmVzIjpbIk1FWUNJUUNiVExZWXBObXUvQjJIVkZ1U0hRNmtFL3dhNWcrZXFUVUxwYVJtYysyV0dBSWhBSVF4Rmd4cmd5M05BVVhEVlJ2NTh3SVNwaXlEcmhReThqeDFIeHRIV2ZwYiJdfSwicHJvdG9jb2xWZXJzaW9uIjoiRUN2MiIsInNpZ25lZE1lc3NhZ2UiOiJ7XCJlbmNyeXB0ZWRNZXNzYWdlXCI6XCJzbWUxT2VZZVZ3a2M3bFpmSzF0VDI1S0NyajEvcFpEUlh5Q0Z2RjlCQ0JYRDZVUWJQOStvd01jMXU3RUlRMjBqOGkxdUEyUEllaXZJeERmQmtLTU9nRmRJeVFsaVR1TjRWTy94NXI4MmdXMEJPZFJ3d3lXREw1VFArM0hkR0oraFNNay9oMW42YTFEbW5OcWpKS1BlNjRTYXk0amxoT2RZL1g2azI5N0plOU5PNWVJc3ovSkJEZmRsN0t6TmhBUlFzREZYYUIwM1NyYnR2RXRPZmxROXBXTkRDdUNLZ0R3TDljWTUrT21xWnJXVzMyRjZOOVJ6ZVg5cnBucStwMHQxN240RjlvZ3N0Z1E1MmVoK0VsM0JqUis3OE5pbUsyakxqRkhISTVwV0VwR2xyc2hTK29RRWdQUzV0YzRsMmlFUzFJWklWMlpzZkg3R2IxK2VjQkNnamhReVpRT3cyZndCM2prVno1ZE9qQVNvWXJUS1JuSnlOYldoSWNqRG1EU3d6cXEwOEptWDFLZFNoZ2xaYUNGWW1JdWpLU1Y1UGE2RVNVeHJXdVFVMFQwRk16TEVzT2xKajEvbXV1MmpFRFZoQkE0WFZMM3FtSEhPUWtVODVjWlU3N0p0YlUxZk1VeXB6UFc2QkdMNWpRbUdMNVREUWErNVREVjBkSEw4d0xJVFJrYnNhMFZ5TFF0U0xVU1o5QVxcdTAwM2RcXHUwMDNkXCIsXCJlcGhlbWVyYWxQdWJsaWNLZXlcIjpcIkJCY2EzVmVQVjhmNlk2NFloVHN1d3NXbzc5RU9LaW1iUG5WaXFvSHorNVdZUi8xZHRadTJrSU1Oc3liTlpsd25iaTduMmtlb1ZnRXloMnZTUkJFc1crb1xcdTAwM2RcIixcInRhZ1wiOlwiUHNLVDlUR0Q2K2Y5OWRubm9aaDB6VFZnZTFVK3MxY04xa24rZzBjQVViY1xcdTAwM2RcIn0ifQo=

The example code below generates a ProcessOut token from the base64 data. See the page about setting up your environment to learn how to obtain our Android SDK and import it into your code.

// You can optionally add the contact information of the cardholder
Contact contact = new Contact(address1, address2, city, state, countryCode, zip);

// First create a card object containing the Google Pay token details
Card card = new Card(Card.TokenType.googlepay, "base64encoded Google Pay token", cardHolderName, contact);

// And then send the card data to ProcessOut to tokenize
client.tokenize(card, new TokenCallback() {
    @Override
    public void onSuccess(String token) {
        // Send the card token to your backend for charging
    }

    @Override
    public void onError(Exception error) {
        Log.e("ProcessOut", error.toString());
    }
});

Web

Our web client library, processout.js, can also create a ProcessOut token from a Google Pay token, but you do not need to encode the data in base64 format as you do with Android apps.

Firstly, follow the setting up your environment for your web page to enable processout.js in your web page. Then, use code like the following to generate the payment token.

var client = new ProcessOut.ProcessOut("test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x");

var data = {
    // You can optionally send cardholder information.
    name: document.getElementById("cardholdername").value,
	contact: {
            zip: document.getElementById("cardholderzip").value,
            // Available contact fields:
            // address1, address2, city, state, country_code, zip
        },
};

// Note: payload is set to the Google Pay token received from the steps above
var payload = {
    "signature": "MEUCIQDi3Yy3uEf9EvOodY43dvlalWRp4t4kS/r3MJMFZZS09QIgS/3yLTSKjF+kmGJiXIKdfmaR8r8aaZEAcI4OlCySPs0\u003d",
    "intermediateSigningKey": {
        "signedKey": "{\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEd0iHKh9XaxOKYFvGvrMHbXk3/Sig0ofeDBCiBmnu2Y5OvB2DU9Fyikd3sujtGm7WkfXbQ7rm5PLEr9jBXS7H2g\\u003d\\u003d\",\"keyExpiration\":\"1631090989783\"}",
        "signatures": ["MEYCIQCbTLYYpNmu/B2HVFuSHQ6kE/wa5g+eqTULpaRmc+2WGAIhAIQxFgxrgy3NAUXDVRv58wISpiyDrhQy8jx1HxtHWfpb"]
    },
    "protocolVersion": "ECv2",
    "signedMessage": "{\"encryptedMessage\":\"sme1OeYeVwkc7lZfK1tT25KCrj1/pZDRXyCFvF9BCBXD6UQbP9+owMc1u7EIQ20j8i1uA2PIeivIxDfBkKMOgFdIyQliTuN4VO/x5r82gW0BOdRwwyWDL5TP+3HdGJ+hSMk/h1n6a1DmnNqjJKPe64Say4jlhOdY/X6k297Je9NO5eIsz/JBDfdl7KzNhARQsDFXaB03SrbtvEtOflQ9pWNDCuCKgDwL9cY5+OmqZrWW32F6N9RzeX9rpnq+p0t17n4F9ogstgQ52eh+El3BjR+78NimK2jLjFHHI5pWEpGlrshS+oQEgPS5tc4l2iES1IZIV2ZsfH7Gb1+ecBCgjhQyZQOw2fwB3jkVz5dOjASoYrTKRnJyNbWhIcjDmDSwzqq08JmX1KdShglZaCFYmIujKSV5Pa6ESUxrWuQU0T0FMzLEsOlJj1/muu2jEDVhBA4XVL3qmHHOQkU85cZU77JtbU1fMUypzPW6BGL5jQmGL5TDQa+5TDV0dHL8wLITRkbsa0VyLQtSLUSZ9A\\u003d\\u003d\",\"ephemeralPublicKey\":\"BBca3VePV8f6Y64YhTsuwsWo79EOKimbPnViqoHz+5WYR/1dtZu2kIMNsybNZlwnbi7n2keoVgEyh2vSRBEsW+o\\u003d\",\"tag\":\"PsKT9TGD6+f99dnnoZh0zTVge1U+s1cN1kn+g0cAUbc\\u003d\"}"
};

var token = new ProcessOut.PaymentToken(ProcessOut.TokenType.GooglePay, payload)

client.tokenize(token, data,
    function(token) {
        document.getElementById("success").innerHTML = "Success! Your created card token is " + token;
    },
    function(err) {
        document.getElementById("errors").innerHTML = err.message;
    });

Using the token

You can use the token for payment or to create a customer token. We generally recommend that you authorize the paymentfrom the client to comply with Strong Customer Authentication (SCA) rules. However, you do not need to do this if you restricted the allowedAuthMethods to just CRYPTOGRAM_3DS in the card parameters, as described above.