spree_multi_currency icon indicating copy to clipboard operation
spree_multi_currency copied to clipboard

Checkout API endpoints fails when updating an order with a shipping address

Open jsilland opened this issue 10 years ago • 1 comments

This is happening on a reasonably vanilla install of Spree 2.4, where spree_multi_currency 2.4-stable installed — the one customization that we have made and seems to be relevant in this case is that we set the session[:currency] field for each request based on the request's IP address, including for API requests.

The problem is relatively easy to track down:

  • CurrencyHelpers is included in ApplicationController by the SpreeMultiCurrency::Engine class in order to provide the supported_currencies method.
  • Separately, Spree::Core::ControllerHelpers::Order is augmented by a decorator in this gem to intercept the current_currency method and validate that it belongs to the supported_currencies available from every controller.
  • As it turns out, Spree::Api::CheckoutsController includes Spree::Core::ControllerHelpers::Order but does not have the supported_currencies method available, because it isn't a subclass of ApplicationController — API controllers inherit from ActionController::Base.

Proposed solution (that we are likely going to go with on our end) is to include the CurrencyHelpers in the Spree::Api::BaseController

jsilland avatar Jul 07 '15 01:07 jsilland

Thanks @jsilland , your notes were very helpful. :+1:

mdavo6 avatar Oct 11 '19 06:10 mdavo6