Class: Dune::Balanced::Bankaccount::PaymentGenerator
- Inherits:
-
Object
- Object
- Dune::Balanced::Bankaccount::PaymentGenerator
- Defined in:
- app/models/dune/balanced/bankaccount/payment_generator.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #can_debit_resource? ⇒ Boolean
- #complete ⇒ Object
- #debit_resource ⇒ Object
-
#initialize(customer, resource, attrs = {}) ⇒ PaymentGenerator
constructor
A new instance of PaymentGenerator.
- #payment ⇒ Object
- #payment_class ⇒ Object
Constructor Details
#initialize(customer, resource, attrs = {}) ⇒ PaymentGenerator
Returns a new instance of PaymentGenerator.
7 8 9 10 11 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 7 def initialize(customer, resource, attrs = {}) @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_generator.rb', line 3 def attrs @attrs end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
3 4 5 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 3 def customer @customer end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 3 def resource @resource end |
Instance Method Details
#can_debit_resource? ⇒ Boolean
30 31 32 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 30 def can_debit_resource? debit_resource.bank_account_verifications.to_a.first.try(:verification_status).eql? 'succeeded' end |
#complete ⇒ Object
13 14 15 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 13 def complete payment.checkout! end |
#debit_resource ⇒ Object
34 35 36 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 34 def debit_resource @debit_resource ||= ::Balanced::BankAccount.find(@attrs.fetch(:use_bank)) end |
#payment ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 17 def payment @payment ||= payment_class.new( 'balanced-bankaccount', customer, resource, attrs ) end |
#payment_class ⇒ Object
26 27 28 |
# File 'app/models/dune/balanced/bankaccount/payment_generator.rb', line 26 def payment_class @payment_class ||= can_debit_resource? ? Dune::Balanced::Bankaccount::Payment : Dune::Balanced::Bankaccount::DelayedPayment end |