#mike-mod_api
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. Thank you for your patience!
โฑ๏ธ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.
๐ 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/1214681478819217418
๐ Have more to share? You can add more detail below, including code, screenshots, videos, etc.
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.
- mike-mod_api, 1 hour ago, 22 messages
After trying to add coupons and trials to my subscription, I stopped receiving events on "customer.subscription.updated" (when a user completed a purchase through the checkout without coupons and trials, the event was triggered properly). I received feedback that actually opting for this event "customer.subscription.updated" might not always yield good results and that I should access the API to check the latest information about the objects. However, I need help to understand if I should wait for all events before accessing the API or not, and which event I should prioritize to listen to and access the API? ...
My goal is create a simple checkout to create a subscription accepting trial and coupons
I was having issues with the sequential indeterminism of events to receive feedback on accessing the API instead of considering the payload, which makes a lot of sense. However, I am unsure about when I should do this and which event exactly. My goal is to have an updated subscription with its status accordingly.
Hello ๐
Are you using Subscriptions API directly OR are you creating subscriptions using Checkout?
Im creating a checkout to the final user
You mean you're using Checkout Sessions API, yes?
I'm not sure about the labels of stripe products, but i think so... im creating this window
Yes, thats my code
Gotcha. Okay, yeah that's Stripe Checkout Session.
Have you had a chance to refer to this section in our docs? https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=stripe-hosted#provision-and-monitor
It outlines which events you should listen for and how you can provision access
This documentation is incorrect because it implies that the events are deterministic. It does not make a judgment to return to the API and fetch updated information, so it ends up not being very helpful in practice.
Fetch what sort of updated information exactly? An example would help
For example, when a user subscribes, within milliseconds, both the "user.subscription.created" and "user.subscription.updated" events are created. In my tests, the last one triggered was the one that updated my database last, but not necessarily with the correct information. However, I'll be honest, I didn't try using the "checkout.session.completed" event, so my concern is solely if I could trust the information contained in it.
The tutorial doesn't mention fetching updated information from the Stripe API. Wouldn't it be prudent to do so? In case some event could go unnoticed and bring something to the checkout session after "completed" while I believe it is "completed"?
I'll spare you the trouble and test the event suggested by the documentation myself, and I'll get back to you with any findings. Any other considerations for me?
For example, when a user subscribes, within milliseconds, both the "user.subscription.created" and "user.subscription.updated" events are created. In my tests, the last one triggered was the one that updated my database last, but not necessarily with the correct information.
We typically recommend listening to events that you need for your use-case.
When a new subscription is created, you should listen to customer.subscription.created and ignore customer.subscription.updated at creation time (so if you receive .updated event prior to .created event, it shouldn't really matter).
https://docs.stripe.com/billing/subscriptions/webhooks
The tutorial doesn't mention fetching updated information from the Stripe API. Wouldn't it be prudent to do so? In case some event could go unnoticed and bring something to the checkout session after "completed" while I believe it is "completed"?
There's won't be any changes in the checkout session after it has been completed
I tried listening to the "created" event, but often it came back outdated as if it were "unpaid". I'm certain that only listening to the "updated" event, it showed as paid, which was much more useful even though it was indeed created."
Can I fetch the subscription through the API using checkout.session.completed? Because your colleague suggested that I ignore the payload, I just need to know if I can find a bridge between checkout.session.completed or "invoice.paid" and the subscription.
Yeah each event is generated as the object moves through different statuses. That's why its important to not rely on the order of the events.
Can I fetch the subscription through the API using checkout.session.completed? Because your colleague suggested that I ignore the payload, I just need to know if I can find a bridge between checkout.session.completed or "invoice.paid" and the subscription.
You can, the checkout session object should reflect the subscription ID
https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-subscription