在 Node.Js 上的集成connect
失败,节点有问题js
。此脚本无法将其连接到api
. 在浏览器上显示这个
不能获取 /
这是教程 点击这里
var express = require('express')
var jwt = require('jsonwebtoken');
var app = express();
app.get('/PageAfterClickOnSubmitWithZainCash', function (req, res) {
jwt.sign({
amount: 1000,//Product Ammout
serviceType: 'AAA books website',
msisdn: 9647911111111,
orderId: 12345,//optional
redirectUrl: "http://www.yourwebiste.com/zain_order.php",//optional
}, 'secretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecretsecret', {
expiresIn: '4h'
}, function (err, token) {
request.post({
url: 'https://api.zaincash.iq/transaction/init',
form: {
token: token,
merchantId: "572487bca0a4d6f2688c1ee3",
lang: "ar"//optional
}
}, function (err, httpResponse, body) {
var body = JSON.parse(body); // response of body { id : "asdae123asd123asd" }
if (body.id)
return res.redirect('https://api.zaincash.iq/transaction/pay?id=' + body.id);
return res.redirect('/payment?msg=cannot_generate_token');
})
});
});
var connect = require('connect');
var serveStatic = require('serve-static');
var app = connect();
app.listen(5000);
console.log('working on port 5000');