Class: Spree::Api::V2::Storefront::CheckoutController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Spree::Api::V2::Storefront::CheckoutController
- Includes:
- OrderConcern
- Defined in:
- app/controllers/spree/api/v2/storefront/checkout_controller.rb
Instance Method Summary collapse
- #add_store_credit ⇒ Object
- #advance ⇒ Object
- #complete ⇒ Object
- #create_payment ⇒ Object
- #next ⇒ Object
- #payment_methods ⇒ Object
- #remove_store_credit ⇒ Object
- #select_shipping_method ⇒ Object
- #shipping_rates ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#add_store_credit ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 63 def add_store_credit :update, spree_current_order, order_token result = add_store_credit_service.call( order: spree_current_order, amount: params[:amount].try(:to_f) ) render_order(result) end |
#advance ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 17 def advance :update, spree_current_order, order_token result = advance_service.call(order: spree_current_order) render_order(result) end |
#complete ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 25 def complete :update, spree_current_order, order_token result = complete_service.call(order: spree_current_order) render_order(result) end |
#create_payment ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 47 def create_payment result = create_payment_service.call(order: spree_current_order, params: params) if result.success? render_serialized_payload(201) { serialize_resource(spree_current_order.reload) } else render_error_payload(result.error) end end |
#next ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 9 def next :update, spree_current_order, order_token result = next_service.call(order: spree_current_order) render_order(result) end |
#payment_methods ⇒ Object
91 92 93 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 91 def payment_methods render_serialized_payload { serialize_payment_methods(spree_current_order.available_payment_methods) } end |
#remove_store_credit ⇒ Object
74 75 76 77 78 79 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 74 def remove_store_credit :update, spree_current_order, order_token result = remove_store_credit_service.call(order: spree_current_order) render_order(result) end |
#select_shipping_method ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 57 def select_shipping_method result = select_shipping_method_service.call(order: spree_current_order, params: params) render_order(result) end |
#shipping_rates ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 81 def shipping_rates result = shipping_rates_service.call(order: spree_current_order) if result.success? render_serialized_payload { serialize_shipping_rates(result.value) } else render_error_payload(result.error) end end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/spree/api/v2/storefront/checkout_controller.rb', line 33 def update :update, spree_current_order, order_token result = update_service.call( order: spree_current_order, params: params, # defined in https://github.com/spree/spree/blob/master/core/lib/spree/core/controller_helpers/strong_parameters.rb#L19 permitted_attributes: permitted_checkout_attributes, request_env: request.headers.env ) render_order(result) end |