我正在使用npm paypal-rest-sdk来调用支付 api。我正在发送电子邮件的身体和金额。当我打电话给api /付款时,它会给出错误,如响应状态:503 。
这是我的代码:
app.post('/api/payment',function(req,res){
paypal.configure({
'mode':"live", //sandbox or live
'client_id': "*******",
'client_secret': "*******"
});
var sender_batch_id = Math.random().toString(36).substring(9);
var create_payout_json = {
"sender_batch_header": {
"sender_batch_id": sender_batch_id,
"email_subject": "You have a payment"
},
"items": [
{
"recipient_type": "EMAIL",
"amount": {
"value": req.body.amount,
"currency": "USD"
},
"receiver": req.body.email,
"note": "Thank you.",
"sender_item_id": Date.now()
}
]
};
var sync_mode = 'true';
paypal.payout.create(create_payout_json,sync_mode, function (error, payout) {
if (error) {
console.log(error.response);
throw error;
} else {
console.log("Create Payout Response");
console.log(payout);
}
});
})
我收到错误响应,如503。请帮我解决这个问题。谢谢