spree_multi_currency
spree_multi_currency copied to clipboard
Checkout API endpoints fails when updating an order with a shipping address
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:
-
CurrencyHelpersis included inApplicationControllerby theSpreeMultiCurrency::Engineclass in order to provide thesupported_currenciesmethod. - Separately,
Spree::Core::ControllerHelpers::Orderis augmented by a decorator in this gem to intercept thecurrent_currencymethod and validate that it belongs to thesupported_currenciesavailable from every controller. - As it turns out,
Spree::Api::CheckoutsControllerincludesSpree::Core::ControllerHelpers::Orderbut does not have thesupported_currenciesmethod 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 the Spree::Api::BaseController
Thanks @jsilland , your notes were very helpful. :+1: