#Bo0013246

1 messages · Page 1 of 1 (latest)

vapid flickerBOT
hallow wind
#

Hello! The answer to this depends on your needs. One common approach is that regardless of what Event you get you ignore the payload and fetch the current version of the object from the API.

#

Another approach is to create a delayed queue system that throws received Events into a queue, then there's a small delay before that queue gets processed, and when processing the queue you go through created Events first, then the others, that kind of thing.

umbral star
#

Trying to understand this better, are you saying to use queue to order the events based on created field?

hallow wind
#

No, Events land in the queue without being processed. Then there's a delay. Then when you go to process the queue you process all the *.created Events first, then the other types.

umbral star
#

ohh interesting!

#

that is a good way to do it

#

another question

Event you get you ignore the payload and fetch the current version of the object from the API.

So if I were to do that, do I need to do to look up the current version of the object, or what do i use from event to know the object?

vapid flickerBOT
hallow wind
#

It depends on your use case and specific needs. For example, if you get a payment_intent.created Event the existence of the Event itself tells you there's a new Payment Intent, but the payload might contain an out-of-date snapshot of the Payment Intent. If you retrieve the Payment Intent from the API after receiving the Event you get the current state, and can then make decisions based on that.

umbral star
#

I see

#

so for example

#

{
"id": "evt_1NC8vh2eZvKYlo2CTLeJerI3",
"object": "event",
"api_version": "2019-02-19",
"created": 1685139373,
"data": {
"object": {
"id": "seti_1NC8vh2eZvKYlo2CXaaP6qtb",
"object": "setup_intent",
"application": null,
"automatic_payment_methods": null,
"cancellation_reason": null,
"client_secret": "seti_1NC8vh2eZvKYlo2CXaaP6qtb_secret_Ny55qYKzZoYTmYhuumZXi2NAIYp89YR",
"created": 1685139373,
"customer": null,
"description": null,
"flow_directions": null,
"last_setup_error": null,
"latest_attempt": null,
"livemode": false,
"mandate": null,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": "pm_1NC8vh2eZvKYlo2CTMbdmQlM",
"payment_method_options": {
"acss_debit": {
"currency": "cad",
"mandate_options": {
"interval_description": "First day of every month",
"payment_schedule": "interval",
"transaction_type": "personal"
},
"verification_method": "automatic"
}
},
"payment_method_types": [
"acss_debit"
],
"single_use_mandate": null,
"status": "requires_confirmation",
"usage": "off_session"
}
},
"livemode": false,
"pending_webhooks": 0,
"request": {
"id": null,
"idempotency_key": null
},
"type": "setup_intent.created"
}

#

I would query seti_1NC8vh2eZvKYlo2CXaaP6qtb for its latest status?

dense epoch
#

Hi, stepping in and catching up here

umbral star
#

ty

#

another question, if I have receive an object like above with type charge.succeeded but I have not received charge.created which field would I use to query Stripe to know all the events related to this payment?

dense epoch
umbral star
#

sorry that is not what I am asking

#

I want to be able to retrieve all events related to a payment

dense epoch
#

That was an answer to your previous question of I would query seti_1NC8vh2eZvKYlo2CXaaP6qtb for its latest status?

On your second question, you can list all of the events via the API, https://stripe.com/docs/api/events/list and filter it by type and date: https://stripe.com/docs/api/events/list#list_events-type for instance. However, there is not a way to pass an object id and list all event related to that object. In this case, you'd retrieve the charge via the API: https://stripe.com/docs/api/charges/retrieve and look at "status".

umbral star
#

I see

#

but lets say if I have charge.succeed as well as setup_intent.created and charge.created

But my webhook only received charge.succeed , so how would I know there is this setup_intent.created or charge.created

How would I query Stripe?

dense epoch
#

This data is surfaced on the Dashboard, it shows all relevant events. Via the API, you'd need to filter it and look at the response and filter through the object.

umbral star
#

oh wow

#

I see

#

if I have a billion event in a day, then i have to filter them all?

dense epoch
#

You'd get the created date from the charge retrieve call, and the filter your list event call to that timeline.

umbral star
#

I see

dense epoch
#

That would narrow down the events you get, and if these are one offs, you could also leverage the Dashboard to see all of events on that object.

umbral star
#

so, for Charge, I query charge retrieve
paymentintent, I query payment intent
setupintennt, I query setupintent
customer, I query customer

dense epoch
#

Yeap, depending on what you're looking for, you can also use the Expand functionality: https://stripe.com/docs/expand that let's you expand some nested objects to see additional data on them.

umbral star
#

So I cannot get an activity level view in API like I do on the dashboard, right?

dense epoch
#

That is correct. I'll share your feedback to show events related to a specific object to the team for future product reiterations. Thank you.

umbral star
#

I see, thank you