Giter VIP home page Giter VIP logo

cordova-plugin-upi's Introduction

cordova-plugin-upi

Cordova plugin to pay via UPI supported apps via intent based

Supported Platform:

  • Android

Installations:

cordova plugin add cordova-plugin-upi

After installation, the upi plugin would be avilable in "window" object.

Methods:

  • Fetch UPI supported apps.
let successCallback = function (apps) {
    console.log("UPI supported apps", apps);
}
let failureCallback = function (err) {
    console.error("Issue in fetching UPI supported apps ", err);
}

window["UPI"].supportedApps(successCallback, failureCallback);
  • Start a transaction you can start a transaction either by passing upistring or parsed value as given below.
let config = {
        "pa": "pa", // VPA no from UPI payment acc
        "pn": "pn", // Merchant Name registered in UPI payment acc
        "me": "me", // Merchant Code from UPI payment acc
        "tid": "tid", // Unique transaction id for merchant's reference
        "tr": "tr", // Unique transaction id for merchant's reference
        "tn": "tn", // Note that will displayed in payment app during transaction
        "am": "am", // Amount 
        "mam": "mam", // its optional. Minimum amount that has to be transferred 
        "cu": "cu", // Currency of amount
        "url": "url" // URL for the order
};

or

let config = {
        "payeeVPA": "pa", // VPA no from UPI payment acc
        "payeeName": "pn", // Merchant Name registered in UPI payment acc
        "payeeMerchantCode": "me", // Merchant Code from UPI payment acc
        "transactionId": "tid", // Unique transaction id for merchant's reference
        "transactionRef": "tr", // Unique transaction id for merchant's reference
        "transactionNote": "tn", // Note that will displayed in payment app during transaction
        "amount": "am", // Amount 
        "minimumAmount": "mam", // its optional. Minimum amount that has to be transferred 
        "currency": "cu", // Currency of amount
        "transactionRefUrl": "url" // URL for the order
};
let successCallback = function (result) { 
    /* success and failure of payment will be given in this method, this is because each payment uses different name to represent the status of transaction under "Status" field.*/
    console.log("result of success interaction of payment app", result);
}
let failureCallback = function (err) {
    console.error("Issue in interaction and completion of payment with UPI", err);
}

window["UPI"].acceptPayment(config, successCallback, failureCallback);

Sample response of successful payment

{
  "ApprovalRefNo": "932413452",
  "Status": "SUCCESS",
  "message": "txnId=764900774.690841&responseCode=00&Status=SUCCESS&txnRef=417855597.31908274&ApprovalRefNo=932413452",
  "responseCode": "00",
  "status": "SUCCESS",
  "txnId": "764900774.690841",
  "txnRef": "417855597.31908274",
  "appId": "com.phonepe.app.preprod",
  "appName": "PhonePe Preprod",
}

Sample response of failure payment

{
  "Status": "FAILURE",
  "message": "txnId=901818401.3087038&responseCode=ZD&Status=FAILURE&txnRef=654595701.7025663",
  "responseCode": "ZD",
  "status": "FAILURE",
  "txnId": "901818401.3087038",
  "txnRef": "654595701.7025663",
  "appId": "com.phonepe.app.preprod",
  "appName": "PhonePe Preprod",
}

Release Notes:

1.0.0:

Initial Release of cordova plugin for upi transaction

1.0.1:

Added capability to fetch all UPI supported apps rather than predefined list (added in 1.0.0v) Added capability to send upi app details used for payment, in response.

1.0.2:

Bug fix related to defensive check on "Status" field.

1.0.3:

Bug fix to handle Empty Param from UPI apps in response. Issue

1.0.4:

Bug fix

cordova-plugin-upi's People

Contributors

arunyogi avatar the-deadshot avatar vishwanath-ca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cordova-plugin-upi's Issues

android 32 not support please new update

java.lang.IllegalArgumentException: com.testby.shiba: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at com.cordova.upi.UPIPlugin.acceptPayment(UPIPlugin.java:150)
at com.cordova.upi.UPIPlugin.execute(UPIPlugin.java:85)
at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
at org.apache.cordova.PluginManager.exec(PluginManager.java:146)
at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:339)
at android.os.Looper.loopOnce(Looper.java:186)
at android.os.Looper.loop(Looper.java:334)
at android.os.HandlerThread.run(HandlerThread.java:67)

TypeError: callback.success.apply is not a function

I have put this code in ionic 5 app. I put the code inside button click event. but I am getting the error "TypeError: callback.success.apply is not a function". Screen-shot is also attached. Can you please guide me how to resolve this error?
error

No Response after successful payment through BHIM app

I am not getting any response either in sucess or failure callback even after successful payment through BHIM app. In freecharge after clicking on pay button returns back to app without any response and unable to make payment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.