Google Pay

Topics covered on this page

Enable Google Pay™ to allow your customers to make purchases using a credit or debit card connected with their Google Account. This guide walks you through the payment flow and steps to implement the service.

By using Google Pay, you agree to Google’s acceptable use policy and terms of service.

How to enable

  • Supported Countries: Thailand, Japan, Singapore, Malaysia
  • Minimum API version: 2017-11-02

To enable Google Pay, send an email requesting this feature to support@omise.co.

Payment flow

Google Pay supports payments on websites and Android devices. Customers who choose to make payments using Google Pay initiate the transaction by tapping or clicking on the Google Pay button that is embedded on your platform. Customers who have already linked a card to their Google Account will be able to choose their preferred card right away. Those who have not, will be given the option to link a new card.

Once the customer selects their preferred card and confirms the payment, the card will be charged the same way as the normal credit card payments flow. This means your account’s current card processing settings (for example, whether 3-D Secure is enabled) will also apply to Google Pay transactions.

Using a desktop browser

To start a Google Pay payment, the customer selects Google Pay as their preferred payment method during checkout on your website ❶. The customer then chooses their preferred credit or debit card ❷. Upon confirmation, Omise will send a webhook event (if enabled) indicating that the charge is complete ❸.

Desktop

Using a mobile application

To start a Google Pay payment, the customer selects Google Pay as their preferred payment method on your mobile application ❶. The customer then chooses their preferred credit or debit card ❷. The customer reviews and confirms the payment ❸. Omise will send a webhook event (if enabled) indicating that the charge is complete ❹.

Mobile

Implementation

Follow the Google Pay Brand guidelines (Web, Android) to add Google Pay payment buttons to your website or Android app. After the customer taps on the button and selects their card, you will receive a Google Pay token from Google, which contains the card information. You then send this type of token to our client-side libraries (Omise.js or the Android SDK) to obtain a card token that’s usable on our Charge API.

Omise treats Google Pay tokens the same way as sensitive card data. Therefore, unless you have a PCI-DSS license, these tokens must first be converted to card tokens before you can use them in your servers. Read more in Collecting Cards.

In summary, to create a charge with Google Pay, make the following API requests.

  1. Obtain a Google Pay token from Google when the user initiates payment through the Google Pay button.
  2. Create a card token from the Google Pay token using Omise.js or the Android SDK.
  3. Create a new charge using the obtained card token from Step 2.
  4. After receiving the charge completion webhook event, retrieve the charge to verify its status (optional, but recommended).

This sequence diagram below shows how to obtain the card token.

sequenceDiagram participant Customer participant Google participant Omise.js participant Merchant Customer ->> Google : Request payment via Google Pay button Google -->> Customer : Return Google Pay token Customer ->> Omise.js : Forward Google Pay token Omise.js ->> Merchant : Merchant gets card token

If you use the Omise pre-built payment form, a Google Pay button will be provided and a usable card token will be returned automatically. Use your secret key to create a charge with it on the server.

Obtaining a Google Pay token

Follow the Google Pay Web or Android developer documentation to render a Google Pay button and receive a Google Pay token. In the API request, ensure that the following fields follow the below guidelines.

  • Field allowedAuthMethods must only contain PAN_ONLY.
  • Field allowedCardNetworks should reflect the supported card brands from the Capability API.
  • Field gateway is set to omise.
  • Field gatewayMerchantId is your Omise public key.

After the request is sent, a new Google Pay token will be returned under the name token in the response.

Please make sure that your implementation also follows the Google Pay Web or Android brand guidelines.

Creating a card token

Once you receive a Google Pay token, create a new card token using the following tokenization parameters.

Name Type Description
method string (required) Set to googlepay string.
data string (required) Google Pay token. Refer to the token field in the PaymentMethodTokenizationData object.
billing_name string (optional, but recommended) Card owner name. Refer to the name field in the Address object.
billing_city string (optional, but recommended) Billing address city. Refer to the locality field in the Address object.
billing_country string (optional, but recommended) Billing address country as two-letter ISO 3166 code. Refer to the countryCode field in the Address object.
billing_postal_code string (optional, but recommended) Billing address postal code. Refer to the postalCode field in the Address object.
billing_state string (optional, but recommended) Billing address state. Refer to the administrativeArea field in the Address object.
billing_street1 string (optional, but recommended) Billing address street #1. Refer to the address1 field in the Address object.
billing_street2 string (optional) Billing address street #2. Refer to the address2 field in the Address object.
billing_phone_number string (optional) Billing address phone number. Refer to the phoneNumber field in the Address object.

By default, the cardholder's name and billing address won't be attached to a card token, and the name will be displayed as Google Pay for such case. To override this behavior, supply billing address parameters when requesting payment to Google. The billing information can be found in the Address object from the response.

For Omise.js, set the token input type to be tokenization at the first argument of the createToken function and submit the tokenization parameters at the second argument.

Omise.setPublicKey("your_omise_public_key");

tokenParameters = {
  method: 'googlepay',
  data: '{\"signature\":\"MEQCIA+wGZttxT13yz599zQjYugoz5kClNSmVa39vKv6ZOenAiARRtHQ0aYSrfd3oWhB\/ZtEeJs3ilT\/J0pYz1EWnzU2fw\\u003d\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEev+pVoUgtoS+y8Ecz3c72OFBD3d74XJOcnRxVmCV+2TJTW1g4d0UhDkhHeURhHQNvJPyBFHfYIUUj\/EYhYAzgQ\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1647856171825\\\"}\",\"signatures\":[\"MEYCIQClXfVcil7qaG2btVbyzf6x1\/MqCTbbJM\/tGN4iME4M9wIhANL53daWJHdDPpKxR3M\/Jis4WPVb093PW7fChj\/gCQUS\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"4JighTc0b1HhRQu+NgQN1XQWWOeB4YyR5cMFi8Vu3FeWHAjPtGs3LjrdpWhJhWekURzD6BZCbg1xakYvAMsahoTyUzDLtNpKmlglFpVjBSSYkPKFT6xovTKsWS7xC\/x9AvJsATtotwN8TTiP3+1dXtLLFClnCTkg9vEvChvXq0FwnrUOBtMiWukBY84R2rpzqNuZoh6gdvWHgPP6RczhtERg+kqKdd4\/UnKE8ElzOWYDmZoJvFhxU\/O97vHW1ohOe8ut94bxiPH6DB82Ec87Mu\/oArsGMpsnFVsWzIcLX+q+KayGRbKxPQzV726fO7GipG94KiF7YfCk1r+D+jkFR7x0ev6l+XRoTz+PKIlhrcn3DEYJudJAP\/Xh2kj\/csnLn4XdKV0aZ5Ua3IauA4fQl80pAo9foujiRGwagHHOfnp6iMjA\/CdG9SNQS3eUdsxtlJKPoK4rtv7cwISNQvoCWMv748YvV3f+LEOWf8couRgrxPCPbk1vO8TfNOgSAjULzRs+C1xy6\/j5aZU46PpomEClDWrujMAcDVqCnExTx2QE9IAb4n02V6UxWv8Dgqv5TsRKjPe7WSCO0+jRWAvs6wBBUbFPHvEe4do+rQ\\\\u003d\\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BGJhfH3jWMmZtIALmYr7fWxYSNSCFoAT9MCOcbCZdO3LmP6njpGk9LISmr+H1Wk9XUZuMvNQmMHE+yFzW\/sA5lg\\\\u003d\\\",\\\"tag\\\":\\\"d9a6aVaoIEQm+bTjd5M2HL7+OeIup0Jb6rM1CN7v3NQ\\\\u003d\\\"}\"}',

  // Add your billing information here (optional)
  billing_name: 'John Doe',
  billing_street1: '1600 Amphitheatre Parkway',
};

Omise.createToken('tokenization', tokenParameters, function(statusCode, response) {
  console.log(response)
});

If you are using the Android SDK, refer to the code snippet below. You can find a more detailed usage example in our GitHub repository.

private val client = Client("your_omise_public_key")

val tokenizationParam = TokenizationParam(
    method = "googlepay",
    data = "{\"signature\":\"MEQCIA+wGZttxT13yz599zQjYugoz5kClNSmVa39vKv6ZOenAiARRtHQ0aYSrfd3oWhB\/ZtEeJs3ilT\/J0pYz1EWnzU2fw\\u003d\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEev+pVoUgtoS+y8Ecz3c72OFBD3d74XJOcnRxVmCV+2TJTW1g4d0UhDkhHeURhHQNvJPyBFHfYIUUj\/EYhYAzgQ\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1647856171825\\\"}\",\"signatures\":[\"MEYCIQClXfVcil7qaG2btVbyzf6x1\/MqCTbbJM\/tGN4iME4M9wIhANL53daWJHdDPpKxR3M\/Jis4WPVb093PW7fChj\/gCQUS\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"4JighTc0b1HhRQu+NgQN1XQWWOeB4YyR5cMFi8Vu3FeWHAjPtGs3LjrdpWhJhWekURzD6BZCbg1xakYvAMsahoTyUzDLtNpKmlglFpVjBSSYkPKFT6xovTKsWS7xC\/x9AvJsATtotwN8TTiP3+1dXtLLFClnCTkg9vEvChvXq0FwnrUOBtMiWukBY84R2rpzqNuZoh6gdvWHgPP6RczhtERg+kqKdd4\/UnKE8ElzOWYDmZoJvFhxU\/O97vHW1ohOe8ut94bxiPH6DB82Ec87Mu\/oArsGMpsnFVsWzIcLX+q+KayGRbKxPQzV726fO7GipG94KiF7YfCk1r+D+jkFR7x0ev6l+XRoTz+PKIlhrcn3DEYJudJAP\/Xh2kj\/csnLn4XdKV0aZ5Ua3IauA4fQl80pAo9foujiRGwagHHOfnp6iMjA\/CdG9SNQS3eUdsxtlJKPoK4rtv7cwISNQvoCWMv748YvV3f+LEOWf8couRgrxPCPbk1vO8TfNOgSAjULzRs+C1xy6\/j5aZU46PpomEClDWrujMAcDVqCnExTx2QE9IAb4n02V6UxWv8Dgqv5TsRKjPe7WSCO0+jRWAvs6wBBUbFPHvEe4do+rQ\\\\u003d\\\\u003d\\\",\\\"ephemeralPublicKey\\\":\\\"BGJhfH3jWMmZtIALmYr7fWxYSNSCFoAT9MCOcbCZdO3LmP6njpGk9LISmr+H1Wk9XUZuMvNQmMHE+yFzW\/sA5lg\\\\u003d\\\",\\\"tag\\\":\\\"d9a6aVaoIEQm+bTjd5M2HL7+OeIup0Jb6rM1CN7v3NQ\\\\u003d\\\"}\"}",

    // Add your billing information here (optional)
    billing_name = "John Doe",
    billing_street1 = "1600 Amphitheatre Parkway"
)

val request = Token.CreateTokenRequestBuilder(tokenization = tokenizationParam).build()

client.send(request, object: RequestListener<Token>{
    override fun onRequestSucceed(model: Token) {
        // you created a token
    }

    override fun onRequestFailed(throwable: Throwable) {
        // something bad happened
    }
})

For testing, you can create the same request using curl. Please note that this example must only be used on test mode, as on live mode Google Pay tokens must be sent from the client side.

curl https://vault.omise.co/tokens \
  -u $OMISE_PUBLIC_KEY: \
  -d 'tokenization[method]=googlepay' \
  --data-urlencode 'tokenization[data]={"signature":"MEUCIQDY1e/dzFAZUkRXXjXBKFN1AeKDdtnspf3yHUaxNF0iLAIgbmAccscWk9KxyiJO/uSjdjBd3rUnDU4ow5hlhDgW0wM\u003d","intermediateSigningKey":{"signedKey":"{\"keyValue\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEa6knFzfre2if/qjHGrPXRJI4R0fa5gDiw53ZLQIF319MCV1ht0lyMl1jc8+MtPfoTENSicQap6Cs8Fl+83apfg\\u003d\\u003d\",\"keyExpiration\":\"1656417412574\"}","signatures":["MEUCIEWY90SXfDoRMVPs8YZy7u0t1B/UZ0WNP6Ibq/OyrbkzAiEAmvxPrtmkE6mEOGzkv39Cpn6OiwqMVwMv01adhafXJto\u003d"]},"protocolVersion":"ECv2","signedMessage":"{\"encryptedMessage\":\"VI+tGn08DwzYavfneViUCQ0hp59zS9lHmBEDhQEANhPOnka2PAvzyeNNLwmkLHF4fglKtQD70WJBfTbLG5PuFttnPXZN56pU/pnv8MgHdkdkzgeoT3fDWL8G00nQ8dM2lCRjS8lSgKrs0tdd5a0VbuH/OZ8TRaQ8LuaWtmXuwtVXTi7clCe3G977FPJmm1upq50wxS/q1W0Yr296J6pNfA4tQ3v5fWnJBwaypsn7fjqM5p4DK5X9Q2tmHQjSjL6VR8o/ojL9RxMZCrAl6X/ZodipD/0uQmtz7Q/T8VBdgZVa6pptGmmxdbLRa0EPXEJpiQpqlleibIzleQakpNcdLaauMCjlXhTobdCqCkvZ6oTlTmRQ3pddowUKeOMaqT5rGAOL9Z6XAbcw2/WCEC6DXPAPR9ba8C+W5iBjA6FcbRf2P0WvHM/2uPe7Dz+rj9tGaGt+E97eCXXiZ+PV9CELghpfZmqrkc58llBThDDLwN/2vBW1UYIWJQCyPSJttzdM3Cyc5CGBNXcQ+O9z7GUZXhLoyu4T7s+8hxlKYLJ++WhmWAJ1ybYywkBmcbdKmhYkoJ/D85qe4UqvpmA3Hhz6w9gNDQteRY/kQEd/ZQ\\u003d\\u003d\",\"ephemeralPublicKey\":\"BOxUCtd20nc4LxB2hUlFAGxo6rx9R2bP+5FRPuOhLLVhvAy5QyoSyku9JDXwsRh07u/EDQN8Hf7e/mtBrg7vaAs\\u003d\",\"tag\":\"5gC0Mw+mNmDInoIK+K1AIN+siXyyJp6afQjhUMK+5Io\\u003d\"}"}'
{
  "object": "token",
  "id": "tokn_test_5s7p3w9z0xhnily5g3j",
  "livemode": false,
  "location": "https://vault.omise.co/tokens/tokn_test_5s7p3w9z0xhnily5g3j",
  "used": false,
  "charge_status": "unknown",
  "card": {
    "object": "card",
    "id": "card_test_5s7p3w9ygewzs8yfliv",
    "livemode": false,
    "location": null,
    "deleted": false,
    "street1": null,
    "street2": null,
    "city": null,
    "state": null,
    "phone_number": null,
    "postal_code": null,
    "country": "us",
    "financing": "credit",
    "bank": "JPMORGAN CHASE BANK N.A.",
    "brand": "Visa",
    "fingerprint": "uHGUFYpH0GCcilfcEdJWQe/+j/FLNfXsZKeW5Xrydc4=",
    "first_digits": null,
    "last_digits": "1111",
    "name": "Google Pay",
    "expiration_month": 12,
    "expiration_year": 2027,
    "security_code_check": true,
    "tokenization_method": "googlepay",
    "created_at": "2022-06-21T02:32:10Z"
  },
  "created_at": "2022-06-21T02:32:10Z"
}

The id attribute is the token identifier (begins with tokn).

Creating a charge

Refer to Credit Card Payments to charge a card with the received card token. There are a couple of differences for card tokens that are generated from a specific tokenization method (googlepay) compared to normal ones:

  1. These card tokens have a field tokenization_method to tell what tokenization method was applied on the card.
  2. These card tokens cannot be used in the Customers API.

Additional options

When using a pre-built payment form, you can set additional configurations to have more control over the Google Pay API. The relevant parameters are described below.

Data Attribute Parameter Description
data-googlepay-merchant-id googlepayMerchantId Merchant ID for Google Pay (required when accepting live traffic).
data-googlepay-request-billing-address googlepayRequestBillingAddress Set to true to attach the cardholder's name and billing address to a card token. Supplying this improves your authorization rate for US, UK, and Candian cardholders.
data-googlepay-request-phone-number googlepayRequestPhoneNumber When the cardholder's billing address is requested, set to true to also attach the cardholder’s phone number to a card token.

The full list of the supported parameters can be found here.

Testing and going live

To complete the whole user journey, you need to have a Google Account and attach a chargeable card to it, or use one of the available test cards provided by Google. If your Google Pay environment is in test mode, the card number in Google Pay tokens will always be 4111 1111 1111 1111. You can charge this card with an Omise test key to simulate a successful charge.

In order to go live, you need a merchant ID which is used at the merchantId field in the Google Pay API. You can obtain this by registering with the Google Pay Business Console. Ensure that you also adhere to the Google Pay Web or Android integration checklist during launch preparation.

Omise uses cookies to improve your overall site experience and collect information on your visits and browsing behavior. By continuing to browse our website, you agree to our Privacy Policy. Learn more