Tokenizing Google Pay

To tokenize a Google Pay™ instrument and use it to make a payment or store it in the customer's Wpay wallet, we will first need to set up your merchant profile. To tokenize a customer's Google Pay instrument you can make use of our APIs.

High-level flow

2803

How it works

  1. Integrate your app or websites with Google Pay to facilitate the checkout journey and allow a customer to select an instrument stored in their Google Pay account and approve the payment.
  2. Once the payment has been approved, Google Pay will provide you with a payment token data payload which can then be sent to Wpay for payments.
  3. The Google Pay token data is decrypted and processed by us. We then return a Wpay PaymentToken which is a unique representation of the Google Pay instrument without any sensitive information.
  4. The Wpay PaymentToken can be used in our payments services to make a payment.

Tokenizing Google Pay

This method should be used to tokenize Google Pay payment token data. The same API can be used for registered and guest customers.

curl --location --request POST 'https://{{environment}}.wpay.com.au/v1/apm/tokenize' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: {{yourApiKey}}' \
--header 'Authorization: Bearer {{yourBearerToken}}' \
--data-raw '{
    "data": {
        "paymentInstrumentType": "GOOGLEPAY",
        "payload": {
            "instrumentType": "AMEX",
            "comment": "AMEX-5232",
            "tokenData": "{\"protocolVersion\":\"ECv2\",\"signature\":\"MEQ**********==\",\"intermediateSigningKey\":{\"signatures\":[\"MEQ**********==\"],\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKo*********\\\",\\\"keyExpiration\\\":\\\"1661308725000\\\"}\"},\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"o7raQeRaPE8**********\\\",\\\"ephemeralPublicKey\\\":\\\"BMEuZ******\\\",\\\"tag\\\":\\\"kfFQwoP5evL**********\\\"}\"}"
        }
    },
    "meta": {}
}'
var myHeaders = new Headers();
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY";
var accessToken = "ACCESS-TOKEN";
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-Api-Key", yourAPIkey);
myHeaders.append("Authorization", `Bearer ${accessToken}`);

var raw = JSON.stringify({
  "data": {
        "paymentInstrumentType": "GOOGLEPAY",
        "payload": {
            "instrumentType": "AMEX",
            "comment": "AMEX-5232",
            "tokenData": "{\"protocolVersion\":\"ECv2\",\"signature\":\"MEQ**********==\",\"intermediateSigningKey\":{\"signatures\":[\"MEQ**********==\"],\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKo*********\\\",\\\"keyExpiration\\\":\\\"1661308725000\\\"}\"},\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"o7raQeRaPE8**********\\\",\\\"ephemeralPublicKey\\\":\\\"BMEuZ******\\\",\\\"tag\\\":\\\"kfFQwoP5evL**********\\\"}\"}"
        }
    },
    "meta": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch(`https://${environment}.wpay.com.au/wow/v1/pay/googlepay/tokenize`, requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

var semaphore = DispatchSemaphore (value: 0)

let yourAPIkey = "YOUR-API-KEY";
let environment = "substitute environment-value here"
let accessToken = "ACCESS-TOKEN";
let parameters = """
{\
	\"data\": {\
		\"paymentInstrumentType\": \"GOOGLEPAY\",\
		\"payload\": {\
	      \"instrumentType\": \"AMEX\",\
        \"comment\": \"AMEX-5232\",\
        \"tokenData\": \"{\"protocolVersion\":\"ECv2\",\"signature\":\"MEQCIBec51ti5KFs==\",\"intermediateSigningKey\":{\"signatures\":[\"MEUCIEvA6rkOlThv=\"],\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYI\\\",\\\"keyExpiration\\\":\\\"1661308725000\\\"}\"},\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"o7raQeRaPE8NxOQuZPro6u\\\",\\\"ephemeralPublicKey\\\":\\\"BMEuZ4HsiNh\\\",\\\"tag\\\":\\\"kfFQwoP5evLtDoh5fTq\\\"}\"}"
		}\
	},\
	\"meta\": {}\
}\
"""
let postData = parameters.data(using: .utf8)

var request = URLRequest(
  url: URL(string: "https://\(environment).wpay.com.au/wow/v1/pay/googlepay/tokenize")!,
  timeoutInterval: Double.infinity
)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue(yourAPIkey, forHTTPHeaderField: "X-Api-Key")
request.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    semaphore.signal()
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
var myHeaders = new Headers()
var environment = "substitute environment-value here"
var yourAPIkey = "YOUR-API-KEY"
var accessToken = "ACCESS-TOKEN"
      
val response = khttp.post(
  url = "https://$environment" + 
        ".wpay.com.au/wow/v1/pay/googlepay/tokenize",
  headers = mapOf("Content-Type" to "application/json",
                  "X-Api-Key" to yourAPIkey,
                  "Authorization", "Bearer $accessToken"),
  json = mapOf("data" to mapOf (
                "paymentInstrumentType" to "GOOGLEPAY",
                "payload" to mapOf (
                    "instrumentType" to "AMEX",
               			"comment" to "AMEX-5232",
                		"tokenData" to "{\"protocolVersion\":\"ECv2\",\"signature\":\"MEQCIBec51ti5KFs==\",\"intermediateSigningKey\":{\"signatures\":[\"MEUCIEvA6rkOlThv=\"],\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYI\\\",\\\"keyExpiration\\\":\\\"1661308725000\\\"}\"},\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"o7raQeRaPE8NxOQuZPro6u\\\",\\\"ephemeralPublicKey\\\":\\\"BMEuZ4HsiNh\\\",\\\"tag\\\":\\\"kfFQwoP5evLtDoh5fTq\\\"}\"}"
                   )
              ),
               "meta" to mapOf ()
        )
)

if(response.statusCode == 200) {
  val obj : JSONObject = response.jsonObject
  println("Successful response payload: ${obj}")
} else {
  handleError(response)
}

Where:

  • paymentInstrumentType should be set to GOOGLEPAY for Google Pay tokenization
  • instrumentType is the payment network of the card selected.
  • comment is the display name of the card selected, generally, this is the payment network followed by the last 4 digits of the selected card.
  • tokenData is the JSON Escaped token data returned by Google Pay upon successfully authenticating the payment.