From b77ff346a36856ce563b0119e61fd2e03e2cc063 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 6 Dec 2021 13:36:39 +0000 Subject: [PATCH] Replace #raise with #return in Checkout::StripeRedirect The (potential) unhappy code path here was raising an error which would not be explicitly handled, and would in theory not return a useful message / response. --- app/controllers/checkout_controller.rb | 1 + app/services/checkout/stripe_redirect.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index a784bac015..29e1814e35 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -178,6 +178,7 @@ class CheckoutController < ::BaseController if @order.state == "payment" return if redirect_to_payment_gateway + return action_failed if @order.errors.any? return action_failed unless @order.process_payments! end diff --git a/app/services/checkout/stripe_redirect.rb b/app/services/checkout/stripe_redirect.rb index 8759471504..760db74615 100644 --- a/app/services/checkout/stripe_redirect.rb +++ b/app/services/checkout/stripe_redirect.rb @@ -16,7 +16,7 @@ module Checkout payment = payment_authorizer.call!(return_url) - raise if order.errors.any? + return if order.errors.any? stripe_payment_url(payment) end