Class: Dune::Balanced::Bankaccount::Payment

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

Instance Attribute Summary

Attributes inherited from PaymentBase

#attrs, #engine_name, #resource

Instance Method Summary collapse

Methods inherited from PaymentBase

#amount_in_cents, #debit, #fee_calculator, #initialize, #status

Constructor Details

This class inherits a constructor from Dune::Balanced::Bankaccount::PaymentBase

Instance Method Details

#checkout!Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 3

def checkout!
  perform_debit!
  resource.confirm
rescue Balanced::BadRequest
  @status = :failed
  resource.cancel
ensure
  resource.update_attributes(
    payment_id:                       @debit.try(:id),
    payment_method:                   engine_name,
    payment_service_fee:              fee_calculator.fees,
    payment_service_fee_paid_by_user: attrs[:pay_fee]
  )
  update_meta(@debit) if @debit
end

#contributorObject



27
28
29
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 27

def contributor
  @contributor ||= Dune::Balanced::Contributor.find_by(href: @customer.href)
end

#debit_resource_hrefObject



23
24
25
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 23

def debit_resource_href
  attrs.fetch(:use_bank) { contributor. }
end

#successful?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 19

def successful?
  %i(pending succeeded).include? status
end