Class: Spree::Payments::Process

Inherits:
Workflow
  • Object
show all
Includes:
InstrumentsGatewayCalls
Defined in:
app/workflows/spree/payments/process.rb

Overview

Processes a checkout payment at the gateway — authorize or purchase, chosen by the payment method's capture timing unless the caller forces a verb. The storefront batch (Purchase::PaymentProcessing) calls this once per payment; Payments::Capture re-authorizes a partial capture's remainder through it.

Instance Method Summary collapse

Methods inherited from Workflow

#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key

Methods included from ServiceModule::Base

#call, prepended

Methods included from Workflow::ControlFlow

#failure

Instance Method Details

#perform(payment:, action: nil) ⇒ Object

Parameters:

  • payment (Spree::Payment)
  • action (Symbol, nil) (defaults to: nil) —

    :authorize or :purchase; nil follows the payment method's capture timing



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/workflows/spree/payments/process.rb', line 16

def perform(payment:, action: nil)
  super

  step :ensure_processable
  run_hooks :validate
  run_hooks :before_process

  step :claim
  external_step :process_at_gateway

  run_hooks :after_process
  success(payment.reload)
end