Sha256: 21df8954c1cc926812b731aa43e811300c91f0fff1d9d78643f9fbc12bcaef47

Contents?: true

Size: 989 Bytes

Versions: 2

Compression:

Stored size: 989 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

2 entries across 2 versions & 1 rubygems

Version Path
spree_ebsin-2.0.1 app/models/spree/ebsinfo.rb
spree_ebsin-2.0.0 app/models/spree/ebsinfo.rb