Sha256: 0b97ecc50dd7ac232ca389270dba5cdd80b217bfb4eef47f78dfa56dd1695923

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 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.to_s],
              :order => 'created_at DESC')
  end 
  
  def can_capture?
    txns.last == find_authorization
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kdmny-spree-0.0.1 app/models/creditcard_payment.rb