Skip to content

Amounts & Currencies

Always use minor units (integers)

All monetary values in the Astro API are integers in the currency's minor unit. Never use decimals.

Value you sendMeaning
5000050.000 LYD
10000100.00 USD
75050750.50 EUR

No decimals

{ "amount": 5.00 } is invalid. Use { "amount": 5000 } for 5.000 LYD.

Currency field

Always include currency (ISO 4217) alongside any amount:

json
{
  "amount": 50000,
  "currency": "LYD"
}

Supported currencies

CodeNameMinor unit
LYDLibyan Dinar3 decimal places (1 LYD = 1000 minor units)
USDUS Dollar2 decimal places
EUREuro2 decimal places

Helper — converting from display values

typescript
// Display → minor units
const toMinor = (amount: number, currency: 'LYD' | 'USD' | 'EUR') => {
  const decimals = currency === 'LYD' ? 3 : 2
  return Math.round(amount * Math.pow(10, decimals))
}

toMinor(500, 'LYD')   // → 500000
toMinor(10.50, 'USD') // → 1050
dart
int toMinor(double amount, String currency) {
  final decimals = currency == 'LYD' ? 3 : 2;
  return (amount * pow(10, decimals)).round();
}
kotlin
fun toMinor(amount: Double, currency: String): Long {
    val decimals = if (currency == "LYD") 3 else 2
    return (amount * 10.0.pow(decimals)).roundToLong()
}
swift
func toMinor(_ amount: Double, currency: String) -> Int {
    let decimals = currency == "LYD" ? 3 : 2
    return Int((amount * pow(10.0, Double(decimals))).rounded())
}

Built on the OpenWave open standard.