3 ms·
Across major payment processors and subscription management systems like Stripe and through most of the stack, integers are used to represent how much to charge
by alehul 7y ago
Across major payment processors and subscription management systems like Stripe and through most of the stack, integers are used to represent how much to charge in the smallest currency unit. [1]
With that said, it's better not to reinvent the wheel here and follow the flow, and it's also the safer option— it's better to charge a customer $10 when you meant to charge them $1000, than it is to charge them $1000 when you meant to charge them $10.
[1] https://stripe.com/docs/api/charges/object#charge_object-amount https://stripe.com/docs/api/charges/object#charge_object-amo...
- tyre 7y agothis isn't re-inventing the wheel. This is how money is safely represented because floating point math is inexact. You end up with cases where the transaction is off ±1¢ (at least)