Griner Docs

Google Pay

Show the Google Pay button in your own checkout and send the payment token to Griner.

In your own checkout, you show the Google Pay button yourself. Your customer either selects a card stored in their Google account or adds a new one. You pass the resulting payment token to Griner for processing. To show Google Pay on the hosted payment page instead, without any work with Google, see Apple Pay and Google Pay on the hosted payment page.

Google Pay terms

To accept Google Pay, you must follow the Google Pay APIs Acceptable Use Policy and accept the Google Pay API Terms of Service.

Before you begin

Authentication methods

Google Pay returns cards with one of two authentication methods. Both are always enabled; you can't turn either of them off.

MethodWhat it means
PAN_ONLYThe card is stored in your customer's Google account and isn't bound to a device, for example on desktop or on non-Android mobile web.
CRYPTOGRAM_3DSThe card is bound to an Android device. Issuers can delegate strong customer authentication to Google for later payments on that device. The payment comes with a cryptogram.

Choose a flow

You can process the payment token from Google in two ways:

FlowWho decrypts the Google Pay tokenWho manages the Google Pay keys
Encrypted payloadGrinerGriner
Decrypted payloadYouYou

Encrypted payload

You pass the encrypted payment token from Google to Griner. Griner decrypts it and stores the card in the vault.

With the activation of Google Pay, you receive the tokenization parameters to configure in your Google Pay payment request and the URL of the Google Pay token service. The examples below use it as $GOOGLE_PAY_TOKEN_URL.

StepEndpointWhat it does
1POST /v1/orders/Creates the order and the Google Pay transaction.
2POST {google_pay_token_url}/tokens/Decrypts the payment token and returns a vaultToken, cryptogram and ECI indicator.
3POST /pay/{order_id}/select-payment-method/google-pay/{transaction_id}/Executes the payment.

Create the order

Create an order with a google-pay transaction:

curl https://api.pay.griner.io/v1/orders/ \
  --user "$API_KEY:" \
  --header "Content-Type: application/json" \
  --data '{
    "currency": "EUR",
    "amount": 995,
    "merchant_order_id": "EXAMPLE001",
    "description": "Example Google Pay order",
    "return_url": "https://www.example.com/order/EXAMPLE001",
    "webhook_url": "https://www.example.com/webhook",
    "transactions": [
      {
        "payment_method": "google-pay"
      }
    ],
    "customer": {
      "merchant_customer_id": "123456789",
      "email_address": "user@example.com",
      "first_name": "John",
      "last_name": "Smith",
      "address_type": "billing",
      "address": "100 Main St",
      "postal_code": "SW1A 1AA",
      "city": "London",
      "country": "GB",
      "locale": "en",
      "phone_numbers": ["+441234567890"],
      "ip_address": "198.51.100.1"
    }
  }'

The response contains the IDs and the setup token you need in the next steps:

{
  "id": "6bf8a727-bef2-4420-8d41-af82f6f19f3d",
  "status": "new",
  "transactions": [
    {
      "id": "59f5866a-c216-472e-b803-8a4e83c4578a",
      "payment_method": "google-pay",
      "payment_method_details": {
        "setup_token": "c6d0a22b-df22-41a2-aac1-d647173ff219"
      },
      "status": "new"
    }
  ]
}

The response is shortened. Save the order id, the transaction id and the setup_token.

Depending on your acquirer, fields of the customer can be required. See Create an order in the API reference for the fields and their formats.

Store the payment details

Your customer selects a card in Google Pay. Google returns the payment token in paymentData.paymentMethodData.tokenizationData.token. Send it as a string, together with the setup token and transaction ID from step 1:

curl "$GOOGLE_PAY_TOKEN_URL/tokens/" \
  --header "Content-Type: application/json" \
  --data '{
    "googlePayMessage": "{\"signature\":\"MEUCIQDXc...03d\",\"protocolVersion\":\"ECv2\",\"signedMessage\":\"...\"}",
    "setupToken": "c6d0a22b-df22-41a2-aac1-d647173ff219",
    "transactionId": "59f5866a-c216-472e-b803-8a4e83c4578a"
  }'

For a test project connected to the Google Pay test environment, use $GOOGLE_PAY_TOKEN_URL/test/tokens/ instead.

{
  "vaultToken": "d972dc43-6a3d-4dcf-b54e-6e9a0fe325e3",
  "cryptogram": "AgAAAAAABk4DWZ4C28yUQAAAAAA=",
  "eciIndicator": "05"
}

cryptogram and eciIndicator can be empty. An empty cryptogram means the card was returned as PAN_ONLY, and the payment is processed as a regular card payment.

Execute the payment

Send the values from step 2 to the payment URL of the transaction, together with your customer's browser details:

curl https://api.pay.griner.io/pay/6bf8a727-bef2-4420-8d41-af82f6f19f3d/select-payment-method/google-pay/59f5866a-c216-472e-b803-8a4e83c4578a/ \
  --header "Content-Type: application/json" \
  --data '{
    "vaultToken": "d972dc43-6a3d-4dcf-b54e-6e9a0fe325e3",
    "cryptogram": "AgAAAAAABk4DWZ4C28yUQAAAAAA=",
    "eciIndicator": "05",
    "browser_info_screen_width": 1920,
    "browser_info_screen_height": 1080,
    "browser_info_color_depth": 24,
    "browser_info_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
    "browser_info_time_zone_offset": 0,
    "browser_info_language": "en-US",
    "browser_info_java_enabled": false
  }'
FieldDescription
vaultTokenThe vault token from step 2.
cryptogramThe cryptogram from step 2. Can be empty.
eciIndicatorThe ECI indicator from step 2. Can be empty.
browser_info_screen_widthScreen width of your customer's device, in pixels.
browser_info_screen_heightScreen height of your customer's device, in pixels.
browser_info_color_depthColor depth of the screen, in bits.
browser_info_user_agentUser agent of your customer's browser.
browser_info_time_zone_offsetTime zone offset of your customer's browser.
browser_info_languageLanguage of your customer's browser, such as en-US.
browser_info_java_enabledWhether Java is enabled in your customer's browser.
{
  "is_successful": true,
  "redirect_url": "https://api.pay.griner.io/pay/6bf8a727-bef2-4420-8d41-af82f6f19f3d/59f5866a-c216-472e-b803-8a4e83c4578a/completed/",
  "reason": "none"
}

Redirect your customer to the redirect_url. Then confirm the payment before you deliver.

Decrypted payload

You decrypt the payment token from Google yourself, with your own Google Pay keys, and store the card details in the Griner vault.

You handle card data

The decrypted payload contains the card number. Your systems must be PCI DSS compliant to process it. See Accept a card payment.

StepEndpointWhat it does
1POST /v1/orders/Creates the order and the Google Pay transaction.
2Google PayYour customer selects a card. You decrypt the payload.
3POST https://tokens.pay.griner.io/v1/cards/Stores the card details in the vault and returns a vault_token.
4POST /pay/{order_id}/select-payment-method/google-pay/{transaction_id}/Executes the payment.

Create the order

Create an order with a google-pay transaction, as in step 1 of the encrypted payload flow. Save the order id, the transaction id and the setup_token from payment_method_details.

Get the payment data from Google

Your customer taps the Google Pay button and selects a card. Google returns an encrypted payload. Decrypt it with your Google Pay keys, and take the card number (pan), expirationMonth and expirationYear from it, plus the cryptogram and eciIndicator when present.

Store the card details

Store the card in the vault with the setup_token from step 1. The expiry date uses the format MMYYYY:

curl https://tokens.pay.griner.io/v1/cards/ \
  --user "$API_KEY:" \
  --header "Content-Type: application/json" \
  --data '{
    "pan": "4871049999999910",
    "expiry": "122028",
    "setup_token": "c6d0a22b-df22-41a2-aac1-d647173ff219"
  }'
{
  "brand": "visa",
  "brands": ["visa"],
  "truncated_pan": "4871********9910",
  "vault_token": "d972dc43-6a3d-4dcf-b54e-6e9a0fe325e3"
}

The setup token can be used once, within 300 seconds after the order was created.

Send the payment

Send the vault_token from the vault as vaultToken, plus the cryptogram and ECI indicator from the decrypted payload when present, to the payment URL of the transaction. The request and response are the same as in step 3 of the encrypted payload flow.

Confirm the payment

Griner sends a webhook when the order status changes. Retrieve the order and deliver only when the order status is completed. See Confirm the payment.

Test your integration

Use Google's test environment: the Google Pay payment sheet then shows test cards instead of the real cards in your Google account. See Google's test card suite for how to set it up, and send the token to $GOOGLE_PAY_TOKEN_URL/test/tokens/.

Go live

  • Request production access for your website in the Google Pay & Wallet Console. Google checks your integration against its integration checklist.
  • Switch the Google Pay payment request to the production environment, and send the token to $GOOGLE_PAY_TOKEN_URL/tokens/.
  • Make sure Google Pay is active in your live project, and use its API key.
  • Set the webhook URL in your live project, or send a webhook_url with every order.

Then work through the go-live checklist.

Recurring payments

Google Pay supports recurring payments. See Recurring payments with Google Pay.