#jasonadams1326_best-practices

1 messages ¡ Page 1 of 1 (latest)

dusky tendonBOT
#

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

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

crimson fractal
#

Hi there

viscid laurel
#

Hi!

crimson fractal
#

Do you happen to have a webhook endpoint that listens for checkout.session.completed events by any chance?

viscid laurel
#

Yes I do

crimson fractal
#

If one or more endpoints that's listening for checkout.session.completed events does not acknowledege the event in a timely manner, we wait up to 10 seconds for a response before timing out and redirecting the customer to the success_url

viscid laurel
#

hmm, i wonder if theres anything in my checkout.sessions.create call and/or my checkout.session.completedhandling in my Stripe webhook. Would it be helpful to share small code snippet? Its javascript

crimson fractal
#

Our general recommendation is to reply to the event delivery with a 200/ack as soon as possible and complete any handler logic after the fact

viscid laurel
#

I do have a webhook endpoint set up to listen for checkout.session.completed events and I do set a success_url, but as far as I can tell, I'm not doing anything that would cause my server to respond slowly to the checkout.session.completed event

crimson fractal
#

The Checkout Session won't be completed instantly after clicking Pay since a few things need to happen on the backend: creation of a Customer (unless you passed a Customer ID when creating the Session), creation of the Subscription, creation of the Invoice, creation of the child PaymentIntent

viscid laurel
#

Gotcha. The only thing I'm doing before returning 200/ack is patching user in db (updating stripe customer id and subscriptionid in my db). Shouldn't take more than a few ms

viscid laurel
crimson fractal
#

Right, probably not. You could test whether updating your database after the 200/ack makes a significant difference

viscid laurel
#

Ok thank you. I will look into that.

viscid laurel
#

added timer logs and tested in my production environment (3 times). My database update on slowest attempt took 11.424ms, the time for the entire webhook to respond to Stripe with 200/ack was 12.326ms (other two tests were faster at around 6ms/7ms).

#

As a new Stripe customer, I understand I don't get charged for transaction fees for the first year (which is ofc awesome)...but does that put me on some sort of slower tier for checkouts?