Module: SolidusTaxCloud::Spree::CheckoutControllerDecorator

Defined in:
lib/decorators/frontend/controllers/solidus_tax_cloud/spree/checkout_controller_decorator.rb

Class Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/decorators/frontend/controllers/solidus_tax_cloud/spree/checkout_controller_decorator.rb', line 6

def self.prepended(base)
  base.class_eval do
    rescue_from SolidusTaxCloud::Error do |exception|
      flash[:error] = exception.message
      redirect_to checkout_state_path(:address)
    end

    rescue_from TaxCloud::Errors::ApiError do |exception|
      exception_message = exception.problem
      flash[:error] = I18n.t('spree.address_verification_failed') + (exception_message ? ": #{exception_message}" : '')
      redirect_to checkout_state_path(:address)
    end
  end
end