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 send | Meaning |
|---|---|
50000 | 50.000 LYD |
10000 | 100.00 USD |
75050 | 750.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
| Code | Name | Minor unit |
|---|---|---|
LYD | Libyan Dinar | 3 decimal places (1 LYD = 1000 minor units) |
USD | US Dollar | 2 decimal places |
EUR | Euro | 2 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') // → 1050dart
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())
}