Class: Dune::Balanced::Bankaccount::PaymentBase

Inherits:
Object
  • Object
show all
Defined in:
app/models/dune/balanced/bankaccount/payment_base.rb

Direct Known Subclasses

DelayedPayment, Payment

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attrsObject (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_nameObject (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

#resourceObject (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_centsObject



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

Raises:

  • (NotImplementedError)


36
37
38
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 36

def checkout!
  raise NotImplementedError
end

#debitObject



28
29
30
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 28

def debit
  @debit.try(:sanitize)
end

#fee_calculatorObject



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

#statusObject



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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


40
41
42
# File 'app/models/dune/balanced/bankaccount/payment_base.rb', line 40

def successful?
  raise NotImplementedError
end