Code Monkey home page Code Monkey logo

upi-link's Introduction

upi-link

Simple npm module to generate UPI deep-links, based on UPI Linking Specifications Version 1.5.1 ๐Ÿค‘

installation

$ npm i upi-link

API

Factory methods

Function Name Input params Returns
Satic VPA ID(M), Payee Name(M), Amount(O) Builder object
Dynamic VPA ID(M), Payee Name(M), Amount(M) Builder object
SaticP VPA ID(M), Payee Name(M), Amount(O) Promise
DynamicP VPA ID(M), Payee Name(M), Amount(M) Promise

Setter methods

  1. setMerchant( mc, ti) : Set merchant takes tow parameter Merchant ID (mandatory) and Transaction ID (optional). Both the ID should be generated by the PSP, and should be passed as it is.

  2. setTxRef( refid, note) : Set merchant takes tow parameter Transaction Reference ID (mandatory) and Transaction Note (optional). Transaction Reference ID should generated by you. It could be order number, subscription number, Bill ID, booking ID, insurance renewal reference, etc.

    • Note : Setting up TxRef is mandatory, when either Merchant is set or the URL type is Dynamic
  3. setMinAmount(amount) : Minimum Amount will only be set when Transaction Amount is already set and the Minimum Amount is different from the Transaction Amount.

  4. setCallback(url) : This should be a URL when clicked provides customer with further transaction details like complete bill details, bill copy, order copy, ticket details, etc. This can also be used to deliver digital goods.

    • Note : Setting up Callback URL doesn't guarantee the it will be called by the PSPs post transaction. Call to this URL is subjected white listing by the PSPs.

Build Method

  • getLink() : This will return a QR code friendly formated UPI URI string is all conditions are met.

Chaining

Build object chaining

const upi = require('upi-link')

let uri = upi.Static("xxxxx@ybl", "Xyz Abc")
.setMerchant("ALPHABET")
.setTxRef('INV001')
.getLink()

console.log('URI:  ',uri);

Promise chaining โ”ผ

const upi = require('upi-link')

upi.DynamicP("xxxxx@ybl", "Xyz Abc", 100000)
.setMinAmount(1000)
.setTxRef('INV001')
.getLink()
.then( uri => console.log('URI:  ',uri))
.catch( err => console.error('Error: ',err.message))

โ”ผ Promise chaining is the recomended method. If you are using plain build object you should handled errors asseted by each metods.

upi-link's People

Contributors

msbadar avatar souravray avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

upi-link's Issues

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.