#alpha-tings_docs

1 messages ¡ Page 1 of 1 (latest)

white nimbusBOT
#

👋 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/1250179261701161042

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

noble mural
#
                        const schedule = await stripe.subscriptionSchedules.create({
                            from_subscription: stripeSubscriptionId,
                        });
                        scheduleToUse = schedule;
                    }

                    const subscriptionSchedule = await stripe.subscriptionSchedules.update(
                        scheduleToUse.id,
                        {
                            phases: [
                                {
                                    items: [
                                        {
                                            price: currentSubscriptionPriceId,
                                            quantity: newSeatQuantity,
                                        },
                                    ],
                                    start_date: scheduleToUse.phases[0].start_date,
                                    end_date: scheduleToUse.phases[0].end_date,
                                },
                                {
                                    items: [
                                        {
                                            price: foundProductDefaultPriceId,
                                            quantity: newSeatQuantity,
                                        },
                                    ],
                                    iterations: 1,
                                },
                            ],
                        },
                    );
minor quest
#

Do intervals account for middle of the month or are they set to exactly one month from the time of the schedules have started?
The interval is calculated from the phase start date

IE: A user wants to downgrade their plan in the middle of the month. I want downgrades to happen at the start of the new billing cycle and upgrades to happen instantly with proration.

For downgrades I create the subscription schedule, If their billing anchor is on June 1 2024, and they decide to cancel June 15 2024, if I put the interval to 1 will the next phase take effect one July 1 or July 15? Or should I use the start_date and end_date functionality?
I'm a bit confused about this. Are you asking if the customer has a downgrade scheduled and then tries to cancel the subscription instead then what would happen?

noble mural
#

Would I have to specify the start date explicitly using intervals?
Not quite, the custom functionality I am trying to achieve is:
-Upgrades === prorate immediately.
-Downgrades === take effect beginning of the next billing cycle.
so the main question was if I had to explicitly say the start_date and end_date on the first phase to achieve that functionality or if I could just use intervals. Moreso if intervals went off of the anchor date or the start_date specifically

#

in my code above i'm trying to achieve is 1st phase is their current plan and quantity, second phase is the downgraded plan and quantity

#

if that makes sense lol

#

but for the first phase do I need
{ items: [ { price: currentSubscriptionPriceId, quantity: newSeatQuantity, }, ], start_date: scheduleToUse.phases[0].start_date, end_date: scheduleToUse.phases[0].end_date, },
or can I do this
{ items: [ { price: currentSubscriptionPriceId, quantity: newSeatQuantity, }, ], interval:1 },

minor quest
#

In the docs, we recommend using start_date and end_date

noble mural
#

Sweet, one more quick question when a schedule is released or canceled does the field "schedule" get removed on the subscription object or does just the schedule get updated with the completion date?

#

I'm assuming it's the latter?

minor quest
#

I'm not sure to be honest. You can try it out with test clocks to be 100% certain.

noble mural
#

Sounds good, one last question for ya, to get the functionality of downgrades happen at the next billing cycle and upgrades happen immediately

#

The fringe case of a user downgrades their plan but upgrades their seats

#

I currently have it calling the subscription.update to charge for the increase seats based on their current (better) plan, and then use a schedule for the downgrade. Is there a better way to do it or am I gtg?

minor quest
#

If the updates are immediate then yeah, updating the subscription directly is the way to go

noble mural
#

Sweet, that's all I got, much appreciated!