Tpay
DOCS

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.

Supported card types

Currently, we only support Visa and Mastercard cards.

Before you start

Ensure that you:

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

* Fields required.

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": "01K5BK4HEPB0WBCGT51FMTYSYJ",
  "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.

Note

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 in an online store/mobile application.

It consists of implementing the Google Pay payment mechanism in a way that allows customers to pay directly from your website/mobile application.

Note

The Google Pay on-site method is currently available only for the Pekao acquiring agent. Check whether your card payments are processed through this acquiring agent.

Supported integration scenarios

Google Pay on-site can be integrated in the following scenarios:

ScenarioDescription
Android application (native)Google Pay is launched directly in a native Android mobile application, where the integration is implemented using the Google Pay API for Android.
Android application with WebViewGoogle Pay is launched in a mobile application via the WebView component, where the user is redirected to the Tpay transaction panel handling the Google Pay payment.
Web browser (Web)Google Pay is launched directly on the checkout page in your online store, where the integration is implemented using the Google Pay JavaScript SDK.

Integration in a mobile application (Android - native)

If you are integrating your payment in an Android mobile application, follow the instructions prepared by Google:

Mobile application guide.

Requirements:

To correctly launch Google Pay in an Android application, the application should:

  • be signed with the application certificate (SHA-256),
  • be submitted and configured in the Google Pay & Wallet Console,
  • have a correctly configured package name consistent with the application data registered in Google.

Application requirements and environment configuration are described in Google's documentation:

Testing and production readiness

Google provides a checklist of functional and branding requirements that must be met before publishing the integration:

Integration checklist (Android)

Integration in a mobile application with Webview

For Google Pay integration in a mobile application using WebView, the application should redirect the user to the Tpay transaction panel, where the Google Pay payment is launched.

In this model:

  • Google Pay integration is handled in the Tpay transaction panel,
  • you do not implement Google Pay directly in your application or on your checkout page.

Application-side requirements:

For the Google Pay payment to be correctly launched in WebView, the application should:

  • use up-to-date versions of Android System WebView / Chrome,
  • have Payment Request API support enabled in the WebView environment,
  • meet Google's requirements for handling payments in WebView,
  • complete the application integration publishing process in the Google Pay & Wallet Console (for the production environment).

Detailed implementation steps are described in Google's documentation:

Note

If the WebView environment does not meet Google Pay requirements, the payment button may not be displayed or the payment may not be correctly launched.

Web integration (browser)

If you are integrating your payment in a system that the payer uses through a web browser, follow the tutorial prepared by Google:

Browser guide.

Domain registration (Web – required)

For Google Pay integration in a browser, you must register the domain on which the checkout is launched in the Google Pay & Wallet Console.

To do this:

  1. Log in to the Google Pay & Wallet Console
  2. Go to the Business information → Websites section
  3. Add the domain from which the Google Pay API is called
  4. Submit the domain for approval by Google

During the approval process, Google verifies, among other things:

  • correctness of the Google Pay API implementation,
  • compliance of the integration with security requirements,
  • operation of payments in test and production environments,
  • compliance with checkout and UX guidelines.

Domain registration applies to integrations implemented directly on the merchant's website. If the payment is processed via redirection to the Tpay transaction panel, domain registration on the merchant side is not required.

Additional requirements and a list of implementation steps are available in the Google documentation

Google Pay SDK configuration for web integration

For correct implementation, configure the payment method as follows.

Google Pay API version used in the integration:

const baseRequest = {
  apiVersion: 2,
  apiVersionMinor: 0,
};

Gateway used during payment:

const tokenizationSpecification = {
  type: "PAYMENT_GATEWAY",
  parameters: {
    gateway: "tpaycom",
    gatewayMerchantId: "{MERCHANT_ID}",
  },
};
parameters.gateway
ensure it is set to tpaycom.
{MERCHANT_ID}
unique identifier assigned to you during Tpay account registration.

Supported card networks:

const allowedCardNetworks = ["MASTERCARD", "VISA"];

Supported authorization methods:

const allowedCardAuthMethods = ["PAN_ONLY", "CRYPTOGRAM_3DS"];

Address format:

const BillingAddressParameters = {
  format: "MIN",
};

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

* Fields required.

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": "01K5BK4HEPB0WBCGT51FMTYSYJ",
  "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/01K5BK4HEPB0WBCGT51FMTYSYJ/pay

Specify the following parameters in the request:

groupId
 *
Payment group identifier for Google Pay: 166.
googlePayPaymentData
 *
Encrypted payment token in base64 format.

* Fields required.

Note

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:

{
  "groupId": 166,
  "googlePayPaymentData": "ewogInRwYXkiIDogIkhlbGxvIFdvcmxkIgp9"
}

Example:

curl --location 'https://api.tpay.com/transactions/01K5BK4HEPB0WBCGT51FMTYSYJ/pay'\
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <access_token>' \
--data '{
"groupId": 166,
"googlePayPaymentData": "ewogInRwYXkiIDogIkhlbGxvIFdvcmxkIgp9"
}'

After sending the request, you will receive a TransactionCreated(https://api.tpay.com/#tag/Transactions/operation/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.