mirror of
https://github.com/discourse/discourse.git
synced 2026-07-31 16:48:26 -05:00
Setting a subscription price like $19.99 would fail with "Invalid
integer 1998.9999999999998" from the Stripe API.
Due to IEEE-754 floating point arithmetic, `parseFloat("19.99") * 100`
produces `1998.9999999999998` instead of `1999`. This non-integer value
is then sent directly to Stripe which rejects it.
Wrapping the multiplication in `Math.round()` ensures the result is
always a proper integer before being stored as `unit_amount`.
https://meta.discourse.org/t/393466