【问题标题】:Submitting a charge to square with a decimal amount以小数金额向平方提交费用
【发布时间】:2016-09-19 10:52:04
【问题描述】:

我正在尝试向 Square 中的 /locations/{location}/transactions 端点传递 POST 请求以向卡收费。我有一个随机数、一个位置 ID 和一个 Guid(.NET 实现)。一切正常,除了我不能传递一个十进制值。我正在使用沙盒。

当我通过以下,API返回422,Value was not expected to be a string

{  
   "card_nonce":"VALID_CARD_NONCE",
   "amount_money":{  
      "amount":"225.00",
      "currency":"USD"
   },
   "idempotency_key":"3f5f21a5-9d6b-4277-93b2-2b257a8e64df"
}

当我通过以下内容时,API 返回 422,Value was not expected to be a number 225.00

{  
   "card_nonce":"VALID_CARD_NONCE",
   "amount_money":{  
      "amount": 225.00,
      "currency":"USD"
   },
   "idempotency_key":"3f5f21a5-9d6b-4277-93b2-2b257a8e64df"
}

当我通过以下内容时,API 返回 200

{  
   "card_nonce":"VALID_CARD_NONCE",
   "amount_money":{  
      "amount": 225,
      "currency":"USD"
   },
   "idempotency_key":"3f5f21a5-9d6b-4277-93b2-2b257a8e64df"
}

它允许我提交整数,但不能提交小数。任何想法为什么?

【问题讨论】:

    标签: square-connect


    【解决方案1】:

    如果您以美元计费,则无需使用小数 - amount 字段的最小单位是美元的美分。您可以将其设置为 22500 以收取 US$225.00

    这里是相关文档:https://docs.connect.squareup.com/api/connect/v2/#workingwithmonetaryamounts

    货币金额,以货币表示的最小面额货币中的最低值。例如,currency_code 为 USD 时,金额为美分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-12
      • 2015-07-23
      • 1970-01-01
      • 2017-11-11
      • 2017-02-04
      • 2016-04-29
      • 1970-01-01
      相关资源
      最近更新 更多