#binaryfire

1 messages · Page 1 of 1 (latest)

heady gazelleBOT
hot minnow
#

hi! metadata can definitely work in this case yes!

You say it's Connect though, so aren't the payments already differentiated by which Stripe account they're happening on? In case you didn't see it, there is an account field on the Event itself in the webhook that is the Stripe account where the event was generated.

pallid sleet
#

@hot minnow Great thanks!

I'm still differentiating events by account. But currently every region needs to do a database query for every incoming event to check if the account exists (even if the account is from a different region). I'm trying to eliminate these unnecessary queries by only processing webhook events that are for accounts in that region. With a region_id I should be able to discard irrelevant events without ever hitting the db.

Are there any types of API requests where metadata can't be added, or any events where metadata isn't returned? Or will this approach work with pretty much everything?

hot minnow
#

well it highly depends what specific events you're listening to and how you integrate. For example, take a Subscription. You can set metadata on that. Every month, the subscription generates a new Invoice object and emits invoice.created. There's no metadata inherited on that Invoice directly; you'd have to look at the Invoice, then use the Retrieve Subscription API to check metadata on the sub, for example

pallid sleet
#

Ah right, ok. Currently I'm integrating checkout, subscriptions and portal but I plan to expand on that in the future. I'll be using a wide variety of events, so it'll start complicated if some events return metadata and others don't.

Is there another way I could achieve this?

hot minnow
#

not really, if you have multiple endpoints on one Stripe account listening to the same event types, that all receive the same, identical event; if you're a Connect platform your Connect endpoint receives all events from all connected accounts(with the account field mentioned earlier). So approaches like adding metadata to objects that you explicitly create can be useful but the implementation is definitely a fair amount of work. Only other solution really is refactoring the actual business/account set up so that multiple Stripe accounts are involved(like you have a US platform with all your US connected accounts and a https://us.example.com/connect_payments webhook), an EU platform with all your EU connected accounts and a https://eu.example.com/connect_payments webhook), etc)