Sha256: 3f68ec46dbe0855574af4d404f7d73e4bc51df8e7b8ed8c49b9ce80f572b223a

Contents?: true

Size: 1011 Bytes

Versions: 11

Compression:

Stored size: 1011 Bytes

Contents

module PagarMe
  class TransactionCommon < Model

    def initialize(response = {})
      super(response)

      self.payment_method ||= 'credit_card'
      self.installments   ||= 1
      self.status         ||= 'local'
    end

    def create
      check_card_object
      super
    end

    def save
      check_card_object
      super
    end

    private
    def check_card_object
      if card
        if card.id
          self.card_id = self.card.id
        else
          self.card_number           = card.card_number
          self.card_holder_name      = card.card_holder_name
          self.card_expiration_year  = card.card_expiration_year
          self.card_expiration_month = card.card_expiration_month
          self.card_cvv              = card.card_cvv
          self.card_expiration_date  = "#{card_expiration_month}#{card_expiration_year}"
        end
        self.card = nil
      end

      self.card_expiration_date ||= "#{card_expiration_month}#{card_expiration_year}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pagarme-2.4.0 lib/pagarme/transaction_common.rb
pagarme-2.3.0 lib/pagarme/transaction_common.rb
pagarme-2.2.3 lib/pagarme/transaction_common.rb
pagarme-2.2.2 lib/pagarme/transaction_common.rb
pagarme-2.2.1 lib/pagarme/transaction_common.rb
pagarme-2.2.0 lib/pagarme/transaction_common.rb
pagarme-2.1.4 lib/pagarme/transaction_common.rb
pagarme-2.1.3 lib/pagarme/transaction_common.rb
pagarme-2.1.2 lib/pagarme/transaction_common.rb
pagarme-2.1.1 lib/pagarme/transaction_common.rb
pagarme-2.1.0 lib/pagarme/transaction_common.rb