From e1393c96ca2ca7138d171253199d03eebe3a84c3 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Tue, 27 Jul 2021 23:24:00 +0100 Subject: [PATCH] Correctly void transactions when payments are cancelled due to stock issues --- app/controllers/checkout_controller.rb | 2 +- spec/controllers/checkout_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 547f180a72..cffa0877b7 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -119,7 +119,7 @@ class CheckoutController < ::BaseController # The checkout could not complete due to stock running out. We void any pending (incomplete) # Stripe payments here as the order will need to be changed and resubmitted (or abandoned). @order.payments.incomplete.each do |payment| - payment.void! + payment.void_transaction! payment.adjustment&.update_columns(eligible: false, state: "finalized") end flash[:notice] = I18n.t("checkout.payment_cancelled_due_to_stock") diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index e0e00a3ff7..10bc625675 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -126,7 +126,7 @@ describe CheckoutController, type: :controller do end it "cancels the payment and resets the order to cart" do - expect(payment).to receive(:void!).and_call_original + expect(payment).to receive(:void_transaction!).and_call_original spree_post :edit