【发布时间】:2015-09-02 10:40:50
【问题描述】:
我正在尝试将基于 PHP 的应用程序重新构建为 MEAN,并且我尝试集成一个 3rd 方支付网关,用户可以在其中输入他们的信用卡信息。
我能够使用'request' module 创建发布请求,并收到来自第三方的响应状态代码 200。现在请求已经完成,有没有办法将用户重定向到第三方站点(类似于使用 html 表单和 PHP 完成的 POST 请求)?
这是发布请求的代码块
function(req, res) {
request({
url: 'https://urlopaymentgateway',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
form:data,
followAllRedirects:true
},function(error,response,body){
if(error) {
console.log("FAIL");
console.log(error);
} else {
console.log(response.statusCode);
/* How to do redirection here? */
}
});
}
经过进一步阅读,followAllRedirects 仅在状态码介于 300 和 400 之间时才有效。
【问题讨论】: