Class: Dune::Balanced::Bankaccount::PaymentBase
- Inherits:
-
Object
- Object
- Dune::Balanced::Bankaccount::PaymentBase
- Defined in:
- app/models/dune/balanced/bankaccount/payment_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#engine_name ⇒ Object
readonly
Returns the value of attribute engine_name.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #amount_in_cents ⇒ Object
- #checkout! ⇒ Object
- #debit ⇒ Object
- #fee_calculator ⇒ Object
-
#initialize(engine_name, customer, resource, attrs = {}) ⇒ PaymentBase
constructor
A new instance of PaymentBase.
- #status ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(engine_name, customer, resource, attrs = {}) ⇒ PaymentBase
Returns a new instance of PaymentBase.
5 6 7 8 9 10 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 5 def initialize(engine_name, customer, resource, attrs = {}) @engine_name = engine_name @customer = customer @resource = resource @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
3 4 5 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 3 def attrs @attrs end |
#engine_name ⇒ Object (readonly)
Returns the value of attribute engine_name.
3 4 5 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 3 def engine_name @engine_name end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 3 def resource @resource end |
Instance Method Details
#amount_in_cents ⇒ Object
12 13 14 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 12 def amount_in_cents (fee_calculator.gross_amount * 100).round end |
#checkout! ⇒ Object
36 37 38 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 36 def checkout! raise NotImplementedError end |
#debit ⇒ Object
28 29 30 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 28 def debit @debit.try(:sanitize) end |
#fee_calculator ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 16 def fee_calculator @fee_calculator and return @fee_calculator calculator_class = if ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include? attrs[:pay_fee] TransactionAdditionalFeeCalculator else TransactionInclusiveFeeCalculator end @fee_calculator = calculator_class.new(resource.value) end |
#status ⇒ Object
32 33 34 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 32 def status @debit.try(:status).try(:to_sym) || @status end |
#successful? ⇒ Boolean
40 41 42 |
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 40 def successful? raise NotImplementedError end |