Skip to content
📱Android Library to implement UPI Payment integration easily in Android App 💳💸
Branch: master
Clone or download
Latest commit e6ad786 Dec 10, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Delete android.yml Dec 9, 2019
EasyUpiPayment Update Docs Dec 9, 2019
app Release v2.0 Dec 9, 2019
docs Added JavaDoc Dec 9, 2019
gradle/wrapper Started Development on v2.0 Dec 9, 2019
.gitattributes Initial commit May 30, 2019
.gitignore Minor fix for Releasing for 1.0 Jun 3, 2019 Create Oct 31, 2019 Added GitHub Files Oct 31, 2019
LICENSE Initial commit May 30, 2019 Typo Fix Dec 10, 2019
_config.yml Set theme jekyll-theme-cayman May 30, 2019
build.gradle Started Development on v2.0 Dec 9, 2019 Initial commit May 30, 2019
gradlew.bat Initial commit May 30, 2019
settings.gradle Initial commit May 30, 2019

Easy UPI Payment - Android Library 📱💳

Bintray API JavaDoc

Github Followers GitHub stars GitHub forks GitHub watchers Twitter Follow


Hello Everyone, I have developed this Android library to easily implement UPI Payment Integration in Android app.

  • UPI apps are required to be installed already before using this library because, internally this API calls UPI apps for payment processing.
  • Before using it, make sure that your device is having atleast one UPI app installed. Otherwise it will unable to process the payments.
    This API is in beta, there are lot of improvements are still needed.


1. Start 2. Select UPI App 3. Complete Payment 4. Finish


You can clone this repository and just import this project in Android Studio. Sample app is in /app directory.


In your build.gradle file of app module, add below dependency to import this library

    dependencies {
      implementation 'com.shreyaspatil:EasyUpiPayment:2.0'

Setting Up Activity

In Android app, make any activity where you want to implement payment integration. Here, I have created

Initializing EasyUpiPayment :

You can see below code, these are minimum and mandatory calls to enable payment processing. If any of it is missed then error will generated.

        final EasyUpiPayment easyUpiPayment = new EasyUpiPayment.Builder()

Calls and Descriptions :

Method Mandatory Description
with() ✔️ This call takes Activity as a parameter where Payment is to be implemented
setPayeeVpa() ✔️ It takes VPA address of payee for e.g. shreyas@upi
setTransactionId() ✔️ This field is used in Merchant Payments generated by PSPs.
setTransactionRefId() ✔️ Transaction reference ID. This could be order number, subscription number, Bill ID, booking ID, insurance renewal reference, etc. Needed for merchant transactions and dynamic URL generation. This is mandatory because absencse of this field generated error in apps like PhonePe
setDescription() ✔️ To provide a valid small note or description about payment. for e.g.
For Food
setAmount() ✔️ It takes the amount in String decimal format (xx.xx) to be paid.
For e.g. 90.88 will pay Rs. 90.88.
setPayeeMerchantCode() Payee Merchant code if present it should be passed.
build() ✔️ It will build and returns the EasyUpiPayment instance.

App-Specific Payment

If you want to pay only with specific app like BHIM UPI, PhonePe, PayTm, etc. Then you can use method setDefaultPaymentApp() of EasyUpiPayment.

Following ENUM can be passed to this method.

  • PaymentApp.BHIM_UPI
  • PaymentApp.AMAZON_PAY
  • PaymentApp.GOOGLE_PAY
  • PaymentApp.PHONE_PE
  • PaymentApp.PAYTM



After this while payment, this app will be opened for transaction.

Proceed to Payment

To start the payment, just call startPayment() method of EasyUpiPayment and after that transaction is started.


Event Callback Listeners

To register for callback events, you will have to set PaymentStatusListener with EasyUpiPayment as below.


Description :

  • onTransactionCompleted() - This method is invoked when transaction is completed. It may either SUCCESS, SUBMITTED or FAILED.

NOTE - If onTransactionCompleted() is invoked it doesn't means that payment is successful. It may fail but transaction is completed is the only purpose.

  • onTransactionSuccess() - Invoked when Payment is successful.
  • onTransactionSubmitted() - Invoked when Payment is partially done/In waiting/Submitted/Pending.
  • onTransactionFailed() - Invoked when Payment is unsuccessful/failed.
  • onTransactionCancelled() - Invoked when Payment cancelled (User pressed back button or any reason).
  • onAppNotFound() - Invoked when app specified with setDefaultPaymentApp() is not exists on device.
    public void onTransactionCompleted(TransactionDetails transactionDetails) {
        // Transaction Completed
        Log.d("TransactionDetails", transactionDetails.toString());

    public void onTransactionSuccess() {
        // Payment Success
        Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();

    public void onTransactionSubmitted() {
        // Payment Pending
        Toast.makeText(this, "Pending | Submitted", Toast.LENGTH_SHORT).show();

    public void onTransactionFailed() {
        // Payment Failed
        Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();

    public void onTransactionCancelled() {
        // Payment Cancelled by User
        Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show();
    public void onAppNotFound() {
        // App Not exists on Device 
        Toast.makeText(this, "App Not Found", Toast.LENGTH_SHORT).show();

Removing Listener

To remove listeners, you can invoke detachListener() after the transaction is completed or you haven’t to do with payment callbacks.


Getting Transaction Details

To get details about transactions, we have callback method onTransactionCompleted() with parameter of TransactionDetails. TransactionDetails instance includes details about previously completed transaction.
To get details, below method of TransactionDetails are useful :

Method Description
getTransactionId() Returns Transaction ID
getResponseCode() Returns UPI Response Code
getApprovalRefNo() Returns UPI Approval Reference Number (beneficiary)
getStatus() Returns Status of transaction.
getTransactionRefId() Returns Transaction reference ID passed in input

Hurrah.... We have successfully implemented UPI integration in our Android app. Thank You!


We can collaboratively make it happen. So if you have any issues, new ideas about implementations then just raise issue and we are open for Pull Requests. Improve and make it happen. See Contributing Guidelines.


Project is published under the Apache 2.0 license. Feel free to clone and modify repo as you want, but don't forget to add reference to authors :)

You can’t perform that action at this time.