【发布时间】:2014-10-16 10:18:05
【问题描述】:
我想使用 NodeJS 和 PayPal API 付款,但它不起作用,因为我创建的应用程序使用的是 Sandbox,而不是实时...
如何实时使用PayPal?
我的 JSON 配置:
{
"api" : {
"host" : "api.sandbox.paypal.com",
"port" : "",
"client_id" : "*****",
"client_secret" : "*****"
},
"returnUrl" : "http://localhost:3000/returnurl",
"cancelUrl" : "http://localhost:3000/order/user/"
}
我的 NodeJS 代码:
this.paypal.configure(paypalConfigs.api);
var payment = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": paypalConfigs.returnUrl,
"cancel_url": paypalConfigs.cancelUrl+request.user.id
},
"transactions": [{
"amount": {
"total": total,
"currency": "EUR"
},
"description": "Commande Printwithlove"
}]
};
paypal.payment.create(payment, function (error, payment) {
if (error) {
console.log(error);
} else {
if(payment.payer.payment_method === 'paypal') {
request.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;
}
}
response.redirect(redirectUrl);
}
}
});
还有我在 PayPal 上的应用:
编辑:
[**.fr.3008-13 (out)] { [Error: Response Status : 401]
[**.fr.3008-13 (out)] response:
[**.fr.3008-13 (out)] { error: 'invalid_client',
[**.fr.3008-13 (out)] error_description: 'The client credentials are invalid',
[**.fr.3008-13 (out)] httpStatusCode: 401 },
[**.fr.3008-13 (out)] httpStatusCode: 401 }
【问题讨论】:
标签: paypal