mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Correctly void transactions when payments are cancelled due to stock issues
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user