From 6b72bf92ce9586a04224ef7a56c1df190899acec Mon Sep 17 00:00:00 2001 From: Yaroslav Vorobiov Date: Wed, 29 Jan 2020 00:06:01 -0500 Subject: [PATCH] satellite/payments: convert egress price to per byte basis Change-Id: Ia3a07d0afa5d9d55871996a1d2117b4ec290ce8f --- satellite/payments/stripecoinpayments/service.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/satellite/payments/stripecoinpayments/service.go b/satellite/payments/stripecoinpayments/service.go index a0a83f02d..72f123914 100644 --- a/satellite/payments/stripecoinpayments/service.go +++ b/satellite/payments/stripecoinpayments/service.go @@ -89,7 +89,7 @@ func NewService(log *zap.Logger, config Config, db DB, projectsDB console.Projec if err != nil { return nil, err } - egressByteDollars, err := decimal.NewFromString(egressTBPrice) + egressTBDollars, err := decimal.NewFromString(egressTBPrice) if err != nil { return nil, err } @@ -100,7 +100,7 @@ func NewService(log *zap.Logger, config Config, db DB, projectsDB console.Projec // change the precision from dollars to cents tbMonthCents := tbMonthDollars.Shift(2) - egressByteCents := egressByteDollars.Shift(2) + egressTBCents := egressTBDollars.Shift(2) objectHourCents := objectMonthDollars.Shift(2) // get per hour prices from storage and objects @@ -109,8 +109,9 @@ func NewService(log *zap.Logger, config Config, db DB, projectsDB console.Projec tbHourCents := tbMonthCents.Div(hoursPerMonth) objectHourCents = objectHourCents.Div(hoursPerMonth) - // convert tb to bytes for storage price + // convert tb to bytes for storage and egress byteHourCents := tbHourCents.Div(decimal.New(1000000000000, 0)) + egressByteCents := egressTBCents.Div(decimal.New(1000000000000, 0)) return &Service{ log: log,