Paypal错误:物品金额格式不正确


Paypal Error: incorrectly formatted item amount

我在paypal遇到了一个奇怪的问题。当我的购物车传递带有小数位的值(如1.15)时,它不起作用,并向我显示错误:您用于进入PayPal系统的链接包含格式不正确的项目金额。

这是不带十进制数的量的输出:

paypal_class->dump_fields() Output:
Field Name     Value
amount_1       70.00 
business       xxxxxxxxxxxxxxxx
cancel_return  xxxxxxxxxxxxxxxxxx
cmd            _cart 
currency_code  HUF 
invoice        171SPLINTERCELLCONVICTIONxxxxxxxxxxxxxxxxxxx
item_name_1    Apple 
item_number_1  211 
notify_url     xxxxxxxxxxxxxxxxxxxxxxxx
on0_1          Option 
os0_1          Default 
quantity_1     1 
return         xxxxxxxxxxxxxxxxxxxxxxxxx
rm             2 
shipping_1     5 
tax_cart       0.00 
upload         1 

这是带小数点的输出,它不起作用(出于安全原因,我删除了一些变量)。

paypal_class->dump_fields() Output:
Field Name     Value
amount_1       70.15 
business       xxxxxxxxxxxxxxxxxx
cancel_return  xxxxxxxxxxxxxxxxxxx
cmd            _cart 
currency_code  HUF 
invoice        172SPLINTERCELLCONVICTIONxxxxxxx
item_name_1    Apple 
item_number_1  211 
notify_url     xxxxxxxxxxx 
on0_1          Option 
os0_1          Default 
quantity_1     1 
return         xxxxxxxxxxx 
rm             2 
shipping_1     5 
tax_cart       0.00 
upload         1 

,它不仅适用于三种货币:匈牙利福林,日元,新台币。

有什么帮助吗?我会很感激的。

您的应用程序应该通过您正在使用的类将正确的货币格式传递给PayPal。

因此,如果您将价格存储为数据库中的十进制数字(例如美元),但访问者将其区域设置/查看偏好设置为日元,那么您的应用程序应该相应地转换价格(在这种情况下为没有小数点的整数),然后将其传递给您的PayPal类。

这三种货币没有十进制值。每当你把十进制值贝宝将显示错误。因此,尝试四舍五入值(10.25到10或11)。