Sha256: 768d7bb16795eb31533e8c739f4d369afad3e71ca4fd9b0515b5d636d7d87101

Contents?: true

Size: 523 Bytes

Versions: 6

Compression:

Stored size: 523 Bytes

Contents

class CreditcardPayment < Payment
  has_many :creditcard_txns
  belongs_to :creditcard
  accepts_nested_attributes_for :creditcard
  
  alias :txns :creditcard_txns
  
  def find_authorization
    #find the transaction associated with the original authorization/capture 
    txns.find(:first, 
              :conditions => ["txn_type = ? AND response_code IS NOT NULL", CreditcardTxn::TxnType::AUTHORIZE],
              :order => 'created_at DESC')
  end 
  
  def can_capture?
    txns.last == find_authorization
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree-0.8.4 app/models/creditcard_payment.rb
spree-0.8.5 app/models/creditcard_payment.rb
spree-0.8.0 app/models/creditcard_payment.rb
spree-0.8.1 app/models/creditcard_payment.rb
spree-0.8.2 app/models/creditcard_payment.rb
spree-0.8.3 app/models/creditcard_payment.rb