【发布时间】:2020-04-04 02:59:22
【问题描述】:
我正在使用 Paypal PHP SDK(在 Laravel 中)准备付款。目前,该付款如下所示:
{
"intent":"sale",
"payer":{
"payment_method":"paypal"
},
"redirect_urls":{
"return_url":"http://website.lab/payment/paypal/success",
"cancel_url":"http://website.lab/payment/paypal/cancel"
},
"transactions":[
{
"amount":{
"currency":"EUR",
"total":"223",
"details":{
"shipping":"0",
"subtotal":"273"
}
},
"description":"...",
"item_list":{
"items":[
{
"name":"product 8",
"currency":"EUR",
"quantity":21,
"sku":"w9",
"price":"13.00"
}
],
"shipping_address":{
"city":"...",
"postal_code":"...",
"country_code":"...",
"recipient_name":"...",
"line1":"..."
}
}
}
]
}
如您所见,从总计到小计中缺少 50 欧元,这会导致此错误
400{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].amount","issue":"Transaction amount details (subtotal, tax, shipping) must add up to specified amount total"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"91d27597e954"}
现在查看 Paypal SDK 我找不到任何可以告诉 Paypal 为小计添加折扣的方法/对象。
任何帮助将不胜感激,我真的在网上找不到任何可以解决这个问题的资源
【问题讨论】:
-
您是否尝试在您的
"item_list"中添加一个对交易具有负值的项目?例如。{"name": "Discount", "price": "-50", "currency": "EUR", "quantity": "1"} -
哦,实际上不,谢谢,我会立即尝试@jibsteroos
-
@jibsteroos 它工作!啊哈,请发布一个答案,以便给你学分
-
很高兴听到,很高兴我能帮上忙!
标签: php laravel paypal sdk payment-gateway