Module: Spree::CaptureMethod

Extended by:
ActiveSupport::Concern
Included in:
PaymentMethod, Store
Defined in:
app/models/concerns/spree/capture_method.rb

Overview

When a customer's card is charged, as opposed to only authorized.

A store sets the default and a payment method may override it, mirroring Spree::Channel::Gating: the method preference is nullable, so an unset value inherits the store's choice rather than meaning "checkout".

Constant Summary collapse

CAPTURE_METHODS =
  • checkout charge as soon as the order is placed
  • on_dispatch authorize at checkout, charge when goods are dispatched
  • manual authorize at checkout, leave charging to staff
%w[checkout on_dispatch manual].freeze
DEFAULT_CAPTURE_METHOD =

The value a store falls back to when nothing has been chosen.

'checkout'.freeze

Instance Method Summary collapse

Instance Method Details

#capture_at_checkout? ⇒ Boolean

Returns true when the money is taken as the order is placed.

Returns:

  • (Boolean) —

    true when the money is taken as the order is placed.



19
20
21
# File 'app/models/concerns/spree/capture_method.rb', line 19

def capture_at_checkout?
  resolved_capture_method == 'checkout'
end

#capture_manually? ⇒ Boolean

Returns true when only staff may take the money.

Returns:

  • (Boolean) —

    true when only staff may take the money.



29
30
31
# File 'app/models/concerns/spree/capture_method.rb', line 29

def capture_manually?
  resolved_capture_method == 'manual'
end

#capture_on_dispatch? ⇒ Boolean

Returns true when dispatching goods is what triggers the charge.

Returns:

  • (Boolean) —

    true when dispatching goods is what triggers the charge.



24
25
26
# File 'app/models/concerns/spree/capture_method.rb', line 24

def capture_on_dispatch?
  resolved_capture_method == 'on_dispatch'
end