From c1defdb1ffb11a6a5fc8c8f5e7a53775f29077f1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 5 Dec 2021 20:08:44 +0000 Subject: [PATCH] Extract #order_processing_error --- app/controllers/checkout_controller.rb | 14 +++----------- app/controllers/concerns/order_completion.rb | 6 ++++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 3484d80ca0..4b7e947e76 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -170,14 +170,6 @@ class CheckoutController < ::BaseController ) end - def order_error - if @order.errors.present? - @order.errors.full_messages.to_sentence - else - t(:payment_processing_failed) - end - end - def update_response if order_complete? processing_succeeded @@ -202,14 +194,14 @@ class CheckoutController < ::BaseController end end - def action_failed(error = RuntimeError.new(order_error)) + def action_failed(error = RuntimeError.new(order_processing_error)) checkout_failed(error) action_failed_response end - def checkout_failed(error = RuntimeError.new(order_error)) + def checkout_failed(error = RuntimeError.new(order_processing_error)) Bugsnag.notify(error, order: @order) - flash[:error] = order_error if flash.blank? + flash[:error] = order_processing_error if flash.blank? Checkout::PostCheckoutActions.new(@order).failure end diff --git a/app/controllers/concerns/order_completion.rb b/app/controllers/concerns/order_completion.rb index 8bae5a5e2c..78f2bfbe3a 100644 --- a/app/controllers/concerns/order_completion.rb +++ b/app/controllers/concerns/order_completion.rb @@ -50,4 +50,10 @@ module OrderCompletion Checkout::PostCheckoutActions.new(@order).success(params, spree_current_user) order_completion_reset(@order) end + + def order_processing_error + return t(:payment_processing_failed) if @order.errors.blank? + + @order.errors.full_messages.to_sentence + end end