Billing 0.14.0: Correct charges in yen, dinars and other currencies
Billing 0.14.0 fixes payments in currencies that do not have two decimal places: a charge in Japanese yen was 100 times too large. It also adds an optional way to pull exchange rates from an outside feed.
Charges in the right amount
Stripe, PayPal, Razorpay and EveryPay all converted amounts with a fixed factor of 100, which is right only for currencies with two decimals. A zero-decimal currency such as JPY or KRW was charged 100 times the intended amount, and a three-decimal one such as BHD or KWD lost its last digit. Checkouts, charges, refunds and incoming webhook confirmations now use the decimal places set for each currency. A transaction recorded without a currency is now refused, instead of being labelled as euros.
Exchange rates from a feed
Rates stay manual by default. A site can now set config :phoenix_kit, :fx_rate_provider, {module, function} to fetch them from an outside source and run mix phoenix_kit_billing.refresh_fx_rates. It only shows what would change; --apply writes the rates. The whole batch is refused if one rate is unknown, not a positive number, or more precise than the column holds, and the base currency is never touched. Nothing runs the task on a schedule.
Upgrading
No migration. Update the dependency. Charges now follow the Decimal Places of each currency on the Currencies page, so make sure they are right for the currencies you sell in.
Full release notes: Billing 0.14.0
0.14.0 · 8 September 2026
Per-domain currency, stage E5: exchange-rate provider hook and provider minor units (PR #38, #40).
Added
PhoenixKitBilling.refresh_rates_from_provider/1— an optional:fx_rate_providerhook (config :phoenix_kit, :fx_rate_provider, {mod, fun}) for a host that wants to pull exchange rates from an external feed. Rates otherwise stay manual, as before. Validates every entry before any write and refuses the whole batch on a single bad one (unknown currency, non-numeric, non-positive, or more/less precision thanphoenix_kit_currencies.exchange_rate’snumeric(15,6)column can hold), skips the base currency, and runs inside one transaction with the base currency row locked so it cannot straddle a concurrentset_default_currency/1orchange_base_currency/2. Ships withmix phoenix_kit_billing.refresh_fx_rates(dry-run by default,--applyto write) as the intended trigger — nothing schedules it automatically.PhoenixKitBilling.Providers.MinorUnits— converts between a shop-sideDecimalamount and a payment provider’s integer minor unit using the currency’s owndecimal_places, the single place this conversion now happens.
Fixed
- Every payment provider (Stripe, PayPal, Razorpay, EveryPay) converted
amounts using a hard-coded ×100 factor, correct only for two-decimal
currencies. A zero-decimal currency (JPY, KRW) was charged 100× its
intended amount; a three-decimal one (BHD, KWD) was silently truncated.
All four providers’ outbound (checkout/charge/refund) and inbound
(webhook confirmation) amount conversions now go through
MinorUnits, keyed off each currency’s actualdecimal_places. Transaction.currencyno longer silently defaults to"EUR". A caller that omits it now gets a validation error instead of a transaction honestly mislabeled with the wrong currency.
Billing 0.14.0. Install or update: {:phoenix_kit_billing, "~> 0.14"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.