#bruce-zhang_webhooks

1 messages ¡ Page 1 of 1 (latest)

simple furnaceBOT
#

👋 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/1217653968755232808

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

honest prairieBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

green sky
#

Yeah your scenario totally makes sense to me. Stripe have Live mode and Test mode, which you can use for Production and anything other including Staging respectively

void gulch
#

Do you mean that when I create an endpoint like this in test mode, then the webhook endpoint is for test mode? And if I turn test mode off and create an endpoint, then the endpoint is for real production environment

green sky
#

Yes correct

void gulch
green sky
#

No that's not correct because localhost is not public over the internet

#

You want to put to Stripe Dashboard public URL via some hosting provider

#

If you just want to test, you can use service like ngrok.io

void gulch
#

ok that make sense

#

thanks a lot

#

and another way is to use CLI to test manually?

green sky
#

Yes that's the purpose of the forward command

#

You can forward events to your localhost, the same machine that you runs CLI

void gulch
#

Thanks. Can i get the customer ID from the webhook?

green sky
#

depends on the event but generally yes

void gulch
#

I think I get get it from the first case. If I am using a webhook to listen to the checkout session, and the user subscribes to a plan, then both 'customer.created' and 'customer.subscription.created' event will happen. How can I make the webhook handle both cases?

green sky
#

It's totally up to you! You can decide to handle in one of these events

void gulch
#

I mean handle multiple events. Will the stripe webhook send two events to me at the same time?

green sky
#

Yes, it is the nature of webhook events. It's the Customer also created, and that Customer's Subscription also created at the same time

void gulch
#

In this switch case, it seems that only one type of event will be handled at one time. How do handle both customer and customer's subscription at one time?

green sky
#

No you can't. That's the nature of async event handling. You want to think of an async way of process both the event. ie. When you receive customer.created simply save to database, but when customer.subscription.created you can call an API to Retrieve the Customer (and make it retry with some ponential backoff strategy) until you get the customer