Prices round up, discounts round down, and one package decides both
Munchable Premium is £10 a month. The price list has 24 currencies in it, and the rule the whole thing is built around is that the number you read is the number your card is charged. Not approximately, not after conversion at the last screen. The same number. That rule is easy to state and easy to break, because "show a price" and "charge a price" are normally two code paths in two parts of an…
The pricing system for Munchable Premium charges customers a fixed price in their local currency, without any approximation or conversion. The pricing is determined by a package containing currency information, product prices, and rounding rules. The package is separate from the Stripe client module, to prevent mixing Stripe SDK code with the component responsible for rendering the price.
Each currency has a single premium price, with local amounts derived from a fixed value in pence. Prices are rounded up using a two-step process: first, a conversion fee buffer is applied, and second, a retail round-up is performed based on the currency's formatting. Discounts, on the other hand, are rounded down using the plain mid-market rate.
The system also includes a guard to ensure that a zero discount does not result in an unexpected rounding up to a non-zero amount.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.