Sha256: 7c3635dcca9a09b90fa9b664fbc98ec7197c31f5d1b2177f3474fbb1dd863ea3

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

module Spree  
  class Ebsinfo < ActiveRecord::Base
    # attr_accessible :first_name, :last_name, :transaction_id, :payment_id, :amount, :order_id

    belongs_to :order, :class_name => 'Spree::Order'

    NECESSARY = %w(Mode PaymentID DateCreated MerchantRefNo Amount TransactionID ResponseCode ResponseMessage).freeze

    def actions
      %w(mark_as_captured void)
    end
    
    # Indicates whether it's possible to capture the payment
    def can_mark_as_captured?(payment)
      ['checkout', 'pending'].include?(payment.state)
    end
    
    # Indicates whether it's possible to void the payment.
    def can_void?(payment)
      payment.state != 'void'
    end
    
    def mark_as_captured(payment)
      payment.update_attribute(:state, 'pending') if payment.state == 'checkout'
      payment.complete
      true
    end
    
    def void(payment)
      payment.update_attribute(:state, 'pending') if payment.state == 'checkout'
      payment.void
      true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_ebsin-3.1.1.2 app/models/spree/ebsinfo.rb
spree_ebsin-3.1.1.1 app/models/spree/ebsinfo.rb
spree_ebsin-2.1.0 app/models/spree/ebsinfo.rb