Skip to content

Money and currencies

All monetary amounts in the Quarzo API are represented as integers in the smallest currency unit — cents for EUR, pence for GBP, and so on. There are no decimals, no floating-point numbers.

json
{
  "amount": 10050,
  "currency": "EUR"
}

This represents €100.50, not 10 050 euros.

Why integers

Floating-point arithmetic is notoriously unreliable for financial calculations. 0.1 + 0.2 does not equal 0.3 in most programming environments. Storing amounts as integers eliminates rounding errors entirely.

Formatting for display

It is better to format monetary amounts before displaying them to users instead of exposing the raw integer. Each currency has its own minor-unit exponent — dividing everything by 100 is wrong for currencies like JPY (exponent 0) or KWD (exponent 3).

Use Intl to read the correct exponent for each currency:

js
function minorUnitFactor(currency) {
  const fmt = new Intl.NumberFormat('fr-FR', { style: 'currency', currency })
  return Math.pow(10, fmt.resolvedOptions().minimumFractionDigits)
}

function formatAmount(amount, currency) {
  return new Intl.NumberFormat('fr-FR', {
    style: 'currency',
    currency,
  }).format(amount / minorUnitFactor(currency))
}

formatAmount(10050, 'EUR') // → "100,50 €"  (÷ 100)
formatAmount(599,   'EUR') // → "5,99 €"
formatAmount(1500,  'JPY') // → "1 500 ¥"   (÷ 1)
formatAmount(1234,  'KWD') // → "1,234 د.ك." (÷ 1000)

Verify the exponent for each currency you support

Intl uses the ISO 4217 standard exponents. This function works correctly for all major currencies, but a handful of exotic currencies are handled inconsistently across payment processors - some represent them with a different exponent than ISO 4217 specifies.

Money libraries

Rather than managing integer arithmetic yourself, consider using a dedicated money library for your language. These libraries handle subunit conversion, currency-aware formatting, and safe arithmetic out of the box.

You can find some proposed libraries below. These are provided for guidance only and should not be considered recommendations.

LanguageLibrary
JavaScript / TypeScriptdinero.js, Moneta
Pythonpy-moneyed
Rubymoney
PHPmoneyphp/money
Java / KotlinJavaMoney (JSR 354)
Gobojanz/currency

Supported currencies

All amounts must be paired with an explicit currency field using the ISO 4217 three-letter code.

Currency others than EUR could be used to show information about underlying assets of Unit Linked funds.

CurrencyCodeSmallest unit
EuroEURCent (÷ 100)
Pound sterlingGBPPenny (÷ 100)
Swiss francCHFRappen (÷ 100)
US dollarUSDCent (÷ 100)

Zero-decimal currencies

Some currencies — like JPY — have no subunit. For these, pass the amount as-is: { "amount": 1200, "currency": "JPY" } represents ¥1,200.

Common mistakes

Do not pass floats. The API will reject non-integer values.

json
// ❌ Invalid
{ "amount": 100.50, "currency": "EUR" }

// ✅ Correct
{ "amount": 10050, "currency": "EUR" }

Do not omit currency. Every amount field must be accompanied by a currency code. Requests missing currency will return a 422 Unprocessable Entity error.