class StripeFee::Calculator
Public Class Methods
new(amount:, currency: 'usd')
click to toggle source
# File lib/stripe_fee/calculator.rb, line 8 def initialize amount:, currency: 'usd' @amount = amount @currency = currency end
Public Instance Methods
amount_in_cents()
click to toggle source
# File lib/stripe_fee/calculator.rb, line 18 def amount_in_cents @amount.to_f * 100 end
charge_amount_in_cents()
click to toggle source
# File lib/stripe_fee/calculator.rb, line 22 def charge_amount_in_cents validate! ((amount_in_cents + 30)/(1 - 0.029)).round end
validate!()
click to toggle source
# File lib/stripe_fee/calculator.rb, line 13 def validate! raise ::AmountError unless @amount.to_f && @amount.to_f > 0 raise ::CurrencyError unless @currency == 'usd' end