#HKrievs-events
1 messages · Page 1 of 1 (latest)
@shell oracle well, two things:
-
when sending events to your webhook endpoint, that order is not guranteed, yes (https://stripe.com/docs/webhooks/best-practices#event-ordering)
-
but for listing using /v1/events, they should be in order — they're returned in reverse-chronological (most recent first) order by the
createddate of the Event object, it's not random. Maybe that's what you mean by seeing the paid event before the created event?
okay. Thats a bit tricky.
Now I have to compare each event by time - if I receive a invoice.paid and Invoice.cancel - I have find which is the later....
if we're talking about webhooks now, I usually suggest just ignoring the payload of the event and instead taking the ID of the object it references(like the in_xxx Invoice ID) and then retrieve that from the API. That gives you the latest state of the object and you can sync against that(if you get at invoice.paid, if you don't already have a record of it in your database, create it at that point for example)
if it's retrieving stuff from /v1/events, maybe it's easier to push the retrieved objects into a queue/list as you make the GET API calls, and then iterate through it one-by-one starting at the end of the list
Good point. Thanks.
I have an addiitonal, but related question: The documentaion says "A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10" Does this mean that If I have a batch jow, running once each night - I need to make sevaral calls in order to pick up all events?
Im using the created.gt parameter.
So waht I basically wants is to say " hey give me alle events from 2:00 AM until now..."
technically you have to make multiple calls but you should use the auto-pagination in our libraries as it handles it for you https://stripe.com/docs/api/pagination/auto
hey give me alle events from 2:00 AM until now..."
yep you can do that. If there are more than 100 events that match that criteria, then you'd need to fetch multiple pages
but the library does that for you really
Thanks, I will investigate....
Will .autoPagingIterable() work with EventCollection events = Event.list(params); ?
I have noticed this one, but can quite figure out to make it work
yes, it works with all list endpoints