Sha256: 003c9084b66c4307cd174f36f5d9ca284e0b2d9f6ca0895d688502ada2ef32d4

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 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(*args)
      simulated_successful_billing_response
    end

    def cancel(response); end

    def void(*args)
      simulated_successful_billing_response
    end

    def source_required?
      false
    end

    def credit(*args)
      simulated_successful_billing_response
    end

    private

    def simulated_successful_billing_response
      ActiveMerchant::Billing::Response.new(true, "", {}, {})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-3.0.4 app/models/spree/payment_method/check.rb
spree_core-3.0.3 app/models/spree/payment_method/check.rb
spree_core-3.0.2 app/models/spree/payment_method/check.rb