upiqr 1.0.36 → 1.0.40
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.d.ts +2 -26
- package/dist/index.js +2 -20
- package/dist/types/upiqr.d.ts +20 -0
- package/dist/types/upiqr.js +1 -0
- package/dist/utils/helper.d.ts +5 -0
- package/dist/utils/helper.js +17 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type Base64<imageType extends ImageType> = `data:image/${imageType};base64${string}`;
|
|
4
|
-
interface UPIIntentParams {
|
|
5
|
-
payeeVPA?: string;
|
|
6
|
-
payeeName?: string;
|
|
7
|
-
payeeMerchantCode?: string;
|
|
8
|
-
transactionId?: string;
|
|
9
|
-
transactionRef?: string;
|
|
10
|
-
transactionNote?: string;
|
|
11
|
-
amount?: string;
|
|
12
|
-
minimumAmount?: string;
|
|
13
|
-
currency?: string;
|
|
14
|
-
transactionRefUrl?: string;
|
|
15
|
-
}
|
|
16
|
-
interface UPIIntentResult {
|
|
17
|
-
qr: string;
|
|
18
|
-
intent: string;
|
|
19
|
-
error: string;
|
|
20
|
-
}
|
|
21
|
-
declare function validateParams({ pa, pn }: {
|
|
22
|
-
pa: string | undefined;
|
|
23
|
-
pn: string | undefined;
|
|
24
|
-
}): string;
|
|
25
|
-
declare function buildUrl(this: string, params: object): string;
|
|
26
|
-
declare function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: me, transactionId: tid, transactionRef: tr, transactionNote: tn, amount: am, minimumAmount: mam, currency: cu, transactionRefUrl, }: UPIIntentParams): Promise<UPIIntentResult | Error>;
|
|
1
|
+
import { UPIIntentParams, UPIIntentResult } from "./types/upiqr";
|
|
2
|
+
export default function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: me, transactionId: tid, transactionRef: tr, transactionNote: tn, amount: am, minimumAmount: mam, currency: cu, }: UPIIntentParams): Promise<UPIIntentResult>;
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
const QRCode = require("qrcode");
|
|
3
|
-
function
|
|
4
|
-
let error = '';
|
|
5
|
-
if (!pa || !pn)
|
|
6
|
-
return "Virtual Payee's Address/Payee's Name is compulsory";
|
|
7
|
-
if ((pa === null || pa === void 0 ? void 0 : pa.length) < 5 || (pn === null || pn === void 0 ? void 0 : pn.length) < 4)
|
|
8
|
-
return "Virtual Payee's Address/Payee's Name is too short.";
|
|
9
|
-
return error;
|
|
10
|
-
}
|
|
11
|
-
function buildUrl(params) {
|
|
12
|
-
let url = this, qs = "";
|
|
13
|
-
for (let [key, value] of Object.entries(params))
|
|
14
|
-
qs += encodeURIComponent(key) + "=" + encodeURIComponent(value) + "&";
|
|
15
|
-
if (qs.length > 0)
|
|
16
|
-
url = url + qs;
|
|
17
|
-
return url;
|
|
18
|
-
}
|
|
19
|
-
function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: me, transactionId: tid, transactionRef: tr, transactionNote: tn, amount: am, minimumAmount: mam, currency: cu, transactionRefUrl: url, }) {
|
|
2
|
+
export default function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: me, transactionId: tid, transactionRef: tr, transactionNote: tn, amount: am, minimumAmount: mam, currency: cu, }) {
|
|
20
3
|
return new Promise((resolve, reject) => {
|
|
21
4
|
let error = validateParams({ pa, pn });
|
|
22
5
|
if (error)
|
|
@@ -42,8 +25,7 @@ function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: me, transaction
|
|
|
42
25
|
QRCode.toDataURL(intent, (err, qr) => {
|
|
43
26
|
if (err)
|
|
44
27
|
reject(new Error("Unable to generate UPI QR Code."));
|
|
45
|
-
resolve({ qr, intent
|
|
28
|
+
resolve({ qr, intent });
|
|
46
29
|
});
|
|
47
30
|
});
|
|
48
31
|
}
|
|
49
|
-
exports.default = upiqr;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type ImageType = 'png' | 'jpeg';
|
|
2
|
+
export type Base64<imageType extends ImageType> = `data:image/${imageType};base64${string}`;
|
|
3
|
+
export interface UPIIntentParams {
|
|
4
|
+
payeeVPA: string;
|
|
5
|
+
payeeName: string;
|
|
6
|
+
payeeMerchantCode?: string;
|
|
7
|
+
transactionId?: string;
|
|
8
|
+
transactionRef?: string;
|
|
9
|
+
transactionNote?: string;
|
|
10
|
+
amount?: string;
|
|
11
|
+
minimumAmount?: string;
|
|
12
|
+
currency?: string;
|
|
13
|
+
transactionRefUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
interface QRResult {
|
|
16
|
+
qr: string;
|
|
17
|
+
intent: string;
|
|
18
|
+
}
|
|
19
|
+
export type UPIIntentResult = QRResult | Error;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function validateParams({ pa, pn }) {
|
|
3
|
+
let error = '';
|
|
4
|
+
if (!pa || !pn)
|
|
5
|
+
return "Virtual Payee's Address/Payee's Name is compulsory";
|
|
6
|
+
if ((pa === null || pa === void 0 ? void 0 : pa.length) < 5 || (pn === null || pn === void 0 ? void 0 : pn.length) < 4)
|
|
7
|
+
return "Virtual Payee's Address/Payee's Name is too short.";
|
|
8
|
+
return error;
|
|
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)
|
|
15
|
+
url = url + qs;
|
|
16
|
+
return url;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "upiqr",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
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",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist",
|
|
9
10
|
"LICENSE",
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
"package.json"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
|
-
"build": "tsc
|
|
15
|
+
"build": "tsc"
|
|
15
16
|
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|