提交费用与小数金额的平方

Submitting a charge to square with a decimal amount

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

当我通过以下时,API returns 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 returns 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 returns 200

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

它允许我提交整数而不是小数。有什么想法吗?

如果您使用美分计费,则无需使用小数点 - 金额 字段的最小面额为美分。您可以将其设置为 22500 收取 US$225.00

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

货币的数量,以最小面值的货币表示的货币中的最低值。例如,当 currency_code 为美元时,金额以美分为单位。