Build · XOF · XAF · 0 DECIMALS

XOF has no cents, and your code probably assumes it does

Collecting and settling in XOF and XAF: why CFA franc amounts are whole numbers, the bugs a times-100 habit causes, and how to model money that works.

Ultraner team··4 min read

A customer in Abidjan taps "Pay 5,000 FCFA" on your site. Their phone buzzes with a prompt for 500,000 FCFA. They decline it, screenshot it, and post it in a WhatsApp group with your logo visible.

The bug that caused that is one line long, and almost every team that grew up on dollars or euros has written it at some point:

js
const amount = Math.round(price * 100);

It is correct for USD. It is correct for KES and ZMW. It is wrong for the two CFA francs, and they cover six of Ultraner's fourteen live markets.

Two currencies, fourteen countries, zero decimals

There are two CFA francs, and they are separate currencies even though they share a name and a peg.

  • XOF, the West African CFA franc, issued by the BCEAO for the eight member states of the West African monetary union 2. Among Ultraner's live markets: Senegal, Ivory Coast and Benin.
  • XAF, the Central African CFA franc, issued by the BEAC for six Central African states 3. Among Ultraner's live markets: Cameroon, Republic of Congo and Gabon.

ISO 4217, the standard that defines currency codes, gives both of them an exponent of zero 1. In plain terms: there is no minor unit. Nobody prices anything in centimes. 5,000 FCFA is the number 5000, all the way through.

Stripe, which most developers learned payments from, lists both on its zero-decimal currencies page 4. Ultraner's API follows the same rule as Stripe for every amount field: integers in the currency's smallest unit, which for XOF and XAF is the franc itself.

Displayamount for XOF / XAFamount if it were USD
50050050000
5,0005000500000
75,000750007500000

The four bugs a times-100 habit causes

1. The 100x prompt

The one in the opening. Your code multiplies, the API trusts you, the customer sees a number a hundred times too big. They decline. You lose the sale and some reputation.

2. The 1/100 order

The mirror image, and the dangerous one. Your frontend sends 5000 meaning 50.00 of something, your backend divides by 100 for display, and a 5,000 FCFA order shows as 50 FCFA in your admin. Or worse: you price in XOF but your reconciliation job divides by 100, and your books say you collected a hundredth of what you did.

3. Rounding that should not exist

A team that stores money as decimals will happily compute a 2.5% fee on 5,000 XOF as 125.00 and a 3% fee on 7,333 XOF as 219.99. There is no 0.99 franc. Every computed XOF or XAF amount needs to land on a whole number, and you have to decide which way to round and apply it consistently. Rounding in the customer's favour on what they pay, and against yourself on what you keep, is the conservative choice.

4. The "minimum charge" that is not

Many systems have a minimum like amount >= 100, written for cents, meaning 1.00. Applied to XOF it means 100 francs, which is a real but tiny amount. The opposite version, a maximum written in cents, will block legitimate large CFA payments. Check every hard-coded threshold in your payments code when you add a zero-decimal currency.

How to model it properly

Store money as an integer in the minor unit, plus the currency code. Never store floats. Never store "the amount in dollars" without the code beside it.

Then put the decimals in one place:

js
const ZERO_DECIMAL = new Set(['XOF', 'XAF', 'TZS', 'UGX', 'RWF']);

function toApiAmount(displayAmount, currency) {
  const decimals = ZERO_DECIMAL.has(currency) ? 0 : 2;
  return Math.round(displayAmount * 10 ** decimals);
}

function fromApiAmount(apiAmount, currency) {
  const decimals = ZERO_DECIMAL.has(currency) ? 0 : 2;
  return apiAmount / 10 ** decimals;
}

That set is a cut-down version for the African currencies that matter here. Ultraner's own list follows Stripe's zero-decimal list plus TZS, which is a deliberate addition: the Tanzanian shilling technically has two decimals in ISO 4217 but nobody uses them. If your code handles other currencies, use a complete table, not a guess. Each currency page states the rule for its currency, including XAF.

Collecting in CFA francs

A real collection in Ivory Coast looks like this:

POST /v5/payments/express/mno
{ "msisdn": "2250701234567", "amount": 5000, "currency": "XOF",
  "country": "CI", "provider": "Orange" }

Note the number. Ivorian mobile numbers are ten digits after 225, thirteen in total, longer than most of the region. The same charge in Cameroon would use 237 and nine digits, XAF, and provider: "MTN".

Two shared-currency facts are worth using:

  • One price list per franc. A product priced at 10,000 XOF reads naturally in Dakar, Abidjan and Cotonou. A product at 10,000 XAF reads naturally in Douala, Brazzaville and Libreville. You do not need six price lists for six countries.
  • XOF and XAF are not interchangeable in practice. They have the same value against the euro, but they are separate currencies from separate central banks. Do not send XOF for a Cameroonian customer because "it is the same thing". The rails will not agree with you.

Settling CFA francs

Collected francs land in your Ultraner balance. When you settle to your own bank account, which works in any country, the quote shows the FX rate if your bank account is in a different currency, the transfer fee, Ultraner's fee and what will land. It is computed by the same code that charges you, so it cannot disagree with what happens.

The thing to watch is the same rounding question in a new place. If you settle 1,250,000 XAF to a euro account, the conversion produces cents on the euro side. Your ledger has to accept that the XAF leg is a whole number and the EUR leg is not, and that is fine. What is not fine is a ledger column called amount with no currency next to it.

Wallet payouts into CFA wallets are not live yet. Tanzania is the live wallet payout market today, and the others are being brought up rail by rail. The settlement capability page describes what works everywhere now.

A test you can run this afternoon

Take your checkout, set the currency to XOF, and try three prices: 100, 5,000 and 250,000. For each, check four places: the price shown to the customer, the amount in the API request, the amount on the sandbox prompt, and the amount in your admin or ledger. All four should be the same number. If any of them differs by a factor of a hundred, you have found your bug before a customer in Abidjan found it for you.

Sources

  1. 1ISO 4217 Currency codes, ISO
  2. 2Banque Centrale des Etats de l'Afrique de l'Ouest, BCEAO
  3. 3Banque des Etats de l'Afrique Centrale, BEAC
  4. 4Zero-decimal currencies, Stripe Docs

For AI agents and tools: this article is also available as plain Markdown, every article is in the RSS feed, and the site guide for AI is at llms.txt.

Keep reading