#lec1892_api

1 messages ยท Page 1 of 1 (latest)

valid gyroBOT
#

๐Ÿ‘‹ 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/1229427736758587402

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

rich quailBOT
halcyon swift
#

Hi ๐Ÿ‘‹ no, that isn't possible, with a few exceptions metadata is not expected to be copied form the object it was placed on to other objects. Invoice's do have a special field that show's the related Subscription's metadata from the time the Invoice was created. Would that work for your needs? It's in subscription_details.metadata:
https://docs.stripe.com/api/invoices/object#invoice_object-subscription_details-metadata

rotund delta
#

this partially helps

#

anyway, thank you

halcyon swift
#

Any time! I can try to help more if I can understand what that still doesn't unblock for you?

In general with metadata, you either need to have logic to step from the object you're inspecting to the one where you provided the metadata, or build your own logic to automatically copy metadata from the object where you put it to related objects (where available to do so).

rotund delta
#

I'm trying to achieve the following:
in my project we have tests that simulate user usage and trigger stripe flows. My application knows when a test execution triggered the stripe. But when a stripe webhook is received my application doesn't know if the webhook event is related to a test execution or real user usage.

#

So my goal is to identify the webhooks that were generated because of tests and the ones generated because of real user usage.

halcyon swift
#

Ah, yeah, that's significantly harder to handle.

It shouldn't be mixed with real user usage though. That real usage should be going through livemode in your account, and your test usage should be going through testmode.

rotund delta
#

Yes, I thought about the live mode and test mode. But in my project, we use test mode for our staging environment, so the Q.A. engineers don't need to pay during usage.
Live mode is used only for production.

halcyon swift
#

The short answer is there is no easy way to do what you're describing. One option is to do your testing in an isolated Stripe account so that there isn't other traffic to interfere with it, but that has the overhead of making sure your account settings stay in alignment amongst your accounts. Otherwise you'll need to add logic to your event handling flows to tell them where they should look for the metadata that you provided to indicate the object was created by a test.

rotund delta
#

I just had an idea: using different webhook endpoints. If it is possible to enable and disable webhook endpoints using stripe api, then my tests can disable the webhook used by real user events, and enable the tests webhook. Then when the tests finish it can revert the webhook changes.

rich quailBOT
halcyon swift
#

That sounds like it'd have the risk of your downstream processing missing real user Events and not handling them, unless you aren't actually referring to real user events here.

rotund delta
#

by real users I mean human users, but they are not users from the production environment
if their events are not processed, this won't be a problem

halcyon swift
#

Ah gotcha, then yeah that could be an option

rotund delta
#

yes
thank you for your help
have a great week ahead!