bb1e86c790
issue: https://github.com/storj/storj/issues/4824 Change-Id: I2e3e63151d1def96270279719f6eceda0acba66c
19 lines
452 B
Go
19 lines
452 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package stripecoinpayments
|
|
|
|
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()
|
|
}
|