Class: CatarsePagarme::TransactionBase
- Inherits:
-
Object
- Object
- CatarsePagarme::TransactionBase
- Defined in:
- app/models/catarse_pagarme/transaction_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#payment ⇒ Object
Returns the value of attribute payment.
-
#transaction ⇒ Object
Returns the value of attribute transaction.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #attributes_to_payment ⇒ Object
- #change_payment_state ⇒ Object
- #default_installments ⇒ Object
- #delegator ⇒ Object
-
#initialize(attributes, payment) ⇒ TransactionBase
constructor
A new instance of TransactionBase.
- #payment_method ⇒ Object
Constructor Details
#initialize(attributes, payment) ⇒ TransactionBase
Returns a new instance of TransactionBase.
6 7 8 9 10 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 6 def initialize(attributes, payment) self.attributes = attributes self.payment = payment self.user = payment.user end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 3 def attributes @attributes end |
#payment ⇒ Object
Returns the value of attribute payment.
3 4 5 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 3 def payment @payment end |
#transaction ⇒ Object
Returns the value of attribute transaction.
3 4 5 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 3 def transaction @transaction end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 3 def user @user end |
Instance Method Details
#attributes_to_payment ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 24 def attributes_to_payment { payment_method: payment_method, gateway_id: self.transaction.id, gateway: 'Pagarme', gateway_data: self.transaction.to_json, installments: default_installments } end |
#change_payment_state ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 12 def change_payment_state self.payment.update_attributes(attributes_to_payment) self.payment.save! delegator.update_transaction self.payment.payment_notifications.create(contribution_id: self.payment.contribution_id, extra_data: self.transaction.to_json) delegator.change_status_by_transaction(self.transaction.status) end |
#default_installments ⇒ Object
34 35 36 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 34 def default_installments (self.transaction.installments || 1) end |
#delegator ⇒ Object
38 39 40 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 38 def delegator self.payment.pagarme_delegator end |
#payment_method ⇒ Object
20 21 22 |
# File 'app/models/catarse_pagarme/transaction_base.rb', line 20 def payment_method PaymentType::CREDIT_CARD end |