向PayPal API发送少量金额

时间:2014-04-07 10:42:42

标签: api paypal floating-point floating-point-precision fixed-point

我使用PayPal API处理我网站上的付款。产品具有以下价格:

  • 不含税:0.083€
  • 增值税率:20%
  • 所有税费:0.10€

在API中,我们必须发送订单项目,不包括税单价和增值税率。

这是我的要求:

{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "currency": "EUR",
        "total": "99.60",
        "details": {
          "subtotal": "83.00",
          "tax": "16.60"
        }
      },
      "item_list": {
        "items": [
          {
            "quantity": "1000",
            "name": "My product",
            "price": "0.08",
            "currency": "EUR",
            "sku": "1-20140407123511492"
          }
        ]
      }
    }
  ]
}

如您所见,由于PayPal仅接受最多2位小数的价格,因此最终计算中存在错误(0.003€乘以数量)。

最后,我有以下错误:

{"name":"VALIDATION_ERROR","details":[{"field":"transactions","issue":"Item amount must add up to specified amount subtotal (or total if amount details not specified)"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"132eaa3f14cce"}

那么,我们如何使用PayPal API处理小价格? 感谢。

0 个答案:

没有答案