#usamarashad_schedules

1 messages ยท Page 1 of 1 (latest)

delicate ermineBOT
#

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

gritty fieldBOT
#

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.

fervent frost
delicate ermineBOT
waxen pike
#

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

fervent frost
#

Yup, because Subscription Schedules don't have an "active" state, what are you referring to by an "active" Subscription Schedule?

waxen pike
#

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

minor mural
#

๐Ÿ‘‹ hopping in here since toby has to head out soon

waxen pike
#

Hey

minor mural
#

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

waxen pike
#

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.

minor mural
#

yup!

waxen pike
#

Hmmm. I get it now.

#

Thanks Karbi.

#

Should I ask a related question in this thread or start a new one ?

minor mural
#

you can ask here ๐Ÿ‘

waxen pike
#

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 ?

minor mural
#

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

waxen pike
#

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.

minor mural
#

Aha! There it is - give me a minute to see what I can figure out about how that works

waxen pike
#

Sure

minor mural
#

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

waxen pike
#

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?

minor mural
#

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)

waxen pike
#

ok in the later case my approach is sound ?

#

ok I get it

minor mural
#

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

waxen pike
#

Perfect Thanks