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
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 thesession[: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 inApplicationController
by theSpreeMultiCurrency::Engine
class in order to provide thesupported_currencies
method.Spree::Core::ControllerHelpers::Order
is augmented by a decorator in this gem to intercept thecurrent_currency
method and validate that it belongs to thesupported_currencies
available from every controller.Spree::Api::CheckoutsController
includesSpree::Core::ControllerHelpers::Order
but does not have thesupported_currencies
method available, because it isn't a subclass ofApplicationController
— API controllers inherit fromActionController::Base
.Proposed solution (that we are likely going to go with on our end) is to include the
CurrencyHelpers
in theSpree::Api::BaseController