From 026e51081c5006ef3b510c012e9e5bea24f4b8a3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 12 Aug 2021 12:23:55 +0100 Subject: [PATCH] Clear invalid payments When going back and changing the payment option, the previous payment gets invalidated. --- app/controllers/split_checkout_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index e1c9950bef..1d1648ab11 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -51,6 +51,7 @@ class SplitCheckoutController < ::BaseController def update if confirm_order || update_order + clear_invalid_payments advance_order_state redirect_to_step else @@ -69,6 +70,10 @@ class SplitCheckoutController < ::BaseController private + def clear_invalid_payments + @order.payments.with_state(:invalid).delete_all + end + def confirm_order return unless @order.confirmation? && params[:confirm_order]