Major-unit amount (e.g. 10.50 dollars)
Currency code, any case (default: usd)
Amount in the smallest currency unit (e.g. 1050 for $10.50)
If currency is not a non-empty string, if
amount is not a finite number, or if the result is beyond
Number.MAX_SAFE_INTEGER
Convert a major-unit amount to the smallest currency unit Stripe expects.
Follows Stripe's currency rules (currency matching is case-insensitive):
usd,eur,huf,twd): × 100.bif clp djf gnf jpy kmf krw mga pyg rwf vnd vuv xaf xof xpf): × 1, rounded to a whole unit.bhd jod kwd omr tnd): × 1000, rounded to the nearest 10 because Stripe requires the last digit to be0.iskandugx: rounded to a whole unit, then × 100 (Stripe takes them as two-decimal values whose decimals are always00).Rounding is half away from zero, so a negative amount (e.g. a credit) mirrors its positive:
toMinor(-5.5, 'isk')is-600. A result of zero is always0, never-0.hufandtwdpayouts must be multiples of 100; this helper does not enforce that, since charges in those currencies may use two decimals.