Fetch new Stripe events until being exhausted
#12100 (grafted from dff6f5203cf2f5a610111bf2c478a5cfdb52a257) --HG-- branch : 6.0
This commit is contained in:
1 parent
c2609342f3
commit
ef6b7217d9
1 file changed
+12
-9
@@ -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
|
||||
|
||||
Reference in new issue
Block a user