node-paytmpg 5.2.3 → 5.2.4
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var crypt = require('./crypt');
|
|
4
4
|
var util = require('util');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
|
+
const PaytmChecksum = require('./PaytmChecksum.js');
|
|
6
7
|
|
|
7
8
|
//mandatory flag: when it set, only mandatory parameters are added to checksum
|
|
8
9
|
|
|
@@ -11,14 +12,24 @@ function paramsToString(params, mandatoryflag) {
|
|
|
11
12
|
var tempKeys = Object.keys(params);
|
|
12
13
|
tempKeys.sort();
|
|
13
14
|
tempKeys.forEach(function (key) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (n == true) {
|
|
17
|
-
params[key] = "";
|
|
15
|
+
if (!params[key]) {
|
|
16
|
+
return
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
try {
|
|
19
|
+
var n = params[key].includes("REFUND");
|
|
20
|
+
var m = params[key].includes("|");
|
|
21
|
+
if (n == true) {
|
|
22
|
+
params[key] = "";
|
|
23
|
+
}
|
|
24
|
+
if (m == true) {
|
|
25
|
+
params[key] = "";
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
20
28
|
params[key] = "";
|
|
29
|
+
console.log(e)
|
|
21
30
|
}
|
|
31
|
+
|
|
32
|
+
|
|
22
33
|
if (key !== 'CHECKSUMHASH') {
|
|
23
34
|
if (params[key] === 'null') params[key] = '';
|
|
24
35
|
if (!mandatoryflag || mandatoryParams.indexOf(key) !== -1) {
|
|
@@ -31,6 +42,9 @@ function paramsToString(params, mandatoryflag) {
|
|
|
31
42
|
|
|
32
43
|
|
|
33
44
|
function genchecksum(params, key, cb) {
|
|
45
|
+
let checksum = PaytmChecksum.generateSignature(params, key);
|
|
46
|
+
cb(undefined, checksum)
|
|
47
|
+
return checksum;
|
|
34
48
|
var data = paramsToString(params);
|
|
35
49
|
crypt.gen_salt(4, function (err, salt) {
|
|
36
50
|
var sha256 = crypto.createHash('sha256').update(data + salt).digest('hex');
|
|
@@ -53,6 +67,7 @@ function genchecksumbystring(params, key, cb) {
|
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
function verifychecksum(params, key, checksumhash) {
|
|
70
|
+
return PaytmChecksum.verifySignature(params, key, checksumhash)
|
|
56
71
|
var data = paramsToString(params, false);
|
|
57
72
|
|
|
58
73
|
//TODO: after PG fix on thier side remove below two lines
|
|
@@ -193,10 +193,10 @@ module.exports = function (app, callbacks) {
|
|
|
193
193
|
"email": params['EMAIL']
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
if(config.mode){
|
|
197
|
-
initTxnbody["enablePaymentMode"] =
|
|
196
|
+
if (config.mode) {
|
|
197
|
+
initTxnbody["enablePaymentMode"] = JSON.parse(config.mode)
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
let checksum = await PaytmChecksum.generateSignature(JSON.stringify(initTxnbody), config.KEY)
|
|
201
201
|
let initTxnUrl = config.paytm_url + `/theia/api/v1/initiateTransaction?mid=${params['MID']}&orderId=${params['ORDER_ID']}`;
|
|
202
202
|
|
|
@@ -891,11 +891,10 @@ module.exports = function (app, callbacks) {
|
|
|
891
891
|
res.status(500)
|
|
892
892
|
res.send('Something went wrong. Please try again later.')
|
|
893
893
|
}
|
|
894
|
-
else
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
}
|
|
894
|
+
else {
|
|
895
|
+
tokenData.payurl = createTxnResult.payurl;
|
|
896
|
+
res.send(tokenData)
|
|
897
|
+
}
|
|
899
898
|
},
|
|
900
899
|
render: (renderPath2, init2ResultRender) => {
|
|
901
900
|
console.log('init2ResultRender', init2ResultRender)
|