upiqr 1.0.32 → 1.0.34

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/package.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "upiqr",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
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
+ "dist",
10
+ "LICENSE",
11
+ "README.md",
12
+ "package.json"
13
+ ],
6
14
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
15
+ "build": "tsc --build"
8
16
  },
9
17
  "repository": {
10
18
  "type": "git",
@@ -22,5 +30,9 @@
22
30
  "license": "MIT",
23
31
  "dependencies": {
24
32
  "qrcode": "^1.4.4"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.5.6",
36
+ "typescript": "^5.2.2"
25
37
  }
26
38
  }
@@ -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
- }