gpt4 book ai didi

php - 为 Paypal 付款添加折扣

转载 作者:太空宇宙 更新时间:2023-11-03 16:20:56 25 4
gpt4 key购买 nike

我正在使用 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"
}

关于php - 为 Paypal 付款添加折扣,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59275442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com