我在NodeJS的帮助下使用一些PayPal Payments创建了一个平台,到目前为止一切正常,我不知道为什么它会引发这个错误。大约1小时前,我付款了,现在还不允许我付款。我还没有修改任何代码或类似的内容。]
这是错误
/ Users / calinonaca / Desktop / PEDIGREE-NOTES复制/控制器/feed.js:863抛出错误;^
错误:响应状态:IncomingMessage处为400。(/ Users / calinonaca / Desktop / PEDIGREE-NOTES copy / node_modules / paypal-rest-sdk / lib / client.js:130:23)位于EndReadableNT(_stream_visible.js)的IncomingMessage.emit(events.js:203:15) :1145:12)在process._tickCallback(internal / process / next_tick.js:63:19)
这是我的功能
exports.postPayment = (req,res,next) => {
const uploadedBy = req.body.noteOwner;
const finalprice = req.body.finalprice;
const notename = req.body.notename;
const loggedInUser = req.session.user._id;
const noteprice = req.body.noteprice;
const create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://localhost/successPayment/"+finalprice+"/"+notename+"/"+uploadedBy+"/"+noteprice+"/"+loggedInUser,
"cancel_url": "http://localhost/cancel"
},
"transactions": [{
"item_list": {
"items": [{
"name": "Note",
"sku": "001",
"price": finalprice,
"currency": "USD",
"quantity": 1
}]
},
"amount": {
"currency": "USD",
"total": finalprice
},
"description": "Note you ordered"
}]
};
paypal.payment.create(create_payment_json, function (error, payment) {
if (error) {
throw error;
} else {
for(let i = 0; i < payment.links.length; i++)
{
if(payment.links[i].rel === 'approval_url')
{
res.redirect(payment.links[i].href);
}
}
}
});
}
到现在为止一切都很好,我不知道出什么问题了,您能帮我吗?谢谢!
我希望这会有所帮助,我遇到了同样的问题,我不得不挖掘几乎所有可能的链接和资源,我发现您必须在这里映射完全相同的对象
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "0.01"
}
},
"description": "The payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [
{
"name": "hat",
"description": "Brown hat.",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "handbag",
"description": "Black handbag.",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}
],
"shipping_address": {
"recipient_name": "Brian Robinson",
"line1": "4th Floor",
"line2": "Unit #34",
"city": "San Jose",
"country_code": "US",
"postal_code": "95131",
"phone": "011862212345678",
"state": "CA"
}
}
}
],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "https://example.com/return",
"cancel_url": "https://example.com/cancel"
}
只有复制并粘贴此对象后,我才能获得带有重定向URL的成功响应。我希望这能帮到您。我将和对象一起玩耍,看看是否有什么可以忽略的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句