【发布时间】:2021-08-11 03:48:54
【问题描述】:
var create_payment_json = {
intent: "sale",
payer: {
payment_method: "paypal"
},
redirect_urls: {
return_url: "http://0c95effc2751.ngrok.io/success",
cancel_url: "http://0c95effc2751.ngrok.io/cancel"
},...}
paypal.payment.create(create_payment_json, function (error, payment) {
if (error) {
console.log(error)
throw error;
} else {
for(let i = 0;i < payment.links.length;i++){
if(payment.links[i].rel === 'approval_url'){
console.log(payment.links[i].href)
res.redirect(payment.links[i].href);
}
}
}
});
在我的后端 Node.js 代码中,我使用中间件来要求身份验证,因此所有路由都可以通过授权标头访问。在 PayPal 页面上批准付款后,在没有此授权标头的情况下重定向回成功路径,因此很遗憾无法访问成功路径。如何解决?
【问题讨论】:
标签: javascript node.js paypal