node-paytmpg 5.1.4 → 5.2.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.
|
@@ -8,7 +8,7 @@ class OpenMoney {
|
|
|
8
8
|
npconfig.accesskey = npconfig.KEY
|
|
9
9
|
npconfig.secretkey = npconfig.SECRET
|
|
10
10
|
npconfig.url = npconfig.open_money_url
|
|
11
|
-
npconfig.script_url = (npconfig.url.indexOf("sandbox") == -1) ? "https://payments.open.money/layer" : "https://sandbox-payments.open.money/layer"
|
|
11
|
+
npconfig.script_url = (npconfig.url && npconfig.url.indexOf("sandbox") == -1) ? "https://payments.open.money/layer" : "https://sandbox-payments.open.money/layer"
|
|
12
12
|
this.config = npconfig;
|
|
13
13
|
|
|
14
14
|
}
|
|
@@ -511,4 +511,4 @@ function ksort(obj) {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
|
|
514
|
-
module.exports = OpenMoney;
|
|
514
|
+
module.exports = OpenMoney;
|
|
@@ -195,7 +195,9 @@ module.exports = function (app, callbacks) {
|
|
|
195
195
|
};
|
|
196
196
|
let checksum = await PaytmChecksum.generateSignature(JSON.stringify(initTxnbody), config.KEY)
|
|
197
197
|
let initTxnUrl = config.paytm_url + `/theia/api/v1/initiateTransaction?mid=${params['MID']}&orderId=${params['ORDER_ID']}`;
|
|
198
|
-
|
|
198
|
+
if(config.mode){
|
|
199
|
+
initTxnbody["enablePaymentMode"] = JSON.parse(config.mode)
|
|
200
|
+
}
|
|
199
201
|
request.post(
|
|
200
202
|
initTxnUrl,
|
|
201
203
|
{
|
|
@@ -216,6 +218,18 @@ module.exports = function (app, callbacks) {
|
|
|
216
218
|
body.body.resultInfo &&
|
|
217
219
|
body.body.resultInfo.resultStatus == "S") {
|
|
218
220
|
|
|
221
|
+
let paytmJsToken = {}
|
|
222
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
223
|
+
paytmJsToken.ORDERID = params['ORDER_ID']
|
|
224
|
+
paytmJsToken.ORDER_ID = params['ORDER_ID']
|
|
225
|
+
paytmJsToken.CANCELLED = "cancelled"
|
|
226
|
+
paytmJsToken.TOKEN = body.body.txnToken
|
|
227
|
+
paytmJsToken.TXN_AMOUNT = params['TXN_AMOUNT']
|
|
228
|
+
paytmJsToken.MID = params['MID']
|
|
229
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
230
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
231
|
+
|
|
232
|
+
|
|
219
233
|
|
|
220
234
|
let paytmJsCheckouHtml = `<html>
|
|
221
235
|
<head>
|
|
@@ -324,6 +338,9 @@ module.exports = function (app, callbacks) {
|
|
|
324
338
|
|
|
325
339
|
</body>
|
|
326
340
|
</html>`
|
|
341
|
+
if (res.token) {
|
|
342
|
+
res.token(paytmJsToken)
|
|
343
|
+
}
|
|
327
344
|
return res.send(paytmJsCheckouHtml)
|
|
328
345
|
|
|
329
346
|
}
|
|
@@ -341,7 +358,9 @@ module.exports = function (app, callbacks) {
|
|
|
341
358
|
form_fields += "<input type='hidden' name='" + x + "' value='" + errorResp[x] + "' >";
|
|
342
359
|
}
|
|
343
360
|
form_fields += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "' >";
|
|
344
|
-
|
|
361
|
+
if (res.token) {
|
|
362
|
+
res.token(undefined)
|
|
363
|
+
}
|
|
345
364
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
346
365
|
res.write(`<html>
|
|
347
366
|
|
|
@@ -838,6 +857,66 @@ module.exports = function (app, callbacks) {
|
|
|
838
857
|
|
|
839
858
|
|
|
840
859
|
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
module.createTxnToken = (req, res) => {
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
module.createTxn(req, {
|
|
866
|
+
send: function (createTxnResult) {
|
|
867
|
+
|
|
868
|
+
// console.log(createTxnResult)
|
|
869
|
+
|
|
870
|
+
req.body.NAME = createTxnResult.name
|
|
871
|
+
req.body.EMAIL = createTxnResult.email
|
|
872
|
+
req.body.MOBILE_NO = createTxnResult.phone
|
|
873
|
+
req.body.ORDER_ID = createTxnResult.orderId
|
|
874
|
+
module.init(req, {
|
|
875
|
+
render: (renderPath, initResultRender) => {
|
|
876
|
+
// console.log(initResultRender)
|
|
877
|
+
req.body = initResultRender
|
|
878
|
+
|
|
879
|
+
module.init(req, {
|
|
880
|
+
send: (initResult) => {
|
|
881
|
+
|
|
882
|
+
},
|
|
883
|
+
status: (status) => {
|
|
884
|
+
console.log('status', status)
|
|
885
|
+
|
|
886
|
+
},
|
|
887
|
+
token: (tokenData) => {
|
|
888
|
+
if (!tokenData) {
|
|
889
|
+
res.status(500)
|
|
890
|
+
res.send('Something went wrong. Please try again later.')
|
|
891
|
+
}
|
|
892
|
+
else
|
|
893
|
+
{
|
|
894
|
+
tokenData.payurl = createTxnResult.payurl;
|
|
895
|
+
res.send(tokenData)
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
render: (renderPath2, init2ResultRender) => {
|
|
899
|
+
console.log('init2ResultRender', init2ResultRender)
|
|
900
|
+
},
|
|
901
|
+
end: (initResultWrite) => {
|
|
902
|
+
console.log('initResultWrite', initResultWrite)
|
|
903
|
+
},
|
|
904
|
+
write: (initResultWrite) => {
|
|
905
|
+
console.log('initResultWrite', initResultWrite)
|
|
906
|
+
},
|
|
907
|
+
writeHead: (initResultWriteHead) => {
|
|
908
|
+
console.log('initResultWriteHead', initResultWriteHead)
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
})
|
|
912
|
+
|
|
913
|
+
}
|
|
914
|
+
})
|
|
915
|
+
},
|
|
916
|
+
redirect: res.redirect
|
|
917
|
+
})
|
|
918
|
+
|
|
919
|
+
|
|
841
920
|
};
|
|
842
921
|
|
|
843
922
|
|
|
@@ -65,6 +65,7 @@ module.exports = (app, express, callbacks) => {
|
|
|
65
65
|
router.all('/callback', pc.callback)
|
|
66
66
|
router.all('/api/webhook', pc.webhook)
|
|
67
67
|
router.all('/api/status', pc.status)
|
|
68
|
+
router.all('/api/createTxn/token', pc.createTxnToken)
|
|
68
69
|
router.all('/api/createTxn', pc.createTxn)
|
|
69
70
|
|
|
70
71
|
|