Closed mattgstevens closed 8 years ago
currencyTable
, and refresh every 5 minutes (good json)currency
-field in Content
recordconvertToSatoshi(currency, price, currencyTable)
invoice
that a user has to pay, we set it's satoshis
to be for instance convertToSatoshi('EUR', 0.05, currencyTable)
. paymentPrompt
Let me know what you think @mattgstevens :)
I implemented this, disregarding floating point rounding errors. It is right to be correct but done is better than perfect and worse is better.
Correct me if I'm wrong, but the rounding errors are on the order of 10^-17 (since 0.2 + 0.1 === 0.30000000000000004
). Worth it to ship quick.
We will want to store and do maths as integers since floating point math is not precise http://stackoverflow.com/questions/588004/is-floating-point-math-broken
When we support other currencies, we can translate from a "natural" currency number (like $5.67 or 5,67€) to our internal representation in pennies 567. Stripe is also storing the amount as an int for similar reasons https://stripe.com/docs/api#charge_object-amount