Sha256: 38d7935c16f7334a0a00dab2243d28c506c8b3d0335f8b86eea11216e4b90661

Contents?: true

Size: 683 Bytes

Versions: 4

Compression:

Stored size: 683 Bytes

Contents

module Spree
  class PaymentMethod::Check < PaymentMethod
    def actions
      %w{capture void}
    end

    # Indicates whether its possible to capture the payment
    def can_capture?(payment)
      ['checkout', 'pending'].include?(payment.state)
    end

    # Indicates whether its possible to void the payment.
    def can_void?(payment)
      payment.state != 'void'
    end

    def capture(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

4 entries across 4 versions & 1 rubygems

Version Path
spree_core-1.0.0.rc4 app/models/spree/payment_method/check.rb
spree_core-1.0.0.rc3 app/models/spree/payment_method/check.rb
spree_core-1.0.0.rc2 app/models/spree/payment_method/check.rb
spree_core-1.0.0.rc1 app/models/spree/payment_method/check.rb