Skip to main content
To support Google Pay Cards on your S2S integration:
  1. Show Google Pay as a separate option when Google Pay is set up on your customer’s device (Know how to check if Google Pay Cards is available on the customer’s device).
  2. Trigger payment when the user clicks Pay with Google Pay Cards on your checkout.
Feature Request
This is an on-demand feature. Please raise a request with our Support team to get this feature activated on your Razorpay account. to get this feature activated on your account.

Prerequisites

Integration Steps

1

[Download the SDKs](#step-1-download-the-sdks)

2

[Add dependencies in Build Gradle file](#step-2-add-dependencies-in...

3

[Check if GPay Cards is supported](#step-3-check-if-gpay-cards-is-s...

4

[Create an order](#step-4-create-an-order)

5

[Create a payment](#step-5-create-a-payment)

6

[Prepare payload for Initiating Payment to Google](#step-6-prepare-...

7

[Invoke Google Pay App](#step-7-invoke-google-pay-app)

8

[Handle response from Google Pay App (optional)](#step-8-handle-res...

9

[Verify payment status](#step-9-verify-payment-status)

Step 1: Download the SDKs

Download the Google Pay SDK and add the .aar file to the application library.

Step 2: Add Dependencies in Build Gradle File

Add the following lines to your app’s build.gradle file.
Dependencies

Step 3: Check if Gpay Cards is Supported

Show Google Pay as a payment option only when Google Pay is set up on your customer’s device. Google Pay is set up when:
  1. The Google Pay app is installed, and
  2. Valid cards or bank accounts (UPI) are added to your customer’s Google pay account.
This will enable you to show only relevant payment methods to your users. Follow these steps to check if Google Pay Cards is supported:

Step 3.1: Integrate the following code snippet in your app

Given below is the code sample:

Step 3.2: Check if Google Pay Cards is set up

Invoke the isReadyToPay function when you want to check if Google Pay Cards is set up on your customer’s device, using the following payload:
Show Pay with Google Pay cards method to your end customers only when isReadyToPay function returns true.

Step 4: Create an Order

Order is an important step in the payment process.
  • An order should be created for every payment.
  • You can create an order using the Orders API. It is a server-side API call. Know how to authenticate Orders API.
  • The order_id received in the response should be passed to the checkout. This ties the Order with the payment and secures the request from being tampered.
Watch Out!Payments made without an order_id cannot be captured and will be automatically refunded. You must create an order before initiating payments to ensure proper payment processing.

API Sample Code

The following is a sample API request and response for creating an order:
Curl

Request Parameters

Here is the list of parameters and their description for creating an order:amount mandatory : integer Payment amount in the smallest currency sub-unit. For example, if the amount to be charged is 299, then pass 29900 in this field. In the case of three decimal currencies, such as KWD, BHD and OMR, to accept a payment of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, to accept a payment of 295, pass the value as 295.
Watch Out!As per payment guidelines, you should pass the last decimal number as 0 for three decimal currency payments. For example, if you want to charge a customer 99.991 KD for a transaction, you should pass the value for the amount parameter as 99990 and not 99991.currency mandatory : string The currency in which the transaction should be made. See the list of supported currencies. Length must be 3 characters.
Handy Tips
Razorpay has added support for zero decimal currencies, such as JPY and three decimal currencies, such as KWD, BHD and OMR, allowing businesses to accept international payments in these currencies. Know more about Currency Conversion (May 2024).receipt optional : string Your receipt id for this order should be passed here. Maximum length is 40 characters.notes optional : json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.partial_payment optional : boolean Indicates whether the customer can make a partial payment. Possible values:
  • true: The customer can make partial payments.
  • false (default): The customer cannot make partial payments.
id mandatory : string Unique identifier of the customer. For example, cust_1Aa00000000004.Know more about Orders API.

Response Parameters

Descriptions for the response parameters are present in the Orders Entity table.

Error Response Parameters

The error response parameters are available in the API Reference Guide.The razorpay_order_id returned on successful creation of the order should be sent to the Checkout form.

Step 5: Create a Payment

Once an order is created, your next step is to create a payment. The following API will create a payment with Pay with Google Pay Cards as the payment method: /payments/create/json
Request

Request Parameters

amount mandatory : integer The amount to be paid by the customer in currency subunits. For example, if the amount is ₹100, enter 10000. currency mandatory : string The currency in which the payment should be made by the customer. See the list of supported currencies. order_id mandatory : string Order ID generated in the previous step. email mandatory : string Email address of the customer. contact mandatory : string Phone number of the customer. provider mandatory : string Name of the service provider partnered with Razorpay. Enter the value google_pay. notes optional : object Set of key-value pairs used to store additional information about the payment. It can hold a maximum of 15 key-value pairs, each 256 characters long (maximum). callback_url optional : string URL endpoint where Razorpay will submit the final payment status. ip optional : string Customer IP Address. referrer optional : string Customer referrer. user_agent optional : string Customer user-agent.

Response Parameters

Given below are the response parameters: razorpay_payment_id : string Unique identifier of the payment. Present for all responses. next : array A list of action objects available to you to continue the payment process. Present when the payment requires further processing. action : string An indication of the next step available to you to continue the payment process. Possible value:
  • invoke_sdk: Contains the payload needed to create loadPaymentData payload as specified by the Google SDK specification. Use this to create the payload and pass it to the customer’s device. Use the same to invoke the Google Pay app on the user’s android app.
  • poll: Contains the URL you must poll to fetch the payment status (authorized or failed).

Step 6: Prepare payload for Initiating Payment to Google

As a next step, you need to initiate payment to Google SDK integrated in Step 2. To initiate the payment, you need to create a payload in the format prescribed by Google. The payload structure is explained in this step: Google Pay payload: Google expects following payload in payment request:
Pay Payload

Request Parameters

As can be seen, the payload has a lot of fields. Razorpay will provide values to be passed in some of the fields. For the remaining fields, you would need to be pass the values from your end. The value to be passed in each field is displayed in the table below:

Parameter | Data Type | Description | Required?

apiVersion | Integer | The Google Pay API version used. The current version is 2. | Y

apiVersionMinor | Integer | The Google Pay API minor version used. The current version is 0. | Y

allowedPaymentMethods | Array | An array of objects for each method to be allowed. In this case, it will have two objects one each for UPI and Cards respectively. Each of the objects are explained in subsequent tables. | Y

transactionInfo.currencyCode | string | The value is INR. | Y

transactionInfo.totalPrice | string | The payment amount passed in the API request in step 5. The amount here is in INR. | Y

transactionInfo.totalPriceStatus | string | The value is FINAL. | Y

UPI Object

The table below explains the fields for the UPI object:

Google Pay Field | Razorpay Field | Value

parameters.payeeVpa required | provider_data.google_pay.upi.payee_vpa | This is your VPA created by Razorpay. This will be provided by Razorpay in payment response in step 5.

parameters.payeeName required | NA | You need to pass the user-facing business name for your business.

parameters.referenceUrl optional | NA | Your website URL for this specific payment. You may pass your website URL here.

parameters.mcc required | provider_data.google_pay.upi.mcc | This is a digit category code for your business. This will be provided by Razorpay in payment response in step 5.

parameters.transactionReferenceId required | provider_data.google_pay.upi.gateway_reference_id | This is a unique ID generated for this UPI payment. This will be provided by Razorpay in payment response in step 5.

tokenizationSpecification.type required | DIRECT | Always Direct

Card Object

The table below explains the fields for the card object:

Google Pay Field | Razorpay Field | Value

parameters.allowedCardNetworks required | provider_data.google_pay.card.supported_networks | This field indicates the card networks to be supported by Google. This will be provided by Razorpay in payment response in step 5. * You will need to transform network names in block letters.For example, convert Visa to VISA and MasterCard to MASTERCARD.

tokenizationSpecification.type required | DIRECT | Always Direct.

tokenizationSpecification.parameters.gateway required | razorpayindia | Always razorpayindia.

tokenizationSpecification.parameters.gatewayMerchantId required | NA | This is the Razorpay merchant ID for your Razorpay account. You can find this by logging in to the Dashboard and clicking the user icon on the top right corner.

tokenizationSpecification.parameters.gatewayTransactionId required | provider_data.google_pay.card.gateway_reference_id | This is a unique ID generated for this Card payment. This will be provided by Razorpay in payment response in step 5.

Step 7: Invoke Google Pay App

The payload created by you in step 6 (using the data available in invoke_sdk action in next array) will be used here. You will need to pass the payload to your Android app and initiate the loadPaymentData function as shown below:
code
This will open the Google Pay app on the customer’s device for payment processing.

Step 8: Handle response from Google Pay App (Optional)

Google Pay app will return result to onActivityResult function as shown below:
onActivityResult
Your app can further use the snippet code below to get more insight into the error code RESULT_FIRST_USER received in onActivityResult:
onActivityResult

Step 9: Verify Payment Status

When your application gets Result_OK from the Google app, you can verify the same using any of the following methods: