Sha256: b13d0bbc694489a26397bb87b8b7db4659d305206df9483b38bc2f13b187a69c

Contents?: true

Size: 1.09 KB

Versions: 51

Compression:

Stored size: 1.09 KB

Contents

module Caboose
  class OrderTransaction < ActiveRecord::Base
    self.table_name  = 'store_order_transactions'
    self.primary_key = 'id'
    
    belongs_to :order
    attr_accessible :id,    
      :order_id,
      :transaction_id,
      :transaction_type,
      :amount,
      :auth_code,
      :date_processed,
      :response_code,
      :success 
        
    TYPE_AUTHORIZE = 'auth'
    TYPE_CAPTURE   = 'capture'
    TYPE_VOID      = 'void'
    TYPE_REFUND    = 'refund'
    
    after_initialize :check_nil_fields
    
    def check_nil_fields
      self.amount = 0.00 if self.amount.nil?        
    end
    
    def self.type_from_authnet_status(status)
      case status
        when 'settledSuccessfully'        then OrderTransaction::TYPE_CAPTURE
        when 'voided'                     then OrderTransaction::TYPE_VOID
        when 'declined'                   then OrderTransaction::TYPE_AUTHORIZE
        when 'authorizedPendingCapture'   then OrderTransaction::TYPE_AUTHORIZE
        when 'refundSettledSuccessfully'  then OrderTransaction::TYPE_REFUND
      end
    end
    
  end
end
   
    

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
caboose-cms-0.7.85 app/models/caboose/order_transaction.rb
caboose-cms-0.7.84 app/models/caboose/order_transaction.rb
caboose-cms-0.7.83 app/models/caboose/order_transaction.rb
caboose-cms-0.7.82 app/models/caboose/order_transaction.rb
caboose-cms-0.7.81 app/models/caboose/order_transaction.rb
caboose-cms-0.7.80 app/models/caboose/order_transaction.rb
caboose-cms-0.7.79 app/models/caboose/order_transaction.rb
caboose-cms-0.7.78 app/models/caboose/order_transaction.rb
caboose-cms-0.7.77 app/models/caboose/order_transaction.rb
caboose-cms-0.7.76 app/models/caboose/order_transaction.rb
caboose-cms-0.7.75 app/models/caboose/order_transaction.rb
caboose-cms-0.7.74 app/models/caboose/order_transaction.rb
caboose-cms-0.7.73 app/models/caboose/order_transaction.rb
caboose-cms-0.7.72 app/models/caboose/order_transaction.rb
caboose-cms-0.7.71 app/models/caboose/order_transaction.rb
caboose-cms-0.7.70 app/models/caboose/order_transaction.rb
caboose-cms-0.7.69 app/models/caboose/order_transaction.rb
caboose-cms-0.7.68 app/models/caboose/order_transaction.rb
caboose-cms-0.7.67 app/models/caboose/order_transaction.rb
caboose-cms-0.7.66 app/models/caboose/order_transaction.rb