【发布时间】:2014-05-24 06:41:49
【问题描述】:
这就是我从我的 web 应用创建 Paypal 付款的方式:
paypal.configure(paypal_config.api);
var payment = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
//"receiver_email": "business@place.fr",
"redirect_urls": {
"return_url": "http://yoururl.com/execute",
"cancel_url": "http://yoururl.com/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "item",
"sku": "item",
"price": "1.00",
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": "1.06",
"details": {
"subtotal": "1.00",
"tax": "0.03",
"shipping": "0.03"
}
},
"description": "This is the payment description."
}]
};
paypal.payment.create(payment, function (error, payment) {
if (error) {
console.log(error);
} else {
if(payment.payer.payment_method === 'paypal') {
req.session.paymentId = payment.id;
var redirectUrl;
for(var i=0; i < payment.links.length; i++) {
var link = payment.links[i];
if (link.method === 'REDIRECT') {
redirectUrl = link.href;
}
}
res.redirect(redirectUrl);
}
}
});
效果很好,但我有两个问题,我需要设置receiver email,当我添加密钥“receiver_email”时,据说请求格式不正确。
我的第二个问题实际上更多的是一个问题,使用这种方法我直接知道付款是否经过验证,但是当付款需要更多时间来验证时会发生什么(银行转账等),没有 ipn要给的网址?
谢谢!
【问题讨论】:
-
你解决了吗?我也有同样的问题。
-
不幸的是没有...:/我目前不在同一个项目上工作,但我必须尽快回来!如果您找到解决方案,请告诉我。谢谢。
-
重定向时出现 CORS 错误。我该如何解决?
标签: node.js api paypal payment-gateway