diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 70200fffa8..5d4eeb4d1a 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -33,7 +33,8 @@ class CheckoutController < ::BaseController def edit return handle_redirect_from_stripe if valid_payment_intent_provided? rescue Spree::Core::GatewayError => e - rescue_from_spree_gateway_error(e) + gateway_error(e) + action_failed(e) end def update @@ -42,7 +43,8 @@ class CheckoutController < ::BaseController checkout_workflow(params_adapter.shipping_method_id) rescue Spree::Core::GatewayError => e - rescue_from_spree_gateway_error(e) + gateway_error(e) + action_failed(e) rescue StandardError => e flash[:error] = I18n.t("checkout.failed") action_failed(e) @@ -204,11 +206,6 @@ class CheckoutController < ::BaseController end end - def rescue_from_spree_gateway_error(error) - flash[:error] = t(:spree_gateway_error_flash_for_checkout, error: error.message) - action_failed(error) - end - def permitted_params PermittedAttributes::Checkout.new(params).call end diff --git a/app/controllers/concerns/order_completion.rb b/app/controllers/concerns/order_completion.rb index e46047e29d..7d0fd08c2b 100644 --- a/app/controllers/concerns/order_completion.rb +++ b/app/controllers/concerns/order_completion.rb @@ -66,4 +66,8 @@ module OrderCompletion @order.errors.full_messages.to_sentence end + + def gateway_error(error) + flash[:error] = t(:spree_gateway_error_flash_for_checkout, error: error.message) + end end