Money & currency
Every amount you send to Flint or read back is a Money object: an integer in the currency's minor unit and an explicit currency code. {"amount": 2500, "currency": "USD"} is $25.00. Amounts are never floats or decimal strings and always name their currency, so the totals Flint computes reconcile exactly with what you store.
Getting money right comes down to four habits: convert to minor units once, at your boundary; send prices and let Flint compute totals; read the computed amounts instead of recalculating them; and keep each amount's currency with it.
The Money object#
Money fields have the same two-field shape in requests and responses:
{"amount": 2500, "currency": "USD"}
amountis a JSON integer in the currency's minor unit. For USD that is the cent, so2500is 2,500 cents, or $25.00. It is a 64-bit integer.currencyis a three-letter uppercase ISO 4217 code.
Both fields are required whenever you send an amount, and both are present on every amount Flint returns.
If a money object is missing either member, Flint returns 400 INVALID_REQUEST with a REQUIRED detail for each missing member. The detail's param includes the full path, such as line_items[0].unit_price_money.amount. Send {"amount": 0, "currency": "USD"} for an explicit zero where allowed. You may omit optional money fields or send null where the field documents clearing.
| To represent | Send amount | Not |
|---|---|---|
| $0.50 | 50 | 0.50 |
| $19.99 | 1999 | 19.99 |
| $25.00 | 2500 | 25 |
| $1,000.00 | 100000 | "1000.00" |
Warning: The off-by-100 bug
Sending dollars where Flint expects minor units is the most common bug in a new integration. {"amount": 25, "currency": "USD"} is 25 cents, not $25.00. If a test charge comes out a hundred times smaller than you expected, you sent major units. If a buyer sees $2,500 instead of $25, something multiplied by 100 twice. Convert in one helper, call it everywhere, and assert on pricing_amounts.total_money in your tests.
Flint rejects an amount it can't read as an exact integer:
- A float such as
12.50or a string such as"1250"fails with400 INVALID_REQUEST, detail codeINVALID_VALUE, andparamnaming the field. - A negative amount fails the same way. The one request field that takes a signed amount is
amount_moneyonPOST /v1/gift-cards/{gift_card_id}/adjust-balance, where a negative amount removes value from the card. - Zero is valid where a free item makes sense, such as a line item's
unit_price_money. Amounts that move or take off money must be greater than zero: payments, refunds, tips, charges, and discounts.
Every order money input and every computed order amount must be at most 99999999 minor units ($999,999.99 USD), the single-payment ceiling. This includes unit prices, modifier prices, discounts, charges, tips, and external tax. Valid inputs can still exceed the ceiling when combined, such as a unit price multiplied by quantity or a charge added to an order total. Flint refuses the request with 400 INVALID_REQUEST, detail code INVALID_VALUE, and param naming the input that made the amount exceed the ceiling. The refused request does not create or change the order. Payment options can have lower limits.
An order line item's quantity must be from 1 through 9999. Its extended subtotal, including modifiers, must also fit within the money ceiling.
Convert input to minor units#
Convert a buyer's or operator's decimal input to an integer once, before it reaches your API client. Parse the string itself rather than multiplying a float, because binary floating point can't represent most decimal fractions exactly:
Number("19.99") * 100; // 1998.9999999999998
A string parser gives the exact integer and rejects input with more decimal places than the currency has:
// Decimal places in each currency's minor unit. Flint accepts USD.
const MINOR_UNIT_DIGITS = { USD: 2 };
function toMinorUnits(input, currency) {
const digits = MINOR_UNIT_DIGITS[currency];
if (digits === undefined) throw new Error(`Unsupported currency: ${currency}`);
const match = /^(\d+)(?:\.(\d+))?$/.exec(input.trim());
if (!match) throw new Error(`Not an amount: ${input}`);
const [, whole, fraction = ""] = match;
if (fraction.length > digits) {
throw new Error(`${currency} amounts have at most ${digits} decimal places`);
}
return Number(whole + fraction.padEnd(digits, "0"));
}
toMinorUnits("19.99", "USD"); // 1999
toMinorUnits("25", "USD"); // 2500
toMinorUnits("0.5", "USD"); // 50
After that, do all arithmetic on integers. 0.1 + 0.2 is not 0.3 in floating point, but 10 + 20 is always 30.
Send prices, read totals#
Two field names carry most amounts, and the name tells you which kind you are looking at:
| Field | Meaning | Where it appears |
|---|---|---|
unit_price_money | The price of one unit. Flint multiplies it by quantity. | Line items on orders, invoices, payment links, and subscription plans; product variants; bundles |
unit_price_delta_money | The per-unit price change a modifier applies. | Modifiers |
amount_money | A whole amount: money that moves, or a total you set directly. | Payment intents, refunds, tips, order charges, manual discounts, invoice manual payments, payouts, disputes, balance transactions |
Quantity math belongs to Flint. Send the unit price and the quantity, and read the extended amounts from the response. Create an order for two tote bags at $12.50 each with a $5.00 manual discount:
curl -X POST https://api.withflintpay.com/v1/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: money-tote-001" \
-d '{
"line_items": [{
"type": "custom",
"name": "Canvas tote bag",
"quantity": 2,
"unit_price_money": {"amount": 1250, "currency": "USD"},
"fulfillment": {"requirement": "none"}
}],
"discounts": [{
"manual": {
"name": "Loyalty credit",
"amount_money": {"amount": 500, "currency": "USD"}
}
}]
}'
{
"data": {
"order_id": "ord_1kmn0aExample",
"status": "open",
"payment_status": "unpaid",
"line_items": [{
"order_line_item_id": "li_1kmn0aExample",
"name": "Canvas tote bag",
"quantity": 2,
"unit_price_money": {"amount": 1250, "currency": "USD"},
"base_subtotal_money": {"amount": 2500, "currency": "USD"},
"modifier_total_money": {"amount": 0, "currency": "USD"},
"subtotal_money": {"amount": 2500, "currency": "USD"},
"discount_money": {"amount": 500, "currency": "USD"},
"tax_money": {"amount": 0, "currency": "USD"},
"total_money": {"amount": 2000, "currency": "USD"}
}],
"discounts": [{
"order_discount_id": "ad_1kmn0aExample",
"source": "manual",
"amount_money": {"amount": 500, "currency": "USD"},
"applied_money": {"amount": 500, "currency": "USD"}
}],
"pricing_amounts": {
"subtotal_money": {"amount": 2500, "currency": "USD"},
"discount_money": {"amount": 500, "currency": "USD"},
"charge_money": {"amount": 0, "currency": "USD"},
"tax_money": {"amount": 0, "currency": "USD"},
"additive_tax_money": {"amount": 0, "currency": "USD"},
"inclusive_tax_money": {"amount": 0, "currency": "USD"},
"requested_tip_money": {"amount": 0, "currency": "USD"},
"total_money": {"amount": 2000, "currency": "USD"}
},
"settlement_amounts": {
"paid_money": {"amount": 0, "currency": "USD"},
"refunded_money": {"amount": 0, "currency": "USD"},
"net_collected_money": {"amount": 0, "currency": "USD"},
"settled_tip_money": {"amount": 0, "currency": "USD"},
"overpaid_money": {"amount": 0, "currency": "USD"},
"written_off_money": {"amount": 0, "currency": "USD"},
"outstanding_money": {"amount": 2000, "currency": "USD"}
}
}
}
Each line item carries its own arithmetic:
base_subtotal_moneyisunit_price_moneytimesquantity.subtotal_moneyaddsmodifier_total_money, the line's modifiers.discount_moneyis the line's share of the order's discounts. An order-level discount is split across the lines it applies to in proportion to their amounts.total_moneyissubtotal_money - discount_money, plustax_moneywhen the price doesn't already include tax.
On the order discount, amount_money is the discount as defined and applied_money is what it took from this order. They differ when a constraint caps the discount, such as a percent promotion applied to what is left after earlier discounts. See Promotions.
Computed order amounts#
Every order carries two computed summaries, and they answer different questions.
pricing_amounts is what the order should collect.
| Field | What it is |
|---|---|
subtotal_money | The line items' subtotal_money added up: prices with modifiers, before discounts. |
discount_money | Order and line-item discounts. Discounts on service charges reduce charge_money instead. |
charge_money | Service, delivery, and other order charges, after any discounts on them. |
tax_money | All tax: additive_tax_money + inclusive_tax_money. |
additive_tax_money | Tax added on top of prices. |
inclusive_tax_money | Tax already inside subtotal_money and charge_money, from tax-inclusive prices. Informational. |
requested_tip_money | The tip: requested before payment, settled net of refunds after. |
total_money | What the buyer pays. |
total_money = subtotal_money - discount_money + charge_money
+ additive_tax_money + requested_tip_money
total_money is never below zero. Only the additive part of tax adds to it. inclusive_tax_money is already counted in the prices, so don't add it again. On an order with no tax-inclusive prices, additive_tax_money equals tax_money and inclusive_tax_money is zero. Invoices carry the same object in snapshot.pricing_amounts.
settlement_amounts is what has happened.
| Field | What it is |
|---|---|
paid_money | Settled payments and applied return credit. |
refunded_money | Money returned to the buyer from what the order collected. |
net_collected_money | Payments collected for the order minus refunded_money. |
settled_tip_money | The part of collected money settled as tips. |
overpaid_money | Money collected beyond the order total and not yet refunded. |
released_money | Authorized money a successful final capture released instead of collecting, which the order no longer owes. Excludes canceled and expired holds. |
written_off_money | Invoice debt no longer owed. It reduces outstanding_money without counting as paid. |
outstanding_money | What is still left to collect: total_money - paid_money - written_off_money - released_money, never below zero. |
Released money does not increase paid_money, net_collected_money, or refund capacity, and pricing_amounts stays unchanged. See Final capture on orders. Refunds return money already collected, so they don't add to outstanding_money. Before any payment, outstanding_money equals pricing_amounts.total_money.
Read totals from these objects instead of deriving them. Discounts are split across lines, percent amounts round to the minor unit, and tax depends on the order's tax location, so a client-side recalculation can be off by a cent. Show the buyer pricing_amounts.total_money before they pay. To confirm collection, check that payment_status is paid and settlement_amounts.outstanding_money is 0.
What you keep#
The order amounts describe what the buyer owes and pays. What reaches your balance is on the payment: captured_money is what the buyer paid, processing_fee_money is Flint's complete fee to process it, and merchant_net_money is captured_money minus processing_fee_money and any add_on_fees. A $50.00 card payment with a $2.25 fee nets $47.75. See Processing fees.
Amounts that can be negative#
Requests take non-negative amounts, except the gift card adjustment above. These response fields are signed:
| Field | When it is negative |
|---|---|
amount_money, fee_money, and net_money on balance transactions | Money leaving your balance, such as a refund. fee_money is positive for a fee charged and negative for a fee returned, and net_money = amount_money - fee_money. |
available_money and pending_money on the balance | Your balance is below zero. |
net_money on payouts | Always, once the processor records the payout: it takes money out of your balance. |
amount_money on gift card transactions | Value was removed from the card. |
balance_delta_money and running_balance_money on order activities | The activity lowered the order balance, or the balance is in credit. |
If you load amounts into an accounting system, store these fields as signed integers and every other amount as non-negative. See Reconciliation for tying payments, fees, and payouts together.
Percentages#
Tips, order charges, and promotions can be a percent instead of a fixed amount. Percent fields are in percentage points, with up to four decimal places: 15 is 15% and 12.5 is 12.5%.
| Input | Fixed form | Percent form | Percent range |
|---|---|---|---|
Tip (requested_tip) | calculation_type: "amount" with amount_money | calculation_type: "percent" with percent | 1 to 100 |
| Order charge | calculation_type: "amount" with amount_money | calculation_type: "percent" with percent and calculation_basis | Above 0, up to 100 |
| Promotion | type: "amount_off" with amount_off_money | type: "percent_off" with percent_off | 1 to 100 |
Each takes one form or the other, never both.
Warning: Percents are not fractions
"percent": 0.15 is 0.15%, not 15%. If a tip or discount comes out as almost nothing, you sent a fraction where Flint expects percentage points.
A percent is an input. What comes back is money, rounded to the minor unit: a percent tip resolves to effective_amount_money on the tip, a percent charge to the charge's applied_money, and a percent promotion to the discount's applied_money. Tips and charges round half up. A 15% tip on an order whose subtotal after discounts is $40.00 returns "effective_amount_money": {"amount": 600, "currency": "USD"}. See Tips and charges and Promotions.
Currency#
currency is a three-letter uppercase ISO 4217 code, and Flint accepts one currency: USD. A malformed code (usd, US), an unknown one (XYZ), and a valid code Flint doesn't accept (EUR) all fail with 400 INVALID_REQUEST and detail code INVALID_VALUE, with param pointing at the currency field:
{
"error": {
"type": "validation_error",
"code": "INVALID_REQUEST",
"message": "Line item 0: Currency \"EUR\" is not supported; supported currencies: USD",
"param": "line_items[0].unit_price_money.currency",
"details": [
{
"code": "INVALID_VALUE",
"param": "line_items[0].unit_price_money.currency",
"message": "Line item 0: Currency \"EUR\" is not supported; supported currencies: USD"
}
]
}
}
Because every amount names its currency, your code should read amount and currency together rather than assume dollars. Never add, compare, or format an amount without its currency.
Currency must also agree within a flow. Every line item on an order uses one currency, and the order's charges, discounts, tips, and payments must use it too. A capture uses the currency of its authorization. A mismatch fails with 400 INVALID_REQUEST and detail code NOT_ALLOWED.
Filter lists by amount#
GET /v1/orders, GET /v1/payment-intents, and GET /v1/refunds take min_amount and max_amount filters. They are bare positive integers in minor units, both bounds are inclusive, and they require currency. Orders filter on pricing_amounts.total_money, and payments and refunds on amount_money. List orders of $100.00 or more:
curl "https://api.withflintpay.com/v1/orders?min_amount=10000¤cy=USD" \
-H "Authorization: Bearer YOUR_API_KEY"
A bound without currency fails with 400 INVALID_REQUEST and detail code REQUIRED on currency. max_amount below min_amount fails with INVALID_VALUE. The buyer lists under /v1/me take the same filters.
Payment amount limits#
A payment intent's amount_money must be at least 50 ($0.50) and at most 99999999 ($999,999.99). Outside that range, creating it fails with 400 INVALID_REQUEST, detail code INVALID_VALUE, on amount_money.amount. Payment options also have their own ranges, which can be narrower: an amount outside one fails with 409 PAYMENT_OPTION_UNAVAILABLE and reason amount_out_of_range. See ACH debit amount limits and Affirm amount limits.
Errors#
Every error uses the standard envelope. See Error handling.
Display amounts#
Convert out of minor units only when you display an amount, and let the formatter own symbols, separators, and the minus sign:
const MINOR_UNIT_DIGITS = { USD: 2 };
function formatMoney({ amount, currency }, locale = "en-US") {
const digits = MINOR_UNIT_DIGITS[currency];
if (digits === undefined) throw new Error(`Unsupported currency: ${currency}`);
return new Intl.NumberFormat(locale, {
style: "currency",
currency,
minimumFractionDigits: digits,
maximumFractionDigits: digits,
}).format(amount / 10 ** digits);
}
formatMoney({ amount: 2500, currency: "USD" }); // "$25.00"
formatMoney({ amount: -225, currency: "USD" }); // "-$2.25"
Keep the stored value as the integer. The formatted string is for people, not for arithmetic or storage.
In the SDKs#
The SDKs use the same minor units and field names as the HTTP API. Amounts and quantities are integer strings instead of numbers, so a value never passes through floating point on its way to Flint or back:
const order = await flint.orders.create(
{
line_items: [
{
type: "custom",
name: "Canvas tote bag",
quantity: "2",
unit_price_money: { amount: "1250", currency: "USD" },
fulfillment: { requirement: "none" },
},
],
},
{ idempotencyKey: "money-tote-002" },
);
order.pricing_amounts.total_money; // { amount: "2500", currency: "USD" }
"2500" is still 2,500 cents. Convert input to a minor-unit string before the call, and parse the returned strings with BigInt(), or with Number() only at the point you format for display.
