Correctly void transactions when payments are cancelled due to stock issues

This commit is contained in:
Matt-Yorkley
2021-07-27 23:24:00 +01:00
parent 440eb2a996
commit e1393c96ca
2 changed files with 2 additions and 2 deletions

View File

@@ -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")

View File

@@ -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