node-paytmpg 5.2.6 → 5.3.1
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.
|
@@ -42,9 +42,10 @@ function paramsToString(params, mandatoryflag) {
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
function genchecksum(params, key, cb) {
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
let checksumPromise = PaytmChecksum.generateSignature(params, key).then(checksum => {
|
|
46
|
+
cb(undefined, checksum)
|
|
47
|
+
})
|
|
48
|
+
return checksumPromise;
|
|
48
49
|
var data = paramsToString(params);
|
|
49
50
|
crypt.gen_salt(4, function (err, salt) {
|
|
50
51
|
var sha256 = crypto.createHash('sha256').update(data + salt).digest('hex');
|
|
@@ -641,7 +641,7 @@ module.exports = function (app, callbacks) {
|
|
|
641
641
|
res.send({ message: "Transaction Not Found !", ORDERID: req.body.ORDERID, TXNID: req.body.TXNID })
|
|
642
642
|
return;
|
|
643
643
|
}
|
|
644
|
-
if (objForUpdate.status != ("INITIATED") && objForUpdate.status != ("TXN_PENDING")) {
|
|
644
|
+
if (objForUpdate.status != ("INITIATED") && objForUpdate.status != ("TXN_PENDING") && objForUpdate.status != ("PENDING")) {
|
|
645
645
|
objForUpdate.readonly = "readonly"
|
|
646
646
|
objForUpdate.action = config.homepage
|
|
647
647
|
res.render(vp + "result.hbs", objForUpdate);
|
|
@@ -676,13 +676,23 @@ module.exports = function (app, callbacks) {
|
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
module.callback = async (req, res) => {
|
|
679
|
-
console.log("request_data ", req.originalUrl, JSON.stringify(req.
|
|
679
|
+
console.log("request_data ", req.originalUrl, JSON.stringify(req.body))
|
|
680
680
|
|
|
681
681
|
var result = false;
|
|
682
682
|
let isCancelled = false;
|
|
683
683
|
if (config.paytm_url) {
|
|
684
684
|
var checksumhash = req.body.CHECKSUMHASH;
|
|
685
|
-
|
|
685
|
+
if (checksumhash) {
|
|
686
|
+
result = checksum_lib.verifychecksum(req.body, config.KEY, checksumhash);
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
let liveStatus = await new Promise((resolve, reject) => {
|
|
690
|
+
getStatusFromPaytm(req.body, req.body.ORDERID, (paytmResponse) => {
|
|
691
|
+
resolve(paytmResponse)
|
|
692
|
+
})
|
|
693
|
+
})
|
|
694
|
+
result = liveStatus.STATUS == req.body.STATUS;
|
|
695
|
+
}
|
|
686
696
|
if (req.body.STATUS == 'TXN_FAILURE' && req.body.CANCELLED == "cancelled" && req.body.TXNID) {
|
|
687
697
|
isCancelled = true;
|
|
688
698
|
}
|
|
@@ -742,7 +752,7 @@ module.exports = function (app, callbacks) {
|
|
|
742
752
|
|
|
743
753
|
|
|
744
754
|
|
|
745
|
-
console.log("request_data ", req.originalUrl, JSON.stringify(req.
|
|
755
|
+
console.log("request_data ", req.originalUrl, JSON.stringify(req.body))
|
|
746
756
|
|
|
747
757
|
if (config.paytm_url) {
|
|
748
758
|
module.callback(req, res)
|
|
@@ -971,26 +981,7 @@ module.exports = function (app, callbacks) {
|
|
|
971
981
|
}
|
|
972
982
|
|
|
973
983
|
if (config.paytm_url) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
request.post(
|
|
977
|
-
config.paytm_url + "/order/status",
|
|
978
|
-
{ json: { MID: config.MID, ORDERID: req.body.ORDER_ID, CHECKSUMHASH: checksum, } },
|
|
979
|
-
function (error, response, body) {
|
|
980
|
-
|
|
981
|
-
if (!error && response.statusCode == 200) {
|
|
982
|
-
// console.log(body);
|
|
983
|
-
var paytmResponse = JSON.parse(JSON.stringify(body))
|
|
984
|
-
onStatusUpdate(paytmResponse)
|
|
985
|
-
}
|
|
986
|
-
else {
|
|
987
|
-
console.log('ERROR:::', error, '\n', response);
|
|
988
|
-
res.status(500)
|
|
989
|
-
res.send({ message: "Error Occured !", ORDERID: req.body.ORDER_ID })
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
);
|
|
993
|
-
});
|
|
984
|
+
getStatusFromPaytm(params, req.body.ORDER_ID, onStatusUpdate)
|
|
994
985
|
}
|
|
995
986
|
else if (config.razor_url) {
|
|
996
987
|
let result = await razorPayInstance.orders.fetch(req.body.ORDER_ID)
|
|
@@ -1051,5 +1042,26 @@ module.exports = function (app, callbacks) {
|
|
|
1051
1042
|
|
|
1052
1043
|
}
|
|
1053
1044
|
|
|
1045
|
+
function getStatusFromPaytm(params, orderId, cb) {
|
|
1046
|
+
checksum_lib.genchecksum(params, config.KEY, function (err, checksum) {
|
|
1047
|
+
|
|
1048
|
+
request.post(
|
|
1049
|
+
config.paytm_url + "/order/status",
|
|
1050
|
+
{ json: { MID: config.MID, ORDERID: orderId, CHECKSUMHASH: checksum, } },
|
|
1051
|
+
function (error, response, body) {
|
|
1052
|
+
|
|
1053
|
+
if (!error && response.statusCode == 200) {
|
|
1054
|
+
var paytmResponse = JSON.parse(JSON.stringify(body))
|
|
1055
|
+
cb(paytmResponse)
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
console.log('ERROR:::', error, '\n', response);
|
|
1059
|
+
cb({ message: "Error Occured !", ORDERID: orderId })
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1054
1066
|
return module;
|
|
1055
1067
|
}
|