Skip to navigation

Amounts and precision

How Mitu represents monetary amounts, so values are never rounded or misread between your systems and ours.
View as Markdown

Monetary amounts are easily corrupted in transit. Floating point numbers cannot represent most decimal values exactly, and an amount that is rounded or misread by even the smallest fraction can break reconciliation. Mitu follows a consistent set of rules for representing amounts, so every value arrives in your systems exactly as it was intended.

Representing amounts

1

Send amounts as numbers in requests

When you create a payment link, invoice or plan, send the amount as a number in the currency’s main unit, such as 25.00 for twenty five US dollars, never in cents or other minor units.

{ "amount": 25.00, "currency": "USD" }
2

Read amounts as decimal strings in responses

Amounts in responses and events are returned as strings, so that no precision is lost on the way to your systems. Parse them with a decimal type, never with a floating point number.

{ "amount": "25.00", "currency": "USD", "amount_paid": "25.000000" }
3

Expect the precision of each currency

Amounts in US dollars and naira carry two decimal places. Amounts in USDC carry up to six, which is the precision of USDC itself, so a payment received in USDC can show more decimal places than the price it settled.

4

Compare amounts as decimals

When you reconcile a payment against a record, compare decimal values rather than text, so that 25.00 and 25.000000 are treated as the same amount.

Precision by currency

CurrencyDecimal placesExample
US dollar (USD)225.00
Nigerian naira (NGN)27500.00
USDCUp to 625.000000

Precision practices

  1. Use a decimal type throughout
    Store and calculate amounts with a decimal type in your database and code, so values are never altered by conversion.
  2. Never round received amounts
    Record the amount exactly as returned, and round only for display.
  3. Reconcile on value, not on formatting
    Match payments to records by decimal value and currency, never by comparing formatted text.

Following these rules ensures that the amount a customer was asked to pay, the amount they paid and the amount in your records always agree, to the smallest unit.