Class: Dune::Balanced::Bankaccount::Payment
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
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
|
#contributor ⇒ Object
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_href ⇒ Object
23
24
25
|
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 23
def debit_resource_href
attrs.fetch(:use_bank) { contributor.bank_account_href }
end
|
#successful? ⇒ Boolean
19
20
21
|
# File 'app/models/dune/balanced/bankaccount/payment.rb', line 19
def successful?
%i(pending succeeded).include? status
end
|