I am integrating Paytm payment gateway in my web app. I am using React for front end and nodeJs for back end.
I've made paytm post request successfully and everything is working fine but my callback url is making problems. I am getting data successfully I can see it in my network tab but when I am console logging req.body
it is showing an empty object.
This is response I am getting from paytm
This where I am posting up the data
app.get('/user/recharge/mywallet' , (req, res) => {
/* initialize an object with request parameters */
var paytmParams = {
"MID" : "my merchant id",
"WEBSITE" : "WEBSTAGING",
"INDUSTRY_TYPE_ID" : "Retail",
/* WEB for website and WAP for Mobile-websites or App */
"CHANNEL_ID" : "WEB",
/* Enter your unique order id */
"ORDER_ID" : "2213211",
/* unique id that belongs to your customer */
"CUST_ID" : "3221211",
/**
* Amount in INR that is payble by customer
* this should be numeric with optionally having two decimal points
*/
"TXN_AMOUNT" : "200",
/* on completion of transaction, we will send you the response on this URL */
"CALLBACK_URL" : "http://localhost:3001/true/paytmresp",
};
checksum.genchecksum(paytmParams, "My Merchant Key", function(err, checksum){
/* for Staging */
let url = "https://securegw-stage.paytm.in/order/process";
/* Prepare HTML Form and Submit to Paytm */
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<html>');
res.write('<head>');
res.write('<title>Merchant Checkout Page</title>');
res.write('</head>');
res.write('<body>');
res.write('<center><h1>Please do not refresh this page...</h1></center>');
res.write('<form method="post" action="' + url + '" name="paytm_form">');
for(let x in paytmParams){
res.write('<input type="hidden" name="' + x + '" value="' + paytmParams[x] + '">');
}
res.write('<input type="hidden" name="CHECKSUMHASH" value="' + checksum + '">');
res.write('</form>');
res.write('<script type="text/javascript">');
res.write('document.paytm_form.submit();');
res.write('</script>');
res.write('</body>');
res.write('</html>');
res.end();
if(err) {
console.log("err: ", err);
}
console.log('checksum: ', checksum);
})
})
app.post('/true/paytmresp', (req, res) => {
console.log("body: ", req.body);
})
I want to put my paytm response into variables so I can verify and add that to db
You have missed adding body-parser in app.js
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json())
Same issue for me too! Can you share the solution if you found?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.