PayU UPI SDK Integration

Onboarding Requirements

To start transacting through Google Pay, please register yourself on Google Pay using the following Google Onboarding, In this registration process please add the Merchant VPA Ids created by PayU for you. In the case of multiple VPAs, all of them needs to be registered. For any queries regarding the same, drop an email to "" team and we will get back to you.

Gradle Dependency

Adding the PayU Upi SDK (available at Maven Central)is a fairly straight forward process:

 implementation 'in.payu:upisdk:1.5.3'

If you are getting the below compile error.

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 Upon expanding the Merged Manifest view you would then see an additional error: Error: Missing 'package' key attribute on element package

It means you need to fix your Gradle plugin, refer to this document.

As UPI sdk is compiled on sdk version 29 with androidx support , it might happen that your app and SDK have common dependencies that lead to compile-time errors due to the duplicity of classes.

In such cases, you need to define resolutionStrategy on your project/App's build.gradle. For more details, Gradle doc.

configurations.all {
    resolutionStrategy {
        force "path of conflicting library 1"
        force "path of conflicting library 2"

Generate Payment Hash

Refer this document, Generate Hash to generate the hash.

Every transaction (payment or non-payment) needs a hash by the merchant before sending the transaction details to PayU. This is required for PayU to validate the authenticity of the transaction. This should be done on your server.

Payment Request Post Data

Ways to generate Postdata:

  • By UPI SDK itself - recommended if using UPI SDK alone.

  • By using PG Sdk library.

Post Data can be generated by using

        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());

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.

        android:value="" />

        android:value="" />


Payment Options

Following Payment Options are currently supported by UPI sdk.

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 payment through PhonePe, you must have to add payu phonepe dependency.


Add below url in root project build.gradle:

allprojects {
    repositories {
        maven {
            url ""

Add below dependency to project build.gradle

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

Dependency for Google pay

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


Add below dependency to project build.gradle

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

Dependency for Samsung pay

To make payment through Samsung Pay, you must have to add payu samsung pay dependency.


Add below dependency to project build.gradle

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

Generate Postdata Using upi-sdk

Refer this document, SDK Integration, Refer PaymentPostParams class to generate Postdata.

Once you check the payment the availability of Payment, you could go ahead to make the payment.


  • 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,

    Following are error messages w.r.t. Samsung Pay initialisation failure.

    - Error Codes      : Error messages 
    - 1                : VENDOR_NOT_SUPPORTED   // Device Vendor is not supported
    - 2                : DEVICE_NOT_SUPPORTED   // Device is not supported 
    - 3                : APP_VERSION_MISMATCH   // Samsung Pay version doesn't meet requirements 
    - 4                : COUNTRY_NOT_SUPPORTED  // Country of device origin is not supported by Samsung Pay 
    - 5                : MERCHANT_KEY_NOT_REGISTER_FOR_SAMSUNG_PAY        // Merchant is not registered for 
                                                                             Samsung Pay with PayU 
    - 6                : CONTEXT_NULL           // Context is null
    - 7                : PAYMENT_ID_NOT_PRESENT // Check your postdata

    In case below error is received while processing payment please check your Payment Post Data/ Payment hash

    - code        : 1002 
    - errormsg    : MERCHANT_INFO_NOT_PRESENT 
    - code        : 1004
    - errormsg    : INVOKING_APP_NOT_INSTALLED_CODE //Selected app is not installed on device.
    - code        : 1005
    - errormsg    : INVOKING_APP_NOT_ONBOARDED_CODE //Uses has not onboarded on UPI on selected application
  • isPaymentOptionAvailable(boolean isAvailable, PaymentOption paymentOption) Merchant must check for Samsung Pay/PhonePe payment option availability on the customer device before showing Samsung Pay/PhonePe as payment option on their checkout page.

  • onVpaEntered(String vpa, IValidityCheck iValidityCheck) For Generic Intent, we need to calculate validateVpahash using vpa and provide to verifyVpa method of iValidityCheck. Hash can be calculated using webservice command "validateVpa" as mentioned here.

        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, first you need to create UpiConfig and provide mandatory parameters, merchant key and postdata, that we described above.

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

Make Intent Payment by Specific App

In order to make Intent Payment by Specific UPI app kindly set the desired name of UPI app in upiConfig object as below.

where UPI_PACKAGE_ID can be any of UPI apps like -, etc.

Disable Manual VPA Fallback Option from Generic Intent Tray

You can disable the Manual VPA Fallback option from Generic Intent tray from backend as well as from frontend.

In order to disable it from front end, set UpiConfig.TRUE to setDisableIntentSeamlessFailure flag of UpiConfig.


Provide the PayUUPICallback instance and Upiconfig object to 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 below. For more detail.


VPA Validation

You can validate a VPA of its own using the SDK. You need to create a hash through this below command. Hash can be calculated using Webservice command "validateVpa" as mentioned here

var1= the vpa, you want to validate

This feature available from UPI SDK version >=1.2.0

After creating the hash, you need to call getCommandResponse() method of Upi with the 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.

PayUCommandResponse Sample

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

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.

Staging Environment Configurations

To Test on Staging Environment( use your Staging Env. merchant key and salt and add below 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="" />
<meta-data android:name="payu_post_url" android:value="" />

Last updated