Sha256: 9d1a68c6a2e041a06265603d03b1e37702d041b8fb0c934428509a743794a237
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
module CatarsePagarme::FeeCalculatorConcern extend ActiveSupport::Concern included do def get_fee(payment_method, acquirer_name = nil) if payment_method == ::CatarsePagarme::PaymentType::SLIP CatarsePagarme.configuration.slip_tax.to_f else if acquirer_name == 'stone' self.contribution.installments > 1 ? tax_calc_for_installment(stone_tax) : tax_calc(stone_tax) else current_tax = self.transaction.card_brand == 'diners' ? installment_diners_tax : installment_not_diners_tax self.contribution.installments > 1 ? tax_calc_for_installment(current_tax) : tax_calc(cielo_tax) end end end protected def tax_calc acquirer_tax ((self.contribution.value * pagarme_tax) + cents_fee).round(2) + (self.contribution.value * acquirer_tax).round(2) end def tax_calc_for_installment acquirer_tax (((self.contribution.installment_value * self.contribution.installments) * pagarme_tax) + cents_fee).round(2) + ((self.contribution.installment_value * acquirer_tax).round(2) * self.contribution.installments) end def cents_fee CatarsePagarme.configuration.credit_card_cents_fee.to_f end def pagarme_tax CatarsePagarme.configuration.pagarme_tax.to_f end def cielo_tax CatarsePagarme.configuration.cielo_tax.to_f end def stone_tax CatarsePagarme.configuration.stone_tax.to_f end def installment_diners_tax CatarsePagarme.configuration.cielo_installment_diners_tax.to_f end def installment_not_diners_tax CatarsePagarme.configuration.cielo_installment_not_diners_tax.to_f end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
catarse_pagarme-1.5.0 | app/models/catarse_pagarme/fee_calculator_concern.rb |
catarse_pagarme-2.4.0 | app/models/catarse_pagarme/fee_calculator_concern.rb |