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
This commit is contained in:
Luis Ramos
2020-07-29 22:34:45 +01:00
parent 9e9e0d0bd8
commit 2136eecd09

View File

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