gpt4 book ai didi

php - 交易金额详细信息(小计、税金、运费)必须加起来达到指定的总金额 - PayPal PHP SDK

转载 作者:太空宇宙 更新时间:2023-11-03 15:57:49 26 4
gpt4 key购买 nike

出于某种原因,当我尝试使用 SDK 授权 PayPal 付款时,我的日志中不断出现以下错误:

ERROR: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment. {"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"

我的交易金额似乎加起来没问题,所以我不知道为什么 PayPal 会抛出错误,这是我的交易金额:

'transactions' => [
0 => PayPal\Api\Transaction#5
(
[PayPal\Common\PayPalModel:_propMap] => [
'amount' => PayPal\Api\Amount#6
(
[PayPal\Common\PayPalModel:_propMap] => [
'currency' => 'GBP'
'total' => '675.00'
'details' => PayPal\Api\Details#7
(
[PayPal\Common\PayPalModel:_propMap] => [
'fee' => '75.00'
'subtotal' => '600.00'
]
)
]
)
'item_list' => PayPal\Api\ItemList#8
(
[PayPal\Common\PayPalModel:_propMap] => [
'items' => [
0 => PayPal\Api\Item#9
(
[PayPal\Common\PayPalModel:_propMap] => [
'name' => 'Day 1: 30-12-2017'
'currency' => 'GBP'
'quantity' => 1
'price' => '300.00'
]
)
1 => PayPal\Api\Item#10
(
[PayPal\Common\PayPalModel:_propMap] => [
'name' => 'Day 2: 27-01-2018'
'currency' => 'GBP'
'quantity' => 1
'price' => '300.00'
]
)
]
]
)

这可能与 number_format 有关吗?功能?我正在使用该函数来确保所有值都与其小数位一致:$grandTotal = number_format($data['job']['grandTotalAmount'], 2, '.', '');

最佳答案

我遇到了这个问题。在我的例子中,解决方案是正确的总计和小计计算:

subtotal 必须是 Price * Quantity

Total 必须是 Tax + shipping + subtotal

不要只是硬编码这些字段。

希望对你有帮助

关于php - 交易金额详细信息(小计、税金、运费)必须加起来达到指定的总金额 - PayPal PHP SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48061785/

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