Integration
This page describes how to integrate with Google Pay SDK.
Gradle Dependency
Add below dependency in application's build.gradle.
Callbacks
List of the callback function provided by PayU Google Pay:
onPaymentFailure (String payuResponse, String merchantResponse) - Calls when payment fails
onPaymentSuccess (String payuResponse, String merchantResponse) - Calls when payment succeeds
onPaymentOptionInitialisationFailure (int errorCode,String description) - Called for Google Pay initialisation failure where,
errorCode : Error Code
description : Error Description
onPaymentInitialisationSuccess() - Callback when Google Pay is successfully initialized.
onGpayErrorReceived(int errorCode, String description) - Callback when found any error while making payment transaction.
Following are error messages w.r.t. Google Pay Payment failure
Set up for Test/Sandbox Merchant
If you are using the SDK with a test merchant, please provide this metadata value to the manifest file else removed these lines below.
Check Payment Availability
Call method checkForPaymentAvailability available in Google Pay to check if Google Pay payment is available or not on the device. This method is called before showing Google Pay as a checkout option.
Sample:
To generate PaymentOption Hash visit here.
Make Payment by Google Pay
After successful initialisation of Google Pay by calling checkForPaymentAvailability method call makePayment method to make payment.
Sample PostData
Verify the transaction through Webhooks or polling
Once you get the response from SDK, make sure to confirm it with the PayU server. It is recommended to implement the PayU Webhook or backend verify call from your backend.
Implementation of PayU WebHook
Webhook is a server-to-server callback. Once this feature is activated for merchants, PayU would send an S2S response, in addition to SDK callback, to the merchant. It is recommended for the merchant to process the transaction order status – based upon the S2S response and not via the Browser Redirection/SDK callback response to ensure optimum translation outcomes.
Refer to this document, for Webhook implementation.
There is another option to verify payment through polling, the transaction status after the SDK callback from your backend.
Last updated