upiqr 1.0.31 → 1.0.33
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/README.md +8 -0
- package/package.json +16 -3
- package/.github/workflows/main.yml +0 -20
- package/index.js +0 -58
package/README.md
CHANGED
|
@@ -7,6 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
Generate NPCI's UPI QR code (BASE64) along with UPI intent link, By using it any payment is possible from UPI enabled apps.
|
|
9
9
|
|
|
10
|
+
## Supports
|
|
11
|
+
|
|
12
|
+
<div id="header" align="center">
|
|
13
|
+
<img src="https://raw.githubusercontent.com/bhar4t/bhar4t/master/public/img/upis.png" width="300"/>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<br/>
|
|
17
|
+
|
|
10
18
|
This package will work on client and server.
|
|
11
19
|
|
|
12
20
|
```js
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "upiqr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.33",
|
|
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
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"README.md",
|
|
13
|
+
"package.json"
|
|
14
|
+
],
|
|
6
15
|
"scripts": {
|
|
7
|
-
"
|
|
16
|
+
"build": "tsc --build"
|
|
8
17
|
},
|
|
9
18
|
"repository": {
|
|
10
19
|
"type": "git",
|
|
@@ -22,5 +31,9 @@
|
|
|
22
31
|
"license": "MIT",
|
|
23
32
|
"dependencies": {
|
|
24
33
|
"qrcode": "^1.4.4"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.5.6",
|
|
37
|
+
"typescript": "^5.2.2"
|
|
25
38
|
}
|
|
26
39
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: upiqr package
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish-gpr:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v2
|
|
13
|
-
- uses: actions/setup-node@v1
|
|
14
|
-
with:
|
|
15
|
-
node-version: 12
|
|
16
|
-
registry-url: https://registry.npmjs.org
|
|
17
|
-
- run: npm install
|
|
18
|
-
- run: npm publish --access public
|
|
19
|
-
env:
|
|
20
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
|
package/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const QRCode = require("qrcode")
|
|
2
|
-
|
|
3
|
-
function validateParams({ pa, pn }) {
|
|
4
|
-
let error = false
|
|
5
|
-
if (!pa || !pn) error = "Virtual Payee's Address/Payee's Name is compulsory"
|
|
6
|
-
if (pa?.length < 5 || pn?.length < 4) error = "Virtual Payee's Address/Payee's Name is too short."
|
|
7
|
-
return error
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function buildUrl(params) {
|
|
11
|
-
let url = this, qs = ""
|
|
12
|
-
for(let [key, value] of Object.entries(params))
|
|
13
|
-
qs += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&"
|
|
14
|
-
if (qs.length > 0) url = url + qs
|
|
15
|
-
return url
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function upiqr ({
|
|
19
|
-
payeeVPA: pa,
|
|
20
|
-
payeeName: pn,
|
|
21
|
-
payeeMerchantCode: me,
|
|
22
|
-
transactionId: tid,
|
|
23
|
-
transactionRef: tr,
|
|
24
|
-
transactionNote: tn,
|
|
25
|
-
amount: am,
|
|
26
|
-
minimumAmount: mam,
|
|
27
|
-
currency: cu,
|
|
28
|
-
transactionRefUrl: url,
|
|
29
|
-
}) {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
|
|
32
|
-
let error = validateParams({ pa, pn })
|
|
33
|
-
if (error) reject(new Error(error))
|
|
34
|
-
|
|
35
|
-
let intent = "upi://pay?"
|
|
36
|
-
if (pa) intent = buildUrl.call(intent, { pa, pn })
|
|
37
|
-
if (am) intent = buildUrl.call(intent, { am })
|
|
38
|
-
if (mam) intent = buildUrl.call(intent, { mam })
|
|
39
|
-
if (cu) intent = buildUrl.call(intent, { cu })
|
|
40
|
-
if (me) intent = buildUrl.call(intent, { me })
|
|
41
|
-
if (tid) intent = buildUrl.call(intent, { tid })
|
|
42
|
-
if (tr) intent = buildUrl.call(intent, { tr }) // // tr: transactionRef upto 35 digits
|
|
43
|
-
if (tn) intent = buildUrl.call(intent, { tn })
|
|
44
|
-
intent = intent.substring(0, intent.length-1)
|
|
45
|
-
|
|
46
|
-
QRCode.toDataURL(
|
|
47
|
-
intent,
|
|
48
|
-
(err, qr) => {
|
|
49
|
-
if (err) reject(new Error("Unable to generate UPI QR Code."))
|
|
50
|
-
resolve({ qr, intent })
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = {
|
|
57
|
-
upiqr
|
|
58
|
-
}
|