Class: Spree::Carts::Complete
- Inherits:
-
Object
- Object
- Spree::Carts::Complete
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/carts/complete.rb
Instance Method Summary collapse
-
#call(cart:) ⇒ Spree::Order
Completes the cart and creates a Spree::Order based on its contents.
Methods included from ServiceModule::Base
Instance Method Details
#call(cart:) ⇒ Spree::Order
Completes the cart and creates a Spree::Order based on its contents.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/spree/carts/complete.rb', line 10 def call(cart:) return success(cart) if cart.completed? return failure(cart, 'Order is canceled') if cart.canceled? cart.with_lock do process_payments!(cart) if cart.payment_required? return failure(cart, cart.errors..to_sentence) if cart.errors.any? advance_to_complete!(cart) if cart.reload.complete? success(cart) else failure(cart, cart.errors..to_sentence.presence || 'Could not complete checkout') end end end |