anyone have experience w/ a multi-dev/multi-env se...
# general
s
anyone have experience w/ a multi-dev/multi-env setup that uses Stripe or Chargebee? I’m wondering how that would work as far as the billing platform having just a single sandbox that sends out webhooks to multiple dev accounts w/ their own databases 🤔
t
Could deploy a billing service that's a shared resource which publishes to a shared eventbus
you can subscribe to event bus events from across accounts
s
hmm.. so Chargebee single webhook -> webhook handler Lambda that exists in primary account only -> publishes to EventBridge ?
that’s still every dev account getting events generated by other devs though. maybe I’m misunderstanding
but maybe it doesn’t matter. if Dev A modifies their user a123, and Dev B gets a webhook event and user123 doesn’t exist in their DB, it’ll just disregard the event
t
Yeah. Only other option I can think of is to mock the service
s
also when devs kill their
sst start
processes, their webhooks are gonna stack up a bunch of dead events that keep retrying until they’re back online. tricky
t
I don't think they'll retry. Eventbridge does an async invoke on the lambda, it doesn't pay attention to whether the lambda fails or not
But it is more invocations that are uselessly running
s
Chargebee will retry, depending on the HTTP status code returned. not sure what would be returned if the API Gateway Lambda is unreachable
oh yeah, in your case with EventBridge, that would be different. but with regular HTTP API -> Lambda, it would keep retrying
b
at our org, we’re moving to handle retry / deadletter ourselves - so we can ensure that 100% of webhooks are captured, and services can be hydrated/caught-up when they come back online.
not really addressing multi-dev/env, 2 cents
s
unfortunately I don’t have enough time/resources for something like that. but I think I can just have the webhook handler do a lookup for the updated customer/subscription, and if it can’t be found in the DB table, it’ll ignore the event
b
sure
s
hopefully later when I have more help, we can build something more sophisticated
b
I know our team uses filters for our events, so we’re not spamming invokes that do nothing. We do it based on eventType, but you should be able to link it up to your environment? Then you get that 1 eventbridge but only subscribe to events each dev/env cares about
s
hmm. I’m not sure..? let’s say a customer cancels their account. Chargebee will send that event out to all developers’ webhooks. there’s no way to filter that intelligently
all dev instances would have to check their DB to see if the user exists or not
b
I was thinking setting up patterns to map those events to specific subscribers
I probably am missing something ’bout the use-case
we’ve just used rules to centralize our events but allow us to target specific types of messages to lambdas
🤷
s
is this a subscription platform you’re talking about? Stripe/Chargebee/Recurly?
b
we have a bunch of partners producing events, critical operational events, so we have them go into an eventbridge, most of the events get routed as is, but partner events do have an anti-corruption layer that processes them a bit. we can handle routing there, basically assigning to the correct domain’s event store, re-structuring or mapping etc.
we actually have a mapping index (dynamodb) which maps partner IDs to our internals, which makes it a lot easier to deal with - it’s working ok for us so far.
s
yeah.. I think this is a specific use case for subscription platforms. the event coming from Stripe/Chargebee doesn’t have enough detail in it to filter & map it properly. e.g.:
Copy code
{
  "event_type": "subscription_changed",
  "customer_id": "Abc123",
  "subscription_id": "Abc123",
  ...details...
}
so that gets fired off to 8 developers’ webhooks.. and Dev #6 is the person who is customer Abc123, so they care about the event. the other 7 developers don’t. in other words, there’s no origin to tell who initiated the event.. it just happens and gets shouted at all webhook URLs 😄
t
Can each developer register their own webhook?
s
no 😕 the Chargebee sandbox mode just has webhooks you can add and provide a URL. it broadcasts to all of them
it’s cool, I have a solution that I think will work
a
We have a little lambda + firebase store which bounces webhooks back out to registered localtunnel domains. I'll see if we can open source it?
s
@Alex Price no need, but thanks! I’ve moved past it.. gotta keep on trucking forward 🙂
a
Yeah cool. We're going to release it as a little free tool so it would be ace if you could try it out when we launch 👍
j
@Sam Hulick How did you handle the stripe setup with multi dev/sandbox’s? did you create a new stripe webhook for each one or did you have a gateway? Any pointers welcome as we are needing to solve the same issue as you.
s
@Jack Fraser we use Chargebee. but, kinda similar set up with prod & a test mode. each dev gets their own webhook, and our code will disregard events that apply to nonexistent user IDs. so if I have a user ID abc123 and my dev has a user ID def456, webhooks for def456 are discarded on my setup