paypal php sdk浮动时的问题

时间:2017-08-30 12:32:24

标签: php paypal woocommerce

我正在使用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,问题也是一样的。 有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

我的猜测是你传递的值不符合paypal所要求的格式。很可能是小数分隔符,由不同的区域设置或其他东西引起。