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.8.2 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.8.1 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.8.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.15 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.14 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.13 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.12 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.11 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.10 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.9 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.8 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.7 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.6 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.5 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.4 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.3 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.2 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.1 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.7.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.6.12 app/models/catarse_pagarme/transaction_base.rb