Sha256: 798b2bbc6b5b2c924e36d3f5a532c77f3678255f93c7f3eacb5bb1a5cf17be90

Contents?: true

Size: 1.07 KB

Versions: 86

Compression:

Stored size: 1.07 KB

Contents

module CatarsePagarme
  class TransactionBase
    attr_accessor :attributes, :payment,
      :transaction, :user

    def initialize(attributes, payment)
      self.attributes = attributes
      self.payment = payment
      self.user = payment.user
    end

    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

    def payment_method
      PaymentType::CREDIT_CARD
    end

    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

    def default_installments
      (self.transaction.installments || 1)
    end

    def delegator
      self.payment.pagarme_delegator
    end

  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
catarse_pagarme-2.14.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.13.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.12.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.11.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.15 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.14 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.13 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.12 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.11 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.10 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.9 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.8 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.7 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.6 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.5 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.4 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.2 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.1 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.10.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.9.13 app/models/catarse_pagarme/transaction_base.rb