upiqr 1.3.18 → 1.3.20
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.
- package/dist/index.js +1 -8
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import QRCode from
|
|
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:r,transactionId:n,transactionRef:a,transactionNote:o,amount:i,minimumAmount:c,currency:s},u){const m={pa:e,pn:t,am:i,mam:c,cu:s,mc:r,tid:n,tr:a,tn:o};const p=validate(m);if(p)return Promise.reject(new Error(p));const d=(e=>{const t=new URLSearchParams(Object.entries(e).filter(([e,t])=>t));return`upi://pay?${t.toString()}`})(m);return new Promise((t,r)=>{QRCode.toDataURL(d,u).then(e=>t({qr:e,intent:d})).catch(e=>r(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.
|
|
3
|
+
"version": "1.3.20",
|
|
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/
|
|
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
|
}
|