1

I am trying to build a checkout using the Square API. I am getting the following error:

'order.total_money.amount' must be greater than 1.

I am sending:

<cfset stFields = {
    "idempotency_key": "*******-258a-402e-abb5-fee8e3d16884",
    "redirect_url": "https://graftondecafundraising.org/SquareOrderComplete.cfm",
    "order": {
      "total_money":{
      "amount": 900},
      "idempotency_key": "******-258a-402e-abb5-fee8e3d16884",
      "order": {
        "location_id": "******C7F3RZ1S5",
        "customer_id": "customer_id",
        "reference_id": "reference_id"
      }
    },
    "ask_for_shipping_address": false,
    "merchant_support_email": "merchant+support@website.com",
    "pre_populate_buyer_email": "example@email.com"
  }
>

And the JSON Reply is showing: enter image description here

Thanks in advance for any suggestions!

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
GCJH
  • 101
  • 1
  • 9
  • 2
    Does this answer your question? [Square API, VALUE\_TOO\_LOW error when charging a card](https://stackoverflow.com/questions/44371683/square-api-value-too-low-error-when-charging-a-card) – Miguel-F Jan 18 '21 at 16:28

2 Answers2

3

The issue was in CF2016 when serializing the JSON CF wasn't sending the amounts as integers even if you wrapped it as INT(#value#).  In CF2018 and CF2021 serializing the JSON created the value as an integer and Square was happy. We tested the exact same code in 2016, 2018, and 2021. It failed in 2016 and worked perfectly in the newer versions.

GCJH
  • 101
  • 1
  • 9
0

This occurs in a lot of payment APIs, the amount is in cents, not dollars.

https://developer.squareup.com/reference/square/objects/Money

amount - integer

The amount of money, in the smallest denomination of the currency indicated by currency. For example, when currency is USD, amount is in cents. Monetary amounts can be positive or negative. See the specific field description to determine the meaning of the sign in a particular case.

Can't recall which API was integrated at a previous company, but sending amount: 0 triggered a full refund. Really need to read the docs when it involves money.

Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44