From ef6b7217d96bfd49568b5f32c4d2b8fc4e6acc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 17 Feb 2023 23:57:45 +0100 Subject: [PATCH] Fetch new Stripe events until being exhausted #12100 (grafted from dff6f5203cf2f5a610111bf2c478a5cfdb52a257) --HG-- branch : 6.0 --- modules/account_payment_stripe/payment.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/account_payment_stripe/payment.py b/modules/account_payment_stripe/payment.py index 2aedda538f..20723c1415 100644 --- a/modules/account_payment_stripe/payment.py +++ b/modules/account_payment_stripe/payment.py @@ -1012,15 +1012,18 @@ class Account(ModelSQL, ModelView): ('webhook_identifier', '=', None), ]) for account in accounts: - events = stripe.Event.list( - api_key=account.secret_key, - ending_before=account.last_event, - limit=100) - for event in reversed(list(events)): - account.webhook(event) - account.last_event = event.id - account.save() - Transaction().commit() + while True: + events = stripe.Event.list( + api_key=account.secret_key, + ending_before=account.last_event, + limit=100) + if not events: + break + for event in reversed(list(events)): + account.webhook(event) + account.last_event = event.id + account.save() + Transaction().commit() def webhook(self, payload): """This method handles stripe webhook callbacks