我想使用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 }
答案 0 :(得分:0)
从沙箱到现场时,您需要做的唯一更改是将端点从“api.sandbox.paypal.com”更改为“api.paypal.com”并使用developer.paypal中的实时凭据.COM