[英]When the nodejs application is running on localhost, how to integrate with api gateway aws?
[英]How to integrate PayTm gateway with nodeJS or with Reactjs?
我正在我的网络应用程序中集成 Paytm 支付网关。 我在前端使用 React,后端使用 nodeJs。
我已成功发出 paytm post 请求,一切正常,但我的回调 url 出现问题。 我成功获取数据我可以在我的网络选项卡中看到它但是当我在控制台记录req.body
它显示一个空对象。
这是我从 paytm 得到的回应
这是我发布数据的地方
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);
})
我想将我的 paytm 响应放入变量中,以便我可以验证并将其添加到 db
你错过了在 app.js 中添加 body-parser
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({extended: true }));
app.use(bodyParser.json())
我也遇到同样的问题! 如果找到,可以分享解决方案吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.