Ginger Payments

Google Pay

Accept Google Pay on the Ginger Payments hosted payment page, or in your own checkout.

With Google Pay, your customers pay with a card stored in their Google account. They don't enter card details. Google Pay works on mobile phones and computers, in most browsers and operating systems.

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.

You can accept Google Pay in two ways:

IntegrationHow it worksGoogle registration
Hosted payment pageGinger Payments shows the Google Pay button on the hosted payment page.Not needed
Server-to-serverYou show the Google Pay button in your own checkout and send the payment token to Ginger Payments.Needed: you integrate with the Google Pay API

Hosted payment page

On the hosted payment page, you don't need to register with Google. Once Google Pay is active in your project, it appears on the hosted payment page along with your other payment methods. To send your customer straight to Google Pay, create the order with google-pay as the payment method:

curl https://api.dev.gingerpayments.com/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"
    }
  }'

Redirect your customer to the payment_url of the transaction in the response. Then handle the result as for any other payment: wait for the webhook and check the order status.

Server-to-server

With a server-to-server integration, you show the Google Pay button in your own checkout. Your customer either selects a card stored in their Google account or adds a new one. You pass the resulting payment token to Ginger Payments for processing.

Before you start, read Google's documentation and make sure your integration follows it:

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 payloadGinger PaymentsGinger Payments
Decrypted payloadYouYou

Encrypted payload

You pass the encrypted payment token from Google to Ginger Payments. Ginger Payments 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, as in the hosted payment page example. 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.

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.dev.gingerpayments.com/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.dev.gingerpayments.com/pay/6bf8a727-bef2-4420-8d41-af82f6f19f3d/59f5866a-c216-472e-b803-8a4e83c4578a/completed/",
  "reason": "none"
}

Redirect your customer to the redirect_url. Then wait for the webhook and check the order status 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 Ginger Payments vault.

You handle card data

The decrypted payload contains the card number. Your systems must be PCI DSS compliant to process it. See Server-to-server.

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.dev.gingerpayments.com/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 the hosted payment page example. 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.dev.gingerpayments.com/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.

Execute 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.

Customer details

Send the customer object with every Google Pay order. Depending on your acquirer, these fields can be required:

FieldDescription
merchant_customer_idYour own customer reference.
email_addressYour customer's email address.
first_name1 to 120 characters. Pattern: ^[\w -,\.À-ÖØ-öø-ÿ]+$
last_name1 to 120 characters. Pattern: ^[\w -,\.À-ÖØ-öø-ÿ]+$
address_typeAlways billing.
addressBilling address, 1 to 120 characters. Pattern: ^[\w -,\.\-À-ÖØ-öø-ÿ]+$
postal_code1 to 10 characters. Pattern: ^[A-Z0-9]+( [A-Z0-9]*)?$
city1 to 120 characters. Pattern: ^[\w -,\.\-À-ÖØ-öø-ÿ]+$
countryISO 3166-1 alpha-2 country code, such as GB.
phone_numbersList of phone numbers, including the country code.

Recurring payments

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

On this page