#mike-mod_api

1 messages ยท Page 1 of 1 (latest)

glad plankBOT
#

๐Ÿ‘‹ 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.

rare fractalBOT
#

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.

calm relic
#

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.

fresh notch
#

Hello ๐Ÿ‘‹
Are you using Subscriptions API directly OR are you creating subscriptions using Checkout?

calm relic
#

Im creating a checkout to the final user

fresh notch
#

You mean you're using Checkout Sessions API, yes?

calm relic
#

I'm not sure about the labels of stripe products, but i think so... im creating this window

#

Yes, thats my code

fresh notch
calm relic
#

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.

fresh notch
#

Fetch what sort of updated information exactly? An example would help

calm relic
#

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?

fresh notch
#

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

calm relic
#

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.

fresh notch
#

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

calm relic
#

Cool, so i will try that

#

Thanks a lot hanzo