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-3.0.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.16.3 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.16.2 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.16.1 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.16.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.15.0 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.14 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.13 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.12 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.11 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.10 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.9 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.8 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.7 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.6 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.5 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.4 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.3 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.2 app/models/catarse_pagarme/transaction_base.rb
catarse_pagarme-2.14.1 app/models/catarse_pagarme/transaction_base.rb