-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.js
65 lines (59 loc) · 2.57 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const PaytmChecksum = require('./checksum')
const port = 5000
module.exports=(app) => {
app.get('/payment', (req, res)=> {
var paytmParams = {
"MID" : 'eIIbMy96581149439609',
"WEBSITE" : 'WEBSTAGING',
"CHANNEL_ID" : 'WEB',
"INDUSTRY_TYPE_ID" : 'Retail',
"ORDER_ID" : req.query.orderId,
"CUST_ID" : 'CUST011',
"TXN_AMOUNT" : req.query.cartTotal,
"CALLBACK_URL" : 'http://localhost:'+port+'/callback',
"EMAIL" : req.query.email,
"MOBILE_NO" : req.query.phone
}
var paytmChecksum = PaytmChecksum.generateSignature(paytmParams, "ijJFdua2mlWQRxG#");
paytmChecksum.then(function(checksum){
// console.log("generateSignature Returns: " + checksum);
console.log("checksum", checksum);
var params = {
...paytmParams,
CHECKSUMHASH: checksum
}
res.json(params)
}).catch(function(error){
console.log(error);
});
// checksum_lib.genchecksum(paytmParams, 'ijJFdua2mlWQRxG#', function(err, checksum){
// let txn_url = "https://securegw-stage.paytm.in/theia/processTransactions"
// let form_fields = ""
// for(x in params){
// form_fields += "<input type='hidden' name='"+x+"' value='"+params[x]+"' />"
// }
// form_fields += "<input type='hidden' name='CHECKSUMHASH' value='"+checksum+"' />"
// var html = '<html><body><center><h1>Please wait!!! Do not refresh the page</h1></center><form method="post" action="'+txn_url+'" name="f1">'+form_fields+'</form><script type="text/javascript">document.f1.submit()</script></body></html>'
// res.writeHead(200,{'Content-Type': 'application/json'})
// res.write(html)
// res.end()
// console.log("checksum", checksum);
// var params = {
// ...paytmParams,
// CHECKSUMHASH: checksum
// }
// console.log(params)
// res.json(params)
// })
})
app.post('/callback', (req, res) => {
var paytmChecksum = req.body.CHECKSUMHASH;
delete request.body.CHECKSUMHASH;
var isVerifySignature = PaytmChecksum.verifySignature(req.body, 'ijJFdua2mlWQRxG#', paytmChecksum);
if (isVerifySignature) {
console.log("Checksum Matched");
} else {
console.log("Checksum Mismatched");
}
})
}