#ronho
1 messages · Page 1 of 1 (latest)
use case: i have a dev env where i have multiple docker backends for different code branches, so i was hoping that i can route the webhook to a central host that can then redirect it to the correct backend
So you could add a new endpoint with custom params, e.g. one endpoint that's example.com?key=value1 and another that's example.com?key=value2, and set up handler logic on your end to route as appropriate
nothing code level i could inject without prior set up?
i could read the metadata from the payload but that would involve setting up a server to parse the metadata coming in
but was hoping to avoid that
haha
No, not possible.
Yes, using metadata then having the handler code on the server that receives the event inspect the event payload and route as needed
Keep in mind that any complex logic should happen after you've acknowledged receipt of the event/after sending Stripe a 2xx response
ok
thank you for the clarification!
one more question: since there could be multiple webhooks that come back on one action: eg invoice gets paid and subscription gets started, does the request metadata get carried across all the different webhook calls that result from the initial request?
Not exactly. Generally, metadata added to an object will remain on that object only so the metadata will only be included in event payloads for that object
There are some exceptions though, for example, when you confirm a PaymentIntent, we copy metadata from that PI object to the charge object that is created. This is a one-time copy so any future updates to the PI or Charge's metadata will remain on those objects only.
what about like, invoice paid, and subscription updated?
Metadata on an invoice's line items will always be retrieved from the current metadata of the invoice's subscription. Invoice objects created after June 29, 2023 have a property called subscription_details[metadata]; this is always a snapshot of the subscription metadata at the time that the invoice was finalized
Also, you can use Subscription Schedules to update metadata on the underlying subscription. You'd set metadata on the schedule phase; when the subscription transitions to that phase, the subscription's metadata is updated accordingly