diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 4b7e947e76..50d9104368 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -129,13 +129,13 @@ class CheckoutController < ::BaseController end def handle_redirect_from_stripe - return checkout_failed unless @order.process_payments! + return processing_failed unless @order.process_payments! if OrderWorkflow.new(@order).next && order_complete? processing_succeeded redirect_to order_completion_route(@order) else - checkout_failed + processing_failed end end @@ -195,16 +195,10 @@ class CheckoutController < ::BaseController end def action_failed(error = RuntimeError.new(order_processing_error)) - checkout_failed(error) + processing_failed(error) action_failed_response end - def checkout_failed(error = RuntimeError.new(order_processing_error)) - Bugsnag.notify(error, order: @order) - flash[:error] = order_processing_error if flash.blank? - Checkout::PostCheckoutActions.new(@order).failure - end - def action_failed_response respond_to do |format| format.html do diff --git a/app/controllers/concerns/order_completion.rb b/app/controllers/concerns/order_completion.rb index 78f2bfbe3a..434bd49bc8 100644 --- a/app/controllers/concerns/order_completion.rb +++ b/app/controllers/concerns/order_completion.rb @@ -51,6 +51,12 @@ module OrderCompletion order_completion_reset(@order) end + def processing_failed(error = RuntimeError.new(order_processing_error)) + Bugsnag.notify(error, order: @order) + flash[:error] = order_processing_error if flash.blank? + Checkout::PostCheckoutActions.new(@order).failure + end + def order_processing_error return t(:payment_processing_failed) if @order.errors.blank? diff --git a/app/controllers/payment_gateways/paypal_controller.rb b/app/controllers/payment_gateways/paypal_controller.rb index 701b9b5a55..9b5258a31b 100644 --- a/app/controllers/payment_gateways/paypal_controller.rb +++ b/app/controllers/payment_gateways/paypal_controller.rb @@ -56,6 +56,7 @@ module PaymentGateways processing_succeeded redirect_to order_completion_route(@order) else + processing_failed redirect_to main_app.checkout_state_path(@order.state) end end