#mh_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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/1285220625354330183
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- mh_code, 1 hour ago, 53 messages
- mh_webhooks, 2 hours ago, 61 messages
hello , i would like to create and save the order in DB when 'payment_intent.succeeded':
can you help me?
currently iam doing this in checkout.session.completed.
Hi there ๐ can you elaborate a bit on what you're struggling with currently. I can help advise on the Stripe side of the flow, but I won't be familiar with your database or how to insert/update records in it.
this is the cose
and this is the modified code
is it correct? im recieving this error that sessionId is missing
and in events iam getting 500 error.
Session ID is missing from payment intent metadata
First, I would strongly advise adjusting a lot of the structure of that code. You're currently writing to your database synchronously using await before responding to us indicating whether you receievd the event successfully. There is a 20-second window for your to respond to the requests you send to us, and if you don't respond in time we assume you didn't receive the Event and queue it to be sent to your endpoint again.
https://docs.stripe.com/webhooks#acknowledge-events-immediately
https://docs.stripe.com/webhooks#handle-events-asynchronously
ok
Do you have an example Payment Intent that threw that error? That's your code checking for whether you added metadata to your intents, and then responding with an error if it doesn't find it.
should i modify anything is the create session part?
here it si
i tried to add the sessionId in the metaData, but it logged an error
Yup, that's putting your metadata on the Checkout Session, it isn't adding it in such a way that the metadata values are put on the associated Payment Intent. That's why when you look for the metadata later your code isn't finding it, and if you look at a specific Payment Intent object you won't see it there.
https://docs.stripe.com/metadata#set-indirectly
You'll want to look at using the payment_intent_data.metadata parameter when creaing the Checkout Session.
Sure?
what is the best thing to do whit checkout.session.completed? and is it best practice to create and save the order in the payment_intent.succeeded'?
That's up to decide based on how you built your integration. If you're only using Checkout Sessions to accept payments, then relying on checkout.session.X events makes sense. But if you accept payments other way for your account you may want to use an Event type that isn't exclusive to Checkout Sessions.
