From 16accfca44465cf6baf9861c97957545f2a833af Mon Sep 17 00:00:00 2001 From: Nicolas Florentin Date: Wed, 6 Apr 2022 16:44:31 +0200 Subject: [PATCH] [bugfix] race condition on invoice after payment (concerning payment schedules) https://app.clickup.com/t/25zpmn1 --- CHANGELOG.md | 1 + lib/stripe/service.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e078601be..1c7c21b92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Fix a bug: unable to show machine availability slot for admin - Fix a bug: unable to confirm modification of reservation for client - Fix a bug: unable to show deleted user in reservation slot +- Fix a bug: race condition on invoice after payment (concerning payment schedules) https://app.clickup.com/t/25zpmn1 ## v5.3.9 2022 April 01 diff --git a/lib/stripe/service.rb b/lib/stripe/service.rb index 3da2035be..d3536f646 100644 --- a/lib/stripe/service.rb +++ b/lib/stripe/service.rb @@ -120,6 +120,8 @@ class Stripe::Service < Payment::Service pgo = PaymentGatewayObject.find_or_initialize_by(item: payment_schedule_item) pgo.gateway_object = stp_invoice pgo.save! + elsif stp_invoice.status == 'draft' + return # Could be that the stripe invoice does not yet reflect the payment made by the member, because we called that service just after payment is made. We call return here and PaymentScheduleItemWorker will anyway call that method every hour else notify_payment_schedule_item_error(payment_schedule_item) payment_schedule_item.update_attributes(state: 'error')