#ironbeard_events-v2-objects

1 messages ยท Page 1 of 1 (latest)

keen cipherBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1486818025381560543

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

safe drift
#

Hi there! Juggling a couple of threads, will be back to this one in a bit!

rich epoch
#

all good ๐Ÿ™‚

safe drift
#

I would say making API calls is the best way to avoid stale issues, although ideally it would only be necessary for some events where you think this would occur. My understanding is this is the thought process behind v2 thin events, which only provide IDs and require extra API calls for the full info

rich epoch
#

I was considering doing something by storing the last update time, but looking in the docs, I see that many objects don't have an updated timestamp, just a created one. Am I missing something?

#

When were v2 thin events created? Looks like I'm still rocking some quite old events, I'm on v1 with stripe.api_version = 2020-08-27.

Do I just need to follow this https://docs.stripe.com/upgrades to use v2?

Understand when and how to upgrade your Stripe API version and handle breaking changes in major releases.

safe drift
#

Thin events were created a while ago but don't have complete feature parity with v1 events, so I wouldn't necessarity recommend upgrading right away
https://docs.stripe.com/event-destinations

Private preview
Thin events for API v1 resources are available in private preview. You can use them to streamline integration upgrades without changing your webhook configuration. Previously, thin events only supported API v2 resources. Learn more and request access.

I was using it as an valid example of the model that you were describing, get events and make additional requests for the full info

Set up event destinations to receive events from Stripe that you can direct to a webhook endpoint or other listening service, such as Amazon EventBridge. You can also configure the type of event Stripe sends, such as thin events or snapshot events.

rich epoch
#

I see a fetchRelatedObject() method. Would I do something like this?

event = stripe.Webhook.construct_event(
  payload=request.body,
  sig_header=request.META['HTTP_STRIPE_SIGNATURE'],
  secret=settings.STRIPE_WEBHOOK_SECRET_KEY,
)
stripe_obj = event.fetchRelatedObject()

?

keen cipherBOT
timber oak
#

HI ๐Ÿ‘‹

I'm stepping in as my colleague has to go

rich epoch
#

all good ๐Ÿ™‚

timber oak
#

What is it you are attempting to achieve here?

rich epoch
#

I'm trying to set up my webhook endpoint to create local versions of some Stripe Objects (Subscriptions, Invoices, PaymentMethods)

#

particularly with invoices, I'm often getting the events out of order (fine), so I'm just trying to adapt to that. The .fetchRelatedObject() method looked interesting, but I can't find much documentation on it

timber oak
#

Unless you need to use V2 thin events for this, I would recommend sticking with V1 events for now.

rich epoch
#

Gotcha, thanks! So I guess the v1 event type doesn't have a mechanism for fetching the latest object, right? I should just use the stripe sdk to do this?

timber oak
#

Well they both basically just make GET requests to the retrieve the objects. The V2 fetchRelatedObject() just kind of obscures that logic so honestly I think it's better to handle that yourself.

rich epoch
#

gotcha, thanks ๐Ÿ™‚