Ensure order is cleanly reset to cart state when redirecting to cart

This commit is contained in:
Matt-Yorkley
2020-11-27 11:42:46 +00:00
parent c4cfc1dc05
commit 0ba670b180

View File

@@ -61,7 +61,7 @@ Spree::PaypalController.class_eval do
# At this point the user has come back from the Paypal form, and we get one
# last chance to interact with the payment process before the money moves...
return handle_insufficient_stock unless sufficient_stock?
return reset_to_cart unless sufficient_stock?
@order.payments.create!({
source: Spree::PaypalExpressCheckout.create({
@@ -114,6 +114,11 @@ Spree::PaypalController.class_eval do
end
end
def reset_to_cart
OrderCheckoutRestart.new(@order).call
handle_insufficient_stock
end
# See #1074 and #1837 for more detail on why we need this
# An 'orphaned' Spree::Payment is created for every call to CheckoutController#update
# for orders that are processed using a Spree::Gateway::PayPalExpress payment method