#mymodian_best-practices

1 messages ¡ Page 1 of 1 (latest)

hoary basaltBOT
arctic kestrelBOT
#

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.

hoary basaltBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1257892258251018301

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

unreal trellis
#

hello! The Subscription object itself doesn't have the Checkout Session id, why do you want to know which Checkout Session created the Subscription object? If you do want to know, when you receive the checkout.session.completed webhook event, you can find the subscription id in https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-subscription. You can make a subsequent request to set the Checkout Session id as metadata on the Subscription object.

maiden cedar
#

because i use Checkout Session to create a subscription for the customer, so when i recieve a customer.subscription.created event, i need to know which request generate the subscription.

unreal trellis
#

like what i mentioned before, when you receive the checkout.session.completed webhook event, you can find the subscription id in https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-subscription. So you can save the Checkout Session id and Subscription id from the checkout.session.completed into your DB

maiden cedar
#

the event sequence is random, it's so difficult to process all these correctly

#

if the invoice.paid event comes first, then i don't know who created it, i can't process it.

unreal trellis
#

what do you mean by if you don't know who created it, you can't process it? can you elaborate more?

maiden cedar
#

we need to process invoice.paid event to grant features to our user, after create a subscription checkout session, if the first incoming event is invoice.paid, i can't process it, because on my side the user has no subscription yet, and i can't know if it's generated by the pending subscription session.

#

just an invoice paid and no other information

unreal trellis
#

Like what our docs mention in https://docs.stripe.com/webhooks#event-ordering, you'll want to retrieve any missing object if you receive a particular object first. If you receive the invoice.paid event first, you can check if your DB already has that subscription id. If it doesn't, make a request to retrieve the corresponding Subscription object and then create it in your DB first.

Listen to events in your Stripe account on your webhook endpoint so your integration can automatically trigger reactions.

maiden cedar
#

if we response 5xx code to the webhook call, will stripe still retry to delivery it?

unreal trellis
#

yes, Stripe will attempt to redeliver as log as you don't send 2XX response

maiden cedar
#

ok. thanks for your help, i have no questions now.