Class: SpreeCmCommissioner::Checkout::AdvanceToPayment

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/checkout/advance_to_payment.rb

Overview

Same as Spree::Checkout::Advance, but stops at payment instead of running on to confirm. Lets a client reach the payment step in one call instead of stepping through next state by state -- useful wherever the checkout doesn't need per-state client input in between (e.g. a top-up order, or a booking flow where guest info is already assigned so there's nothing for the client to fill in at the address/delivery states). Fails with the order's error message when it can't get there.

Instance Method Summary collapse

Instance Method Details

#call(order:) ⇒ Object



12
13
14
15
16
17
18
# File 'app/services/spree_cm_commissioner/checkout/advance_to_payment.rb', line 12

def call(order:)
  Spree::Dependencies.checkout_next_service.constantize.call(order: order) until cannot_make_transition?(order)

  return success(order) if order.payment?

  failure(order, order.errors.full_messages.to_sentence.presence)
end