![](/img/trans.png)
[英]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.