Google Pay
Google Pay allows users to make payments using payment cards saved in their Google account. When paying with this method, if the user is logged into Google, they will see their preferred payment card, an option to switch to another card saved in their Google account, and a way to confirm the transaction. If the user is not logged in, a login form for their Google account will be displayed. During the payment process, a one-time payment token is generated by Google and used instead of card data, enhancing transaction security.
Before you start
Ensure that you:
- Have API authorization data.
- Handle transaction webhooks.
- Have card payments enabled.
- Have the Google Pay payment channel enabled.
Google Pay transaction
Execute Google Pay payments using the transaction creation endpoint with groupId: 166
.
Send a request to create a Google Pay transaction
To create a Google Pay transaction, send a POST
request to the endpoint:
https://api.tpay.com/transactions
Check details in the API Reference documentation: POST /transactions
Specify the following parameters in the request:
amount | Transaction amount (in PLN). |
description | Description of the transaction visible to the payer. |
payer.email | Payer's email address. |
payer.name | Payer's full name. |
pay.groupId | Payment group identifier for Google Pay: 166. |
The basic body of the request should look as follows:
{ "amount": 0.1, "description": "Google Pay test payment", "payer": { "email": "[email protected]", "name": "John Doe" }, "pay": { "groupId": 166 } }
Example:
curl --location 'https://api.tpay.com/transactions' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data-raw '{ "amount": 0.1, "description": "Google Pay test payment", "payer": { "email": "[email protected]", "name": "John Doe" }, "pay": { "groupId": 166 } }'
After sending the request, you will receive a TransactionCreated
schema in response.
Key response parameters:
result | success - The transaction was created successfully. |
status | pending - The transaction is awaiting payment. |
transactionPaymentUrl | URL to redirect the payer to. |
Example response:
{ "result": "success", "requestId": "8d67feda5067b7df97f0", "transactionId": "ta_zBQdVyQA1dZKVoL3", "title": "TR-BRA-CN7CN3X", "posId": "ps_NyRBLzV5kelrpjaM", "status": "pending", "date": { "creation": "2024-06-04 21:39:46", "realization": null }, "amount": 0.1, "currency": "PLN", "description": "Google Pay test payment", "hiddenDescription": "", "payer": { "payerId": "py_a9rjlZWxRLdG1bqY", "email": "[email protected]", "name": "John Doe", "phone": "", "address": "", "city": "", "country": "PL", "postalCode": "" }, "payments": { "status": "pending", "method": "pay_by_link", "amountPaid": 0, "date": { "realization": null } }, "transactionPaymentUrl": "https://secure.tpay.com/?title=TR-BRA-CN7CN3X&uid=01HZJC7HJXA31Z67XNWRV9R0A3" }
Redirect the payer to the Transaction Panel
Redirect the payer to the URL provided in the transactionPaymentUrl
field in the response.
At the provided URL, the payer will see a payment sheet with a list of available payment cards saved in their Google account or a login form for their Google account.
The payer selects a card and completes the transaction.
If you integrate payments with a mobile application and open the transaction panel in WebView, the Google Pay payment method will not be properly supported. We recommend opening payments in the default web browser or on-site integration.
The payer will be redirected to a success or error page
When the Google Pay payment is completed, the payer will be redirected to a success page or error page depending on whether the transaction was successful.
Handle notification
We will notify you about the transaction status via the transaction webhook. Check the details.
Google Pay on-site
Google Pay on-site is an integration of Google Pay payments directly on your website/mobile application.
It involves placing the Google Pay payment mechanism in a way that allows customers to pay directly from your website/mobile application.
Check more:
The Google Pay on-site method is currently available only for the acquirer Pekao. Check if your card payments are processed via the acquirer Pekao.
Integrate Google Pay in the browser using the tutorial
If you are integrating your payment system that the payer uses via a web browser, follow the tutorial prepared by Google:
Integrate Google Pay in Android using the tutorial
If you are integrating your payment system in a mobile application on Android, follow the instructions prepared by Google:
For Android applications using WebViews, you need to call the platform-specific Google Pay API. Examples can be found here: Binding JavaScript code with Android code.
Configure Google Pay SDK
For correct implementation, configure the payment method as follows.
Google Pay API version used in the integration:
Gateway used during payment:
parameters.gateway | ensure it is set to tpaycom . |
{MERCHANT_ID} | unique identifier assigned to you during Tpay account registration. |
Supported card networks:
Supported authorization methods:
Address format:
The value provided above is the default value; you do not need to implement it.
Send a request to create a Google Pay transaction
To create a Google Pay transaction, send a POST
request to the endpoint:
https://api.tpay.com/transactions
Check details in the API Reference documentation: POST /transactions
Specify the following parameters in the request:
amount | Transaction amount (in PLN). |
description | Description of the transaction visible to the payer. |
payer.email | Payer's email address. |
payer.name | Payer's full name. |
payer.ip | Payer’s IP address (IPv4 or IPv6). |
groupId | Payment group identifier for Google Pay: 166. |
The basic body of the request should look as follows:
{ "amount": 0.1, "description": "Google Pay test payment", "payer": { "email": "[email protected]", "name": "John Doe", "ip": "127.0.0.1" }, "pay": { "groupId": 166 } }
Example:
curl --location 'https://api.tpay.com/transactions' \ --header 'Authorization: Bearer <access_token>' \ --header 'Content-Type: application/json' \ --data-raw '{ "amount": 0.1, "description": "Google Pay test payment", "payer": { "email": "[email protected]", "name": "John Doe", "ip": "127.0.0.1" }, "pay": { "groupId": 166 } }'
After sending the request, you will receive a TransactionCreated
schema in response.
Key response parameters:
result | success - The transaction was created successfully. |
status | pending - The transaction is awaiting payment. |
transactionId | Unique transaction identifier - store it in your system. |
Example response:
{ "result": "success", "requestId": "8d67feda5067b7df97f0", "transactionId": "ta_zBQdVyQA1dZKVoL3", "title": "TR-BRA-CN7CN3X", "posId": "ps_NyRBLzV5kelrpjaM", "status": "pending", "date": { "creation": "2024-06-04 21:39:46", "realization": null }, "amount": 0.1, "currency": "PLN", "description": "Google Pay test payment", "hiddenDescription": "", "payer": { "payerId": "py_a9rjlZWxRLdG1bqY", "email": "[email protected]", "name": "John Doe", "ip": "127.0.0.1", "phone": "", "address": "", "city": "", "country": "PL", "postalCode": "" }, "payments": { "status": "pending", "method": "pay_by_link", "amountPaid": 0, "date": { "realization": null } }, "transactionPaymentUrl": "https://secure.tpay.com/?title=TR-BRA-CN7CN3X&uid=01HZJC7HJXA31Z67XNWRV9R0A3" }
Process the response object
When the payer confirms the payment in the Google Pay form, handle the returned payment data.
Android:
Android how to process payment data
Browser
Browser how to process payment data
Pay the transaction using the payment token
To complete the Google Pay on-site transaction, use the previously stored transactionId
parameter, sending a POST
request to the address:
https://api.tpay.com/transactions/{transactionId}/pay
Place {transactionId}
in the URL, for example:
https://api.tpay.com/transactions/ta_jrkNGj5L29pnlbqw/pay
Specify the following parameters in the request:
groupId | Payment group identifier for Google Pay: 166. |
googlePayPaymentData | Encrypted payment token in base64 format. |
The payment token is located in the paymentMethodData.tokenizationData.token
.object. Encrypt its content using the base64 algorithm.
The basic body of the request should look as follows:
Example:
After sending the request, you will receive a TransactionCreated
(https://api.tpay.com/#/Transactions/post_transactions_create) schema in response.
Handle 3D Secure redirection
The status parameter with the value pending
,indicates that the transaction requires additional 3D Secure authentication. Redirect the payer to the address specified in the transactionPaymentUrl
parameter, where they can complete the 3D Secure authentication. Check more.
Display the transaction result
After receiving the notification about the transaction status, use the tr_status
field and display the transaction result.