storj/satellite/payments/stripe/conversion.go
Michal Niewrzal 8a50a3baa3 satellite/payments: rename 'stripecoinpayments' package to 'stripe'
Automatic rename. May require some more cleanups later.

Change-Id: I18220a4278056d25c41fb137832bb81f2b876ac1
2023-04-06 16:51:43 +00:00

19 lines
440 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package stripe
import (
"github.com/shopspring/decimal"
"storj.io/common/currency"
)
// convertToCents convert amount to USD cents with given rate.
func convertToCents(rate decimal.Decimal, amount currency.Amount) int64 {
amountDecimal := amount.AsDecimal()
usd := amountDecimal.Mul(rate)
usdCents := usd.Shift(2)
return usdCents.Round(0).IntPart()
}