Class: Workarea::Api::Storefront::CheckoutsController
- Inherits:
-
ApplicationController
- Object
- Workarea::ApplicationController
- ApplicationController
- Workarea::Api::Storefront::CheckoutsController
- Includes:
- CurrentCheckout
- Defined in:
- app/controllers/workarea/api/storefront/checkouts_controller.rb
Defined Under Namespace
Classes: InvalidCheckout
Instance Method Summary collapse
Methods included from CurrentCheckout
#current_checkout, #current_order
Methods inherited from ApplicationController
#assert_current_metrics_id, #cache_page, #skip_session
Methods included from Authentication
#authentication?, #current_user, find_user
Instance Method Details
#complete ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/workarea/api/storefront/checkouts_controller.rb', line 30 def complete payment = Workarea::Checkout::Steps::Payment.new(current_checkout) payment.update(params) if payment.complete? && current_checkout.place_order Workarea::Storefront::OrderMailer .confirmation(current_order.id) .deliver_later @order = Workarea::Storefront::OrderViewModel.new(current_order) render template: 'workarea/api/storefront/orders/show' else flash[:error] = t('workarea.storefront.flash_messages.order_place_error') render_checkout status: :unprocessable_entity end end |
#reset ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/workarea/api/storefront/checkouts_controller.rb', line 48 def reset current_checkout.reset! start_checkout render_checkout end |
#show ⇒ Object
21 22 23 |
# File 'app/controllers/workarea/api/storefront/checkouts_controller.rb', line 21 def show render_checkout end |
#update ⇒ Object
25 26 27 28 |
# File 'app/controllers/workarea/api/storefront/checkouts_controller.rb', line 25 def update success = current_checkout.update(params) render_checkout(status: success ? :ok : :unprocessable_entity) end |