From 2136eecd0968476878f1ab797beb809a14b9cafe Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Wed, 29 Jul 2020 22:34:45 +0100 Subject: [PATCH] Avoid reloading the payment every time, so that in-memory data is not wiped out When checkout fails and the payment states dont match (inside the if), in-memory data of the failed payment can be lost but updating the payment state is the fundamental part here so that further checkout attempts work. We may improve this update statement so that all the data of the failed payment is persisted --- app/services/order_workflow.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/order_workflow.rb b/app/services/order_workflow.rb index b7db840ef8..c2a7e9dc95 100644 --- a/app/services/order_workflow.rb +++ b/app/services/order_workflow.rb @@ -64,8 +64,8 @@ class OrderWorkflow def persist_all_payments order.payments.each do |payment| original_payment_state = payment.state - if original_payment_state != payment.reload.state - payment.update(state: original_payment_state) + if original_payment_state != Spree::Payment.find(payment.id).state + payment.reload.update(state: original_payment_state) end end end