Thesis: multi-currency e-commerce breaks in three places: the exchange rate you didn't save, the rounding you did per line instead of per order, and the refund you calculated at today's rate. Store money as integers with a currency code, snapshot the rate on every order, and refund in the currency and amount the customer actually paid.
Quick answer: multi-currency ecommerce done safely. Store every amount as an integer in minor units plus an ISO 4217 currency code. Use fixed price lists for your main markets and converted prices elsewhere. Save the exchange rate and its source on each order, round once per line with a documented rule, and refund in the original currency.
I wrote this with help from AI tools and checked every code sample myself. I run Loop Origin, a software studio that builds custom e-commerce and marketplace platforms.
The three currencies in every order
Most bugs start because a team thinks there's one currency per order. There are usually three:
- Presentment currency: what the shopper sees and pays, say EUR.
- Settlement currency: what your payment processor deposits into your bank, say USD.
- Reporting (functional) currency: what your books and dashboards use. Often the same as settlement, not always.
A multi-vendor marketplace adds a fourth: the payout currency each seller receives. If your schema only has one currency column on orders, you'll end up reverse-engineering the other three from processor exports later, which is exactly the reconciliation pain I described in Multi-Vendor Marketplace Payments: Ledgers & Payouts.
Pricing strategy: converted, fixed or hybrid
| Approach | How it works | Pros | Cons | Fits |
|---|---|---|---|---|
| Runtime conversion | Base price × live rate at render time | One price to maintain, every currency covered | Prices drift daily, ugly amounts like 18.37, cache headaches | Long tail of low-volume markets |
| Fixed price lists | A stored price per product per currency | Clean psychological prices, stable promos, predictable margins | More data to maintain, manual repricing when FX moves | Your top 2–5 markets |
| Hybrid | Fixed lists for main markets, converted plus rounding rules for the rest | Best of both, controlled effort | Two code paths to test | Most growing stores |
My default for clients is hybrid. Merchandisers set EUR and GBP prices deliberately; everything else converts from the base currency with a "round to a nice ending" rule applied per currency.
Schema: integers, codes and a rate snapshot
Floats are not money. 0.1 + 0.2 is not 0.3 in binary floating point, and the error compounds across line items, tax and discounts. Store minor units as BIGINT and keep the currency code next to every amount.
Minor units differ by currency. JPY has zero decimal places, USD and EUR have two, and KWD and BHD have three. Hard-coding "multiply by 100" is a bug waiting for your first Kuwaiti customer.
// database/migrations/2026_12_06_000001_create_fx_rates_and_order_money.php
Schema::create('fx_rates', function (Blueprint $table) {
$table->id();
$table->char('base', 3);
$table->char('quote', 3);
$table->decimal('rate', 18, 8); // 1 base = rate quote
$table->string('source', 40); // e.g. 'ecb', 'processor', 'manual'
$table->timestamp('fetched_at');
$table->unique(['base', 'quote', 'fetched_at']);
});
Schema::table('orders', function (Blueprint $table) {
$table->char('presentment_currency', 3);
$table->bigInteger('total_minor'); // in presentment currency
$table->char('settlement_currency', 3)->nullable();
$table->bigInteger('settlement_total_minor')->nullable(); // filled from processor
$table->foreignId('fx_rate_id')->nullable()->constrained('fx_rates');
});
Schema::table('order_lines', function (Blueprint $table) {
$table->bigInteger('unit_price_minor');
$table->bigInteger('line_total_minor');
$table->bigInteger('tax_minor');
});
The fx_rate_id is the important part. When finance asks why an order converted the way it did six months ago, you can answer from the database instead of guessing which rate was live that afternoon.
Conversion and rounding in one place
Put every conversion behind one service so rounding rules live in exactly one file. This sketch uses the brick/money package, which knows each currency's minor units and refuses to round silently unless you tell it how.
use Brick\Money\Money;
use Brick\Math\RoundingMode;
final class PriceConverter
{
public function __construct(private FxRateRepository $rates) {}
public function convert(Money $base, string $quote): array
{
$rate = $this->rates->latest($base->getCurrency()->getCurrencyCode(), $quote);
$converted = $base->convertedTo($quote, $rate->rate, null, RoundingMode::HALF_UP);
return [$this->charmRound($converted), $rate->id];
}
// Round up to a "nice" ending per currency, e.g. 18.37 EUR -> 18.99 EUR
private function charmRound(Money $m): Money
{
$code = $m->getCurrency()->getCurrencyCode();
if ($m->getCurrency()->getDefaultFractionDigits() === 0) {
// JPY and similar: round up to the next 10
$units = $m->getAmount()->toInt();
return Money::of((int) (ceil($units / 10) * 10), $code);
}
$whole = $m->getAmount()->toBigDecimal()->dividedBy(1, 0, RoundingMode::FLOOR);
return Money::of($whole->plus('0.99'), $code);
}
}
Treat charmRound as a merchandising decision, not a math one. Some markets expect whole numbers; some legal regimes require tax-inclusive display. Make the rule configurable per currency rather than hard-coding .99.
Round per line, then sum. If you convert the order total and then split it across lines, the lines won't add up to the total on the invoice, and your accounting sync will flag a one-cent difference on hundreds of orders. Convert unit prices, round them, multiply by quantity, and let the total be the sum. If you need to distribute a discount, use an allocation method such as Money::allocate() so the parts always add back up to the whole. The same "sum must balance" rule drives the stock ledger in Multi-Warehouse Inventory: A Stock Ledger That Balances.
Refunds: original currency, original amount
The rule that saves the most support tickets: refund what the customer paid, in the currency they paid it. A shopper who paid 49.99 EUR expects 49.99 EUR back, not a USD amount converted at today's rate.
That means:
- Refunds reference the original order lines and their stored
line_total_minorin the presentment currency. - Partial refunds use the same allocation logic as discounts, so three partial refunds never exceed the original charge by a rounding cent.
- The difference between what you received in settlement currency at purchase time and what the processor debits at refund time is an FX gain or loss. Record it as its own ledger entry; don't bury it inside the refund.
Processors handle conversion differently. Many convert presentment to settlement currency and charge a conversion fee, and refunds may be converted at a different rate than the original charge. Read your processor's currency documentation and store the settlement amount it reports via webhook rather than computing it yourself.
Failure modes I've seen in production
-
Stale cached rates. A cron job fetching rates died quietly; prices froze for weeks. Alert when the newest
fetched_atis older than your tolerance, the same idea as watching any silent scheduled task. - Cart total changes at checkout. The cart rendered with one rate and checkout re-priced with a newer one. Lock the rate into the cart session or quote for a fixed window.
- Float drift in exports. The app was correct, but a CSV export divided minor units with floats and accounting got 49.989999. Format money with the money library at the edge, never with raw division.
- Wrong decimals for zero-decimal currencies. An order for 1,500 JPY was sent to the processor as 150000 because the code multiplied by 100.
- Seller payouts at the wrong rate. Marketplace sellers were paid using the payout-day rate while commissions were calculated at order-time rates, so the ledger never balanced. Pick one policy, document it in seller terms and store the rate used.
If your accounting sync then pushes these orders to QuickBooks or Xero, send the currency and the stored rate explicitly, as covered in QuickBooks & Xero Invoice Sync Without Duplicates.
Implementation checklist
- Every amount column is an integer in minor units with a currency code beside it.
- Minor-unit precision comes from ISO 4217 data or your money library, never a hard-coded 100.
- Rates are stored with source and timestamp; every order references the rate it used.
- A monitor alerts when the newest rate is older than your tolerance.
- Fixed price lists exist for your main markets; converted prices use per-currency rounding rules.
- Rounding happens per unit price; totals are sums; discounts and partial refunds use allocation.
- The cart or quote locks a rate for a defined window.
- Refunds go back in the presentment currency for the original line amounts.
- FX gains and losses are separate ledger entries.
- Settlement amounts come from processor webhooks and are reconciled daily.
If you're planning a store or marketplace that has to sell across currencies, this is the kind of foundation my team designs at Loop Origin.
FAQ
Should I store prices as decimals or integers?
Integers in minor units, with a currency code. A database DECIMAL column is acceptable for storage, but integers make the rule explicit and stop anyone from loading the value into a float in application code.
Which exchange rate source should I use?
Any reputable source works if you store which one you used and when. Many stores use their processor's rates for checkout and a central bank reference rate for reporting. Consistency and an audit trail matter more than the provider.
How often should I refresh rates?
For converted catalog prices, daily is usually enough and keeps prices stable. Refresh more often only if margins are thin and the currency is volatile, and lock the rate into each cart so shoppers don't see totals jump.
Should discount codes be fixed amounts per currency?
Percentage discounts convert cleanly. Fixed-amount codes need a value per currency, such as 10 USD and 10 EUR set deliberately, otherwise a converted 9.21 EUR code looks broken to shoppers.
What about taxes in multiple currencies?
Calculate tax in the presentment currency on the rounded line amounts, then store it per line. Some jurisdictions require tax reported in local currency at a specific official rate, so keep the rate snapshot available for your tax reports.
Do I need multi-currency on day one?
Not always. If most of your sales are domestic, launch with one currency but use integer minor units and currency columns from the start. Adding currencies later is then a pricing project, not a data migration.
Follow & Connect
- LinkedIn: Loop Origin
- X: Muhammad Ali Mughal (@AliMughal887)
- GitHub: Loop Origin (@LoopOrigin)
Watch on YouTube: Resume Boost AI · PixelValut · Daily AI News By Ali

Top comments (0)