#usamarashad_schedules
1 messages ยท Page 1 of 1 (latest)
๐ 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/1248663032561664131
๐ Have more to share? Add 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.
- usamarashad_sub-schedules, 2 days ago, 13 messages
- usamarashad_api, 3 days ago, 3 messages
Hi ๐ within our API, Subscriptions and Subscription Schedules are distinct types of objects.
Subscriptions are the objects that are used to model recurring payments:
https://docs.stripe.com/api/subscriptions
Subscription Schedules can be used to schedule future changes that you want to make to a Subscription:
https://docs.stripe.com/api/subscription_schedules
They cannot be used interchangeably, though they can be used together.
Common cases for when you would want to incorporate Subscription Schedules, such as scheduling Subscriptions to start in the future, are discussed here:
https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases
ok thanks. One remaining question. How can I get the list of "active" subscription schedules ?
there is no parameter in the subscription shcedule list function
which allows the fetching of only active subs
Yup, because Subscription Schedules don't have an "active" state, what are you referring to by an "active" Subscription Schedule?
i am referring to a schedule that has one of its phases active and charged
or in other words has not come to an end yet
๐ hopping in here since toby has to head out soon
Hey
Schedule phases don't really have the concept of being "active" - if you want to be sure that a schedule is tied to a subscription that has currently been paid for then it's better to just list all Subscriptions instead
Umm ok. So given that I have a customers Stripe ID only, I will first list the subscriptions he has and check which one is active like this :
let sub = await stripe.subscriptions.list({ customer: customerInfo.stripeID.toString(), status: "active" });
and I can avoid using the subscription schedules altogether, since a schedule would exist anyways if a subscription is running.
yup!
Hmmm. I get it now.
Thanks Karbi.
Should I ask a related question in this thread or start a new one ?
you can ask here ๐
You see this dial indicator showing the progress of a subscription? I want to show something similar on my dashboard. How is this being detetermined ?
Do you have a subscription ID and the specific dashboard page you're looking at that shows it? I'm not seeing it on my dashboard so an example would help a lot
Sure. Hold on...
sub_1PL4CxDVf1B7CjYuZqxVqXbu
Thats the ID
Once you open the customer's profile, it has the list of subscriptions under thier name
the status of active subs are shown as a dial.
Aha! There it is - give me a minute to see what I can figure out about how that works
Sure
Okay so it looks like what we're doing is calculating the percentage of the current period that's already been passed by doing (current time - current_period_start) / (current_period_end - current_period_start)
You should be able to get current_period_start and current_period_end from the Subscription
ok so if there are 4 phases to the subscription , i need to do this calculated for each of the phase periods and then sum those up ?
or is the period referring to the whole sub?
No, the phases have nothing to do with it - that progress indicator is just looking at the current period. Subscription schedule phases can be across multiple periods
If you wanted to show progress across the lifecycle of the schedule that would be something else (you'd have to calculate that yourself)
yeah if you want to do whole lifecycle of the schedule then I think you'd swap out current_period_start for the start_date of the first phase of the schedule and swap out current_period_end for the end_date of the last phase
Perfect Thanks