#whimsy_subscription-event
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/1304208301419921438
๐ 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.
- whimsy_api, 8 hours ago, 18 messages
Hello! What specific data do you want?
hm i'd mostly be interested in like if downgrade or upgrade happened
You likely want to listen for customer.subscription.updated instead, then look at the previous_attributes property of that Event to see what changed: https://docs.stripe.com/api/events/object#event_object-data-previous_attributes
ah yeah maybe, what would be best way to check when subscription was canceled by a user and when it is actually stopped (when what they paid for is over)
how i did it before is i'd check if cancel_at_period_end was set in customer.subscription.updated and wasnt in previous_attributes
It would depend on how your integration works. It sounds like that might be appropriate, but you said you did that before? Before what? Does it not work anymore? If so, why not? What changed?
no i mean it does, but im basically abstracting my system into mini package for my own use, im wondering if that's actually the right way to check when normal subscription ends and when its canceled or is that just luck that i found that way which might possibly break
If that works for your integration and the way you're using Subcriptions then yes, that's fine.
hm
There are many different ways to handle/implement Subscription cancelations, so your solution might work well for your integration but might not work well for a different integration. There's no single universal way to do what you're talking about because Stripe Subscriptions are complex and can be used in many different ways.
i mean yeah, the way i do it is what i just read in the docs, i create checkout session with subscription data and then if user wants to cancel it, i send them to customer portal
Right, that's just one way to do this though. Some people don't use the Customer Portal at all. Some people don't use cancel_at_period_end at all.
That's why this might work well for your specific integration, or it might not. It depends on how your integration works and what you've built.
You know more about your integration than I do, so you're better positioned to determine if this is the correct approach or not.
what are other ways to do that, you could fetch their subscriptions and then show them in their own ui and use cancel via api? but wouldnt that also change cancel_at_period_end
i mean yeah, some dont use webhooks at all, but just do it directly if they cancel it via api
Some people use Subscription Schedules to cancel an upcoming cancelation. Others schedule a job on their end to call the cancel API at the appropriate time, in which case nothing on Stripe's end would be aware of the upcoming cancelation. There are a myriad of other ways to do this as well.
ah yeah that sounds already complex
Neither of those examples would touch cancel_at_period_end, which is why I chose them.
That's my point: Subscriptions are very powerful because they have a lot of functionality and different ways to do things. This allows them to accommodate many different use cases, but it also make it impossible for there to be a single correct way to do certain things.
true, thanks ill test out
Happy to help!
i kinda also just realized that instead of using cancel_at_period_end i could've checked if subscription.data.status is canceled and event.data.previous_attributes.status isnt
Yep, that's useful to see when a Subscription actually transitions to canceled.
i found broken link in nodejs client
Where?
Wait, where are those links? What's shown on your video?
You can fix those by adding docs. in front of stripe.com in those URLs, but I want to find and fix those on our end.
Oh, it's in the Node SDK comments, I see. Thanks!
yeah
small last question do you by chance know any scenario when subscription could go from canceled to active status, and how
its not .crop but yes
Oh, my bad, sorry!
Fixed.
Side effect of me reporting that issue with the links in the Node SDK. ๐
ah haha, is there a way to add/modify items/products to existing subscriptions? if so, how would user be notified about that? like if i they buy some subscription and they want to purchase "an addon" which is basically just a product on stripe's end, how'd i append that product to existing subscription
We have a lot of documentation here about changing existing Subscriptions: https://docs.stripe.com/billing/subscriptions/change
You can update an existing Subscription and add a new line item, for example.
Or adjust the quanity of an existing item.
figued that, but how does user get notified of that, like that they'd need to pay
or how do i notify them
Typically the change would result in an off-session payment attempt against their saved payment details for the Subscription. If that doesn't succeed it's up to you how you want to contact them. You can enable failed payment emails in the Dashboard, for example, or you can send your own emails, or contact them in another way.
do after i update subscription with new items, it directly charges the user? i got told before this so im just checking #1290662876809527378 message
It depends on what's being changed: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade#immediate-payment
ah so i would need to have proration_behavior to always_invoice before i try updating items
proration_behavior isn't a persistent setting on a Subscription, it only applies to the request where you set it.
so while updating items
Yes.
would there be a reliable way to directly fetch that invoice and serve a user with url to it so they can pay
Yes, have a look at the latest_invoice property on the Subscription to access the Invoice. You can then verify it's ready to be paid (or update it so it is) then send the customer to its hosted payment page.
yup, what webhook even would that be? also update and check for previous or
This would be you fetching the data from the API. Not sure what you mean about a webhook in this scenario?
uh, my potential confusion is that if i for example downgrade a user, aka modify their items to remove one product they had and add another, that wont create invoice, so basically not on every update will invoice be created and i'd like some way to check when it has been created, i assume i can't directly fetch subscription after i updated it and expect there to be invoice already that fast or?
You can.
As long as you wait for a response back from the update request the Subscription will then be in the new state. In fact, the response to the update request itself likely has the information you want.
Give it a try in test mode and you'll see how it works.
will do