1. Integration Steps



To start transacting through Google Pay, register yourself on Google Pay using the following Google Onboarding. In this registration process, add the Merchant VPA Ids created by PayU for you. In case of multiple VPAs, all of them need to be registered. For any queries regarding the same, send an email to the Mobile Integration team.

Step 1: Create a PayU account

First, create a PayU account. For more information, refer to Register for a Merchant Account.

Step 2: Set up build.gradle

Add the PayU UPI SDK (available at Maven Central) to build. gradle:

implementation 'in.payu:upisdk:1.6.14'


Watch Out

If you are getting the following compile error, expand the Merged Manifest view.

Android resource linking failed /Users/sample/AndroidStudioProjects/MyApp/app/build/intermediates/merged_manifests/debug/AndroidManifest.xml:18: error: unexpected element found in <manifest> Manifest merger failed with multiple errors, see logs

In the Merged Manifest view, the following additional error message is displayed. This indicates that you need to fix your Gradle plugin. For more information on the Gradle plugin, refer to the Google Andriod Documentation.

Error: Missing 'package' key attribute on element package

As UPI SDK is compiled on SDK version 29 with Androidx support, your app, and SDK might have common dependencies that lead to compilation errors due to the duplicity of classes. In such cases, you need to define resolutionStrategy on your project or app’s build.gradle. For more information, refer to Gradle Documentation.

configurations.all {

resolutionStrategy {
force "path of conflicting library 1"
force "path of conflicting library 2"

Step 3: Generate Hash

To generate the hash, refer to Hash Generation.



Every transaction (payment or non-payment) needs a hash by you before sending the transaction details to PayU. Hash is required for PayU to validate the authenticity of the transaction. The hashing must be done on your server.

Step 4: Payment Request Post Data

You can use the following methods to generate post data are:

  • By UPI SDK itself (recommended if you are using UPI SDK alone)
  • By using the PG SDK library.

PostData can be generated by using the following sample code:

        PaymentParamsUpiSdk mPaymentParamsUpiSdk = new PaymentParamsUpiSdk();
        mPaymentParamsUpiSdk.setKey(inputData); //Your Merchant Key

        mPaymentParamsUpiSdk.setProductInfo("product info");
        mPaymentParamsUpiSdk.setFirstName("first name"); //Customer First name
        mPaymentParamsUpiSdk.setEmail("email"); //Customer Email
        mPaymentParamsUpiSdk.setTxnId("txnId"); //Your transaction id
        mPaymentParamsUpiSdk.setAmount("Transaction Amount"); //Your transaction Amount(In Double as String)
        mPaymentParamsUpiSdk.setSurl("success url");
        mPaymentParamsUpiSdk.setFurl("failure url");
        mPaymentParamsUpiSdk.setVpa("vpa"); //In case of UPI Collect set customer vpa here
        mPaymentParamsUpiSdk.setUserCredentials("user credentials");
        mPaymentParamsUpiSdk.setOfferKey("offer key");
        mPaymentParamsUpiSdk.setPhone("phone number");//Customer Phone Number
        mPaymentParamsUpiSdk.setHash("hash");//Your Payment Hash

        String postDataFromUpiSdk = new PostDataGenerate.PostDataBuilder(this).
     * Callback of payment availability while doing through UPISDK.
    PayUUPICallback payUUpiSdkCallback = new PayUUPICallback() {

        public void isPaymentOptionAvailable(boolean isAvailable, PaymentOption paymentOption) {
            super.isPaymentOptionAvailable(isAvailable, paymentOption);
            switch (paymentOption) {
                case PHONEPE:
                   //check whether you show Phonepe or not using isAvailable.
                case SAMSUNGPAY:
                 //check whether you show Samsung Pay or not using isAvailable
 //Checking the payment availability for PHONEPE, SAMSUNGPAY and Google Pay.
 // It will return the availability on payUUpiSdkCallback isPaymentOptionAvailable() method.
   Upi upi = Upi.getInstance();
        upi.checkForPaymentAvailability(this, PaymentOption.PHONEPE, payUUpiSdkCallback, mPayUHashes.getPaymentRelatedDetailsForMobileSdkHash(), mPaymentParamsUpiSdk.getKey(), mPaymentParamsUpiSdk.getUserCredentials());
        upi.checkForPaymentAvailability(this, PaymentOption.SAMSUNGPAY, payUUpiSdkCallback, mPayUHashes.getPaymentRelatedDetailsForMobileSdkHash(), mPaymentParamsUpiSdk.getKey(), mPaymentParamsUpiSdk.getUserCredentials());
        upi.checkForPaymentAvailability(this, PaymentOption.TEZ, payUUpiSdkCallback, mPayUHashes.getPaymentRelatedDetailsForMobileSdkHash(), mPaymentParamsUpiSdk.getKey(), mPaymentParamsUpiSdk.getUserCredentials());

Step 5: Set up for Test Merchant

If you are using the SDK with a test merchant, provide the following metadata value to the manifest file:

android:value="https://test.payu.in" />
android:value="https://test.payu.in" />

Step 6: Payment Options

UPI SDK currently supports the following payment options:

PaymentOption.PHONEPE: Payment using PhonePe
PaymentOption.SAMSUNGPAY: Payment using Samsung pay.
PaymentOption.TEZ: Payment using Google Pay.
PaymentOption.UPI_INTENT: Payment using UPI apps installed on device.i,e, Intent flow..
PaymentOption.UPI_COLLECT: UPI payment through web flow.

Dependency for PhonePe

To make a payment through PhonePe, you must have to add PayU PhonePe dependency:

  • Add the following URL to the root project of build.gradle:
allprojects {
repositories {
maven {
url "https://phonepe.mycloudrepo.io/public/repositories/phonepe-intentsdk-android"
  • Add the following dependency to the root project of build.gradle:

implementation 'in.payu:phonepe-intent:1.7.2'

Dependency on Google Pay

To make a payment through Google Pay, you must have to add PayU Google Pay dependency:

  • Add the following dependency to the root project of build.gradle:

implementation 'in.payu:payu-gpay:1.5.3'

Dependency on Samsung Pay

To make a payment through Samsung Pay, you must have to add PayU Samsung dependency:

  • Add the following dependency to the root project of build.gradle:

implementation 'com.payu.samsungpay:samsungpay:1.0'

  • Use PaymentPostParams class to generate Postdata. For more information, refer to TPV Integration.
    After you check the payment availability of Payment, you can go ahead to make the payment.

Step 7: Callbacks

  • onPaymentFailure(String payuResult,String merchantResponse): Calls when payment fails.
  • onPaymentSuccess(String payuResult,String merchantResponse): Calls when payment succeeds.
  • onUpiErrorReceived(int errorCode,String errorMessage): Called for error on UPI SDK where the following error messages are displayed for Samsung Pay initialization failure.
Error CodesError messagesDescription
1VENDOR_NOT_SUPPORTEDThe device Vendor is not supported
2DEVICE_NOT_SUPPORTEDThe device is not supported
3APP_VERSION_MISMATCHSamsung Pay version doesn't meet the requirements
4COUNTRY_NOT_SUPPORTEDThe country of device origin is not supported by Samsung Pay
5MERCHANT_KEY_NOT_REGISTER_FOR_SAMSUNG_PAYMerchant is not registered for Samsung Pay with PayU
6CONTEXT_NULLContext is null
7PAYMENT_ID_NOT_PRESENTCheck your postdata

If the following error messages are received while processing payment, check your Payment Post Data or Payment hash.

Error CodeError MessageDescription
1004INVOKING_APP_NOT_INSTALLED_CODEThe selected app is not installed on the device.
1005INVOKING_APP_NOT_ONBOARDED_CODEApplication uses have not been onboarded on UPI on the selected
  • isPaymentOptionAvailable(boolean isAvailable, PaymentOption paymentOption): The merchant must check for Samsung Pay/PhonePe payment option availability on the customer device before showing Samsung Pay/PhonePe as the payment option on their checkout page.
  • onVpaEntered(String vpa, IValidityCheck iValidityCheck): For Generic Intent, you need to calculate validateVpahash using VPA and provide to verifyVpa method of iValidityCheck. Hash can be calculated using the validateVpa webservice. For more information, refer to Hash Generation.
PayUUPICallback payUUpiSdkCallbackUpiSdk = new PayUUPICallback() {
public void onPaymentFailure(String payuResult, String merchantResponse) {
super.onPaymentFailure(payuResult, merchantResponse);
//Payment failed
public void onPaymentSuccess(String payuResult, String merchantResponse) {
super.onPaymentSuccess(payuResult, merchantResponse);
//Payment succeed
public void onVpaEntered(String vpa, IValidityCheck iValidityCheck) {
super.onVpaEntered(vpa, iValidityCheck);
String input = "payu merchant key" + "|validateVPA|" + vpa + "|" + "payu merchant salt";
public void onUpiErrorReceived(int code, String errormsg) {
super.onUpiErrorReceived(code, errormsg);
//Any error on upisdk

Make Payment

To make the payment, you need to create UpiConfig and provide mandatory parameters, merchant key, and postdata. For more information, refer to Payment Request Post Data.

UpiConfig upiConfig = new UpiConfig();
upiConfig.setMerchantKey("merchant key");
upiConfig.setPayuPostData("postdata");// that we generate above
//In order to set CustomProgress View use below settings

Make Intent Payment by Specific App

To make Intent Payment by Specific UPI app, kindly set the desired name of the UPI app in the upiConfig object.


Where UPI_PACKAGE_ID can be any of UPI apps such as: com.phonepe.app(PhonePe), com.google.android.apps.nbu.paisa.user(GPay) etc.

Disable Manual VPA Fallback Option from Generic Intent Tray
You can disable the Manual VPA Fallback option from the Generic Intent tray from the back-end and from the front-end.
In order to disable it from front-end, set UpiConfig.TRUE to setDisableIntentSeamlessFailure flag of UpiConfig.


Provide the PayUUPICallback instance and Upiconfig object to the UPI makepayment() method.

Upi upi = Upi.getInstance();
upi.makePayment(payUUpiSdkCallbackUpiSdk, activity, upiConfig);



For Device API Level 19, you must enable GMS provider service and set gmsProviderUpdatedStatus of UpiConfig similar to the following example. For more details, refer to the Andriod Documentation.


Step 8: VPA Validation

You can validate a VPA of its own using the SDK. You need to create a hash through the below command. Hash can be calculated using the Webservice command validateVpa. For more information, refer to Hash Generation.



  • key=YOUR KEY
  • command=validateVPA
  • salt= YOUR SALT
  • var1= the vpa, you want to validate



This feature is only available from UPI SDK version 1.2.0 or later.

After creating the hash, you need to call the getCommandResponse() method of UPI with postdata.

Upi upi = Upi.getInstance();
upi.getCommandResponse(Activity, postdata, PayUUPICallback);

Create postdata for VPA Validation

String postData= "key=" + Your Key + "&var1=" + {VPA for validation} + "&command=validateVPA&" + "hash=" + {Hash you generated above}

You will get the response to onCommandResponse(String payUCommandResponse, String command) of PayUUPICallback.

"vpa":"VPA you are validating",
"isVPAValid":1, //It will be 0(Invalid) or 1(Valid)
"payerAccountName":"Payer Name corresponding to the VPA"}



After 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 an SDK callback, to the merchant. It is recommended for the merchant process the transaction order status – based on the S2S response and not via the Browser Redirection/SDK callback response to ensure optimum translation outcomes. For more information on the Webhook implementation, refer to Web Checkout Integration Documentation > Webhooks.

Also, you can verify payment through polling, the transaction status after the SDK callback from your backend. For more information, refer to Verify the Transaction.

Sandbox Environment Configurations

To test on Sandbox or Test Environment(test.payu.in), use your Sandbox environment merchant key and Salt and add the following configurations in your application manifest:

<meta-data android:name="payu_debug_mode_enabled" android:value="true" />
<meta-data android:name="payu_web_service_url" android:value="https://test.payu.in" />
<meta-data android:name="payu_post_url" android:value="https://test.payu.in" />

In the case of UPI intent/InApp flow, you will not receive a callback response in SURL/FURL. In this case, the format of payuresponse received will be different from other payment options that you can handle accordingly.
If you get mihpayid in the PayU response, consider as a PayU ID/ID.