node-paytmpg 5.1.5 → 5.2.2
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.
|
@@ -193,6 +193,10 @@ module.exports = function (app, callbacks) {
|
|
|
193
193
|
"email": params['EMAIL']
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
+
if(config.mode){
|
|
197
|
+
initTxnbody["enablePaymentMode"] = JSON.parse(config.mode)
|
|
198
|
+
}
|
|
199
|
+
|
|
196
200
|
let checksum = await PaytmChecksum.generateSignature(JSON.stringify(initTxnbody), config.KEY)
|
|
197
201
|
let initTxnUrl = config.paytm_url + `/theia/api/v1/initiateTransaction?mid=${params['MID']}&orderId=${params['ORDER_ID']}`;
|
|
198
202
|
|
|
@@ -216,6 +220,18 @@ module.exports = function (app, callbacks) {
|
|
|
216
220
|
body.body.resultInfo &&
|
|
217
221
|
body.body.resultInfo.resultStatus == "S") {
|
|
218
222
|
|
|
223
|
+
let paytmJsToken = {}
|
|
224
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
225
|
+
paytmJsToken.ORDERID = params['ORDER_ID']
|
|
226
|
+
paytmJsToken.ORDER_ID = params['ORDER_ID']
|
|
227
|
+
paytmJsToken.CANCELLED = "cancelled"
|
|
228
|
+
paytmJsToken.TOKEN = body.body.txnToken
|
|
229
|
+
paytmJsToken.TXN_AMOUNT = params['TXN_AMOUNT']
|
|
230
|
+
paytmJsToken.MID = params['MID']
|
|
231
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
232
|
+
paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
|
|
233
|
+
|
|
234
|
+
|
|
219
235
|
|
|
220
236
|
let paytmJsCheckouHtml = `<html>
|
|
221
237
|
<head>
|
|
@@ -324,6 +340,9 @@ module.exports = function (app, callbacks) {
|
|
|
324
340
|
|
|
325
341
|
</body>
|
|
326
342
|
</html>`
|
|
343
|
+
if (res.token) {
|
|
344
|
+
res.token(paytmJsToken)
|
|
345
|
+
}
|
|
327
346
|
return res.send(paytmJsCheckouHtml)
|
|
328
347
|
|
|
329
348
|
}
|
|
@@ -341,7 +360,9 @@ module.exports = function (app, callbacks) {
|
|
|
341
360
|
form_fields += "<input type='hidden' name='" + x + "' value='" + errorResp[x] + "' >";
|
|
342
361
|
}
|
|
343
362
|
form_fields += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "' >";
|
|
344
|
-
|
|
363
|
+
if (res.token) {
|
|
364
|
+
res.token(undefined)
|
|
365
|
+
}
|
|
345
366
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
346
367
|
res.write(`<html>
|
|
347
368
|
|
|
@@ -838,6 +859,66 @@ module.exports = function (app, callbacks) {
|
|
|
838
859
|
|
|
839
860
|
|
|
840
861
|
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
module.createTxnToken = (req, res) => {
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
module.createTxn(req, {
|
|
868
|
+
send: function (createTxnResult) {
|
|
869
|
+
|
|
870
|
+
// console.log(createTxnResult)
|
|
871
|
+
|
|
872
|
+
req.body.NAME = createTxnResult.name
|
|
873
|
+
req.body.EMAIL = createTxnResult.email
|
|
874
|
+
req.body.MOBILE_NO = createTxnResult.phone
|
|
875
|
+
req.body.ORDER_ID = createTxnResult.orderId
|
|
876
|
+
module.init(req, {
|
|
877
|
+
render: (renderPath, initResultRender) => {
|
|
878
|
+
// console.log(initResultRender)
|
|
879
|
+
req.body = initResultRender
|
|
880
|
+
|
|
881
|
+
module.init(req, {
|
|
882
|
+
send: (initResult) => {
|
|
883
|
+
|
|
884
|
+
},
|
|
885
|
+
status: (status) => {
|
|
886
|
+
console.log('status', status)
|
|
887
|
+
|
|
888
|
+
},
|
|
889
|
+
token: (tokenData) => {
|
|
890
|
+
if (!tokenData) {
|
|
891
|
+
res.status(500)
|
|
892
|
+
res.send('Something went wrong. Please try again later.')
|
|
893
|
+
}
|
|
894
|
+
else
|
|
895
|
+
{
|
|
896
|
+
tokenData.payurl = createTxnResult.payurl;
|
|
897
|
+
res.send(tokenData)
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
render: (renderPath2, init2ResultRender) => {
|
|
901
|
+
console.log('init2ResultRender', init2ResultRender)
|
|
902
|
+
},
|
|
903
|
+
end: (initResultWrite) => {
|
|
904
|
+
console.log('initResultWrite', initResultWrite)
|
|
905
|
+
},
|
|
906
|
+
write: (initResultWrite) => {
|
|
907
|
+
console.log('initResultWrite', initResultWrite)
|
|
908
|
+
},
|
|
909
|
+
writeHead: (initResultWriteHead) => {
|
|
910
|
+
console.log('initResultWriteHead', initResultWriteHead)
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
})
|
|
914
|
+
|
|
915
|
+
}
|
|
916
|
+
})
|
|
917
|
+
},
|
|
918
|
+
redirect: res.redirect
|
|
919
|
+
})
|
|
920
|
+
|
|
921
|
+
|
|
841
922
|
};
|
|
842
923
|
|
|
843
924
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const PaytmChecksum = require('./checksum/PaytmChecksum.js');
|
|
2
|
+
var request = require('request')
|
|
3
|
+
|
|
4
|
+
let iod = "pay_uuvmP3p282" + Math.floor(Math.random() * 100)
|
|
5
|
+
let initTxnbody = {
|
|
6
|
+
"requestType": "Payment",
|
|
7
|
+
"mid": "mGkXCb73842366174007",
|
|
8
|
+
"websiteName": "DEFAULT",
|
|
9
|
+
"orderId": iod,
|
|
10
|
+
"callbackUrl": "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=" + iod,
|
|
11
|
+
"txnAmount": {
|
|
12
|
+
"value": "10",
|
|
13
|
+
"currency": "INR"
|
|
14
|
+
},
|
|
15
|
+
"userInfo": {
|
|
16
|
+
"custId": "user_q0W8cX7tjt",
|
|
17
|
+
"mobile": "+918527483275",
|
|
18
|
+
"firstName": "shivesh navin",
|
|
19
|
+
"email": "shiveshnavin@gmail.com"
|
|
20
|
+
},
|
|
21
|
+
"enablePaymentMode": [
|
|
22
|
+
{
|
|
23
|
+
"mode": "UPI"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"mode": "BALANCE"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"mode": "NET_BANKING"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"mode": "DEBIT_CARD"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"mode": "CREDIT_CARD"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
(async () => {
|
|
41
|
+
|
|
42
|
+
let checksum = await PaytmChecksum.generateSignature(JSON.stringify(initTxnbody), "KwA5mZLG_wSBDTTi")
|
|
43
|
+
let initTxnUrl = "https://securegw.paytm.in" + `/theia/api/v1/initiateTransaction?mid=${initTxnbody.mid}&orderId=${initTxnbody.orderId}`;
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
request.post(
|
|
47
|
+
initTxnUrl,
|
|
48
|
+
{
|
|
49
|
+
json: {
|
|
50
|
+
"body": initTxnbody,
|
|
51
|
+
"head": {
|
|
52
|
+
"signature": checksum,
|
|
53
|
+
"channelId": "WAP"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
function (error, response, body) {
|
|
58
|
+
|
|
59
|
+
console.log(body.body.txnToken)
|
|
60
|
+
console.log(initTxnbody.orderId)
|
|
61
|
+
|
|
62
|
+
});
|
|
63
|
+
})()
|
|
@@ -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
|
|