Google Pay
Set up recurring payments with Google Pay, on the hosted payment page or in a server-to-server integration.
Google Pay supports recurring payments that you start without your customer: merchant-initiated transactions. The flow is the same as for recurring card payments, with payment_method set to google-pay.
The first transaction can use either Google Pay authorization method:
| Authorization method | What your customer pays with |
|---|---|
PAN_ONLY | A card stored in their Google account. |
CRYPTOGRAM_3DS | A tokenized card on an Android device. |
Before you start, make sure Google Pay works for regular payments. See Google Pay.
Hosted payment page
Create the first transaction
Create an order with a google-pay transaction and set recurring_type to first:
curl https://api.pay.paytrim.com/v1/orders/ \
--user "$API_KEY:" \
--header "Content-Type: application/json" \
--data '{
"merchant_order_id": "GP-SUB-001",
"amount": 1295,
"currency": "EUR",
"description": "Subscription setup with Google Pay",
"return_url": "https://www.example.com/return",
"transactions": [
{
"payment_method": "google-pay",
"payment_method_details": {
"recurring_type": "first"
}
}
],
"customer": {
"merchant_customer_id": "CUST-ABCDE",
"email_address": "jane.doe@example.com",
"first_name": "Jane",
"last_name": "Doe",
"address_type": "billing",
"address": "123 Abbey Road",
"postal_code": "NW8 9AY",
"country": "GB",
"city": "London",
"ip_address": "203.0.113.10"
}
}'Redirect your customer to the payment_url of the transaction in the response. When the order is completed, retrieve the order. Store the id of the transaction and the vault_token in its payment_method_details.
Charge subsequent payments
When a payment is due, create an order with recurring_type set to recurring and the stored vault_token:
curl https://api.pay.paytrim.com/v1/orders/ \
--user "$API_KEY:" \
--header "Content-Type: application/json" \
--data '{
"merchant_order_id": "GP-SUB-001-CYCLE-02",
"amount": 1295,
"currency": "EUR",
"description": "Monthly subscription",
"webhook_url": "https://www.example.com/webhook",
"transactions": [
{
"payment_method": "google-pay",
"payment_method_details": {
"recurring_type": "recurring",
"vault_token": "0c8fd8ab-25ec-4109-ac8f-495804aa5026"
}
}
],
"customer": {
"merchant_customer_id": "CUST-ABCDE",
"email_address": "jane.doe@example.com",
"first_name": "Jane",
"last_name": "Doe",
"address_type": "billing",
"address": "123 Abbey Road",
"postal_code": "NW8 9AY",
"country": "GB",
"city": "London",
"ip_address": "203.0.113.10"
}
}'The payment is processed without your customer. Follow the result with a webhook.
Server-to-server
Create the order
Create an order with a google-pay transaction and recurring_type set to first, as on the hosted payment page above.
Complete the payment
Complete the payment with the encrypted payload flow.
Charge subsequent payments
When the first transaction succeeds, charge the next payments as on the hosted payment page above.
Google Pay terms
Every merchant that accepts Google Pay must:
- Follow the Google Pay APIs Acceptable Use Policy.
- Accept the Google Pay API Terms of Service.