
A checkout page shows ₦1,250.75. The payment API wants 125075. Those are not two prices. They are two ways of representing the same amount: naira for the customer, kobo for the API.
It is tempting to write amount * 100 and move on. That works for a naira amount expressed in naira when the endpoint expects kobo, but the same shortcut can overcharge in another currency or multiply an amount you already converted. The useful rule is: convert once, at a clearly defined boundary, using the rules of the endpoint you are calling.
Start with the naira example
One naira is 100 kobo. If a customer owes ₦1,250.75, the naira portion accounts for 125,000 kobo and the remaining 75 kobo brings the total to 125,075. Paystack’s currency documentation specifies kobo for NGN amounts. The amount and currency fields in a checkout request would therefore look like this:
{
"currency": "NGN",
"amount": 125075
}
That is the amount fragment, not a complete checkout request. Sending 1250 would represent ₦12.50, not ₦1,250.75, even if the endpoint ultimately rejects it for another reason. Multiplying 125075 a second time would represent ₦125,075.00. The problem in both cases is the unit, not the arithmetic.
A currency code is not the whole API contract
There are two questions to answer: Can this amount contain a fraction? and How does this endpoint encode the amount? A currency can have no fractional units and still be represented by an API integer with two trailing zeros.
- Ordinary zero-decimal case: For a Stripe charge of ¥500, send
500, not50000. - Legacy encoding: For a Stripe charge of 12 ISK, send
1200. The API uses two trailing zeros for compatibility, but you cannot charge 12.34 ISK. Paystack similarly documents a factor of 100 for XOF even though XOF has no subunit. - Operation-specific rule: Stripe permits fractional HUF charges, but a manual payout amount must be divisible by 100 in the API representation. A HUF 25 payout is
2500; you cannot send2545to manually pay out HUF 25.45.
These examples describe amount formatting, not whether a provider offers a currency or operation for your particular account. Check the Stripe currency exceptions and your provider’s documentation for the specific operation. An ISO currency table is a useful starting point for money in your application. It cannot tell you which exceptions an API has chosen for compatibility.
Keep the meaning attached to the number
Give the amount a unit wherever it crosses a boundary. For example, an order record could contain amount_minor = 125075 and currency = NGN. A text box or external import might instead supply "1250.75" as a major-unit decimal string. Label those values differently and make the conversion explicit. A function receiving an unnamed amount cannot tell which form it has.
Parse a decimal string exactly, or use a decimal type designed for financial arithmetic. Do not make a binary floating-point calculation and then truncate it into an integer: a value that should land on a whole subunit can end up just below it. If the customer enters more precision than you support, reject it or apply an explicit rounding rule. Do not let a cast silently make that decision.
Put provider-specific formatting in the adapter that sends the request. For the example above, the internal NGN minor-unit integer already matches Paystack’s expected amount, so the adapter should pass it through. A whole-unit currency that needs trailing zeros should be encoded there, without changing the underlying order value.
Test more than a round number
A useful test set includes a fractional naira amount, a zero-decimal amount, a provider exception, an excess-precision input and a retry. Test that retrying the same order sends exactly the same encoded amount, not an amount converted again. Also check the provider’s minimums and maximums separately from its formatting rules.
When confirming payment, compare the provider-reported currency and amount with what your server expected for that order. If the values are in different representations, normalise them before comparing. Never mark an order paid because the returned status is successful while its amount or currency does not match.
The best check is simple: can another engineer tell from the field name or type whether 125075 is a price, a minor-unit amount or a provider-encoded integer? If they have to guess, the conversion bug is still waiting for them.