storj/satellite/payments/stripecoinpayments
paul cannon a16aecfa96 satellite/payments: specialized type for monetary amounts
Why: big.Float is not an ideal type for dealing with monetary amounts,
because no matter how high the precision, some non-integer decimal
values can not be represented exactly in base-2 floating point. Also,
storing gob-encoded big.Float values in the database makes it very hard
to use those values in meaningful queries, making it difficult to do
any sort of analysis on billing.

For better accuracy, then, we can just represent monetary values as
integers (in whatever base units are appropriate for the currency). For
example, STORJ tokens or Bitcoins can not be split into pieces smaller
than 10^-8, so we can store amounts of STORJ or BTC with precision
simply by moving the decimal point 8 digits to the right. For USD values
(assuming we don't want to deal with fractional cents), we can move the
decimal point 2 digits to the right.

To make it easier and less error-prone to deal with the math involved, I
introduce here a new type, monetary.Amount, instances of which have an
associated value _and_ a currency.

Change-Id: I03395d52f0e2473cf301361f6033722b54640265
2021-09-28 23:27:44 +00:00
..
accounts.go satellite/payments: Implement coupon codes 2021-07-26 17:15:55 +00:00
clearing.go all: fix error naming 2021-04-29 15:38:21 +03:00
client.go satellite/payments: Implement coupon codes 2021-07-26 17:15:55 +00:00
conversion.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00
coupons_test.go web/satellite: Allow users to see coupon in billing area 2021-08-14 16:09:54 -05:00
coupons.go web/satellite: Allow users to see coupon in billing area 2021-08-14 16:09:54 -05:00
creditcards_test.go satellite/{payments,admin}: add deletion of user creditcards on account deletion 2020-08-27 10:18:19 +00:00
creditcards.go satellite/payments: Implement coupon codes 2021-07-26 17:15:55 +00:00
customers_test.go satellite/payments/stripecoinpayments: fix test flakyness 2020-04-29 12:06:35 +00:00
customers.go satellite/billing: make stripe invoice generation work with multiregion satellites 2021-05-06 11:51:03 -06:00
db.go satellite/payments: delete credits and credits_spendings db tables 2020-07-30 12:19:57 +03:00
invoices.go satellite/payments: Implement coupon codes 2021-07-26 17:15:55 +00:00
projectrecords_test.go satellite/payments: delete credits and credits_spendings db tables 2020-07-30 12:19:57 +03:00
projectrecords.go satellite/payments: delete credits and credits_spendings db tables 2020-07-30 12:19:57 +03:00
service_test.go satellite/payments: fix invoice generation to include the last day of 2021-08-31 16:25:18 +00:00
service.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00
stripemock.go satellite/{payments,console},web/satellite: Adds confirmation step if user already has coupon code applied and wants to replace it 2021-08-11 20:04:23 +00:00
tokens_test.go satellite/payments: Implement coupon codes 2021-07-26 17:15:55 +00:00
tokens.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00
transactions_test.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00
transactions.go satellite/payments: specialized type for monetary amounts 2021-09-28 23:27:44 +00:00