#HKrievs-events

1 messages · Page 1 of 1 (latest)

tribal violet
#

@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 created date of the Event object, it's not random. Maybe that's what you mean by seeing the paid event before the created event?

shell oracle
#

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

tribal violet
#

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

shell oracle
#

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?

#

So waht I basically wants is to say " hey give me alle events from 2:00 AM until now..."

tribal violet
#

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

shell oracle
#

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

tribal violet