Integration
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 "mobile.integration@payu.in" 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'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.
Payment Request Post Data
Post Data can be generated by using
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.
Payment Options
Following Payment Options are currently supported by UPI sdk.
Dependency for PhonePe
To make payment through PhonePe, you must have to add payu phonepe dependency.
GradleAdd below url in root project build.gradle:
Add below dependency to project build.gradle
Dependency for Google pay
To make payment through Google Pay, you must have to add PayU Google Pay dependency.
GradleAdd below dependency to project build.gradle
Dependency for Samsung pay
To make payment through Samsung Pay, you must have to add payu samsung pay dependency.
GradleAdd below dependency to project build.gradle
Generate Postdata Using upi-sdk
Once you check the payment the availability of Payment, you could go ahead to make the payment.
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,
Following are error messages w.r.t. Samsung Pay initialisation failure.
In case below error is received while processing payment please check your Payment Post Data/ Payment hash
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.
Make Payment
To make the payment, first you need to create UpiConfig and provide mandatory parameters, merchant key and postdata, that we described above.
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.
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.
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
After creating the hash, you need to call getCommandResponse() method of Upi with the postdata.