Paytrim

Google Pay

Accept Google Pay on the Paytrim 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 pagePaytrim 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 Paytrim.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.pay.paytrim.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 Paytrim 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.

Paytrim decrypts the payment token from Google with its own Google Pay keys. The card number never reaches your systems.

Encrypted payload

You pass the encrypted payment token from Google to Paytrim. Paytrim 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.pay.paytrim.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.pay.paytrim.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.

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