upiqr 1.3.17 → 1.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +12 -12
  2. package/dist/index.js +1 -8
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -35,18 +35,18 @@ This package will work on client and server.
35
35
 
36
36
  ### Fields detail:
37
37
 
38
- | Fields | Description | Required |
39
- |-------------------|---------------------------------------------------|-----------|
40
- | payeeVPA | VPA address from UPI payment account | Mandatory |
41
- | payeeName | Merchant Name registered in UPI payment account | Mandatory |
42
- | payeeMerchantCode | Merchant Code from UPI payment account | Optional |
43
- | transactionId | Unique transaction id for merchant's reference | Optional |
44
- | transactionRef | Unique transaction id for merchant's reference | Optional |
45
- | transactionNote | Note will appear in payment app while transaction | Optional |
46
- | amount | Amount | Optional |
47
- | minimumAmount | Minimum amount that has to be transferred | Optional |
48
- | currency | Currency of amount (default: INR) | Optional |
49
- | transactionRefUrl | URL for the order | Optional |
38
+ | Fields | Description | Required |
39
+ |--------------------|---------------------------------------------------|-----------|
40
+ | `payeeVPA` | UPI ID of the payee (e.g., `example@upi`). | Yes |
41
+ | `payeeName` | Registered name of the payee (e.g., `John Doe`). | Yes |
42
+ | `payeeMerchantCode`| Merchant Code from UPI payment account | No |
43
+ | `transactionId` | Unique transaction id for merchant's reference | No |
44
+ | `transactionRef` | Unique transaction id for merchant's reference | No |
45
+ | `transactionNote` | Note for the payment (e.g., `Electricity Bill`). | No |
46
+ | `amount` | Amount | No |
47
+ | `minimumAmount` | Amount to be paid (e.g., `100.00` or `499`). | No |
48
+ | `currency` | Currency of amount (default: `INR`) | No |
49
+ | `transactionRefUrl`| URL for the order | No |
50
50
 
51
51
 
52
52
  In table, fields requirement column is based on static QR, For dynamic QR you need to change more fields along with `payeeVPA` and `payeeName`.
package/dist/index.js CHANGED
@@ -1,8 +1 @@
1
- import QRCode from'qrcode';function validate({pa,pn}){if(!pa||!pn)
2
- return"Virtual payee's address/name is compulsory";if(pa.length<5||pn.length<4)
3
- return"Virtual payee's address/name is too short.";return'';}
4
- function buildUrl(params){let qs="";for(let[key,value]of Object.entries(params)){if(value)
5
- qs+=`${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;}
6
- return"upi://pay?"+qs.slice(0,-1);}
7
- export default function upiqr({payeeVPA:pa,payeeName:pn,payeeMerchantCode:mc,transactionId:tid,transactionRef:tr,transactionNote:tn,amount:am,minimumAmount:mam,currency:cu,},qrOptions){const params={pa,pn,am,mam,cu,mc,tid,tr,tn};const error=validate(params);if(error)
8
- return Promise.reject(new Error(error));const intent=buildUrl(params);return new Promise((resolve,reject)=>{QRCode.toDataURL(intent,qrOptions).then((base64Data)=>resolve({qr:base64Data,intent})).catch(err=>reject(new Error("Unable to generate UPI QR Code.\n"+err)));});}
1
+ import QRCode from"qrcode";function validate({pa:e,pn:t}){if(!e||!t)return"Virtual payee's address/name is compulsory";if(e.length<5||t.length<4)return"Virtual payee's address/name is too short.";return""}export default function upiqr({payeeVPA:e,payeeName:t,payeeMerchantCode:n,transactionId:r,transactionRef:a,transactionNote:o,amount:i,minimumAmount:c,currency:s},u){const m={pa:e,pn:t,am:i,mam:c,cu:s,mc:n,tid:r,tr:a,tn:o};const p=validate(m);if(p)return Promise.reject(new Error(p));const d=(e=>{const t=new URLSearchParams;for(const[n,r]of Object.entries(e)){if(r)t.append(n,r)}return`upi://pay?${t.toString()}`})(m);return new Promise((t,n)=>{QRCode.toDataURL(d,u).then(e=>t({qr:e,intent:d})).catch(e=>n(new Error("Unable to generate UPI QR Code.\n"+e)))})}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "upiqr",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
4
4
  "description": "Generate NPCI's UPI QR code along with UPI intent link, By using it any payment is possible from UPI enabled apps.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "package.json"
13
13
  ],
14
14
  "scripts": {
15
- "minify": "jsmin -o dist/index.d.ts dist/index.d.ts && jsmin -o dist/index.js dist/index.js && jsmin -o dist/types/upiqr.d.ts dist/types/upiqr.d.ts",
15
+ "minify": "jsmin -o dist/types/upiqr.d.ts dist/types/upiqr.d.ts && jsmin -o dist/index.d.ts dist/index.d.ts && uglifyjs -o dist/index.js dist/index.js --mangle",
16
16
  "build": "tsc && npm run minify"
17
17
  },
18
18
  "repository": {
@@ -45,7 +45,6 @@
45
45
  "devDependencies": {
46
46
  "@types/node": "^20.5.6",
47
47
  "@types/qrcode": "^1.5.1",
48
- "jsmin": "^1.0.1",
49
48
  "typescript": "^5.2.2"
50
49
  }
51
50
  }