【发布时间】:2023-04-09 05:50:02
【问题描述】:
我正在使用 paypal rest api 为 woocommerce 编写一个自定义的 paypal 网关。 我几乎完成了,在使用沙盒帐户进行测试时一切正常。但是切换到 Live 后,我得到了很多错误“货币金额必须是非负数” 这是我得到的:
PayPal\Core\PayPalHttpConnection : ERROR: Got Http response code 400 when accessing https://api.paypal.com/v1/payments/payment. {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].item_list.items[0].price","issue":"Currency amount must be non-negative number, contain exactly 2 decimal places separated by '.' (JPY contains 0 decimal places), optional thousands separator ',', limited to 7 digits before the decimal point and currency which is a valid ISO Currency Code"},{"field":"transactions[0].amount.details.subtotal","issue":"Currency amount must be non-negative number, contain exactly 2 decimal places separated by '.' (JPY contains 0 decimal places), optional thousands separator ',', limited to 7 digits before the decimal point and currency which is a valid ISO Currency Code"},{"field":"transactions[0].amount.total","issue":"Currency amount must be non-negative number, contain exactly 2 decimal places separated by '.' (JPY contains 0 decimal places), optional thousands separator ',', limited to 7 digits before the decimal point and currency which is a valid ISO Currency Code"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"dc60e0012af71"}
我认为问题出在这里:
if ($dec == 0) $myprice = ceil($myprice);
else $myprice = round($myprice, $dec);}
$myprice = doubleval($myprice);
return $myprice ;
当我将 $myprice 的值更改为整数时,它可以正常工作,但这样它就不起作用了。即使使用 Number_format,问题也是一样的。 有人可以帮帮我吗?
【问题讨论】:
标签: php paypal woocommerce