#ajivrajani_code
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/1265746433752170526
๐ 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.
- ajivrajani_code, 19 hours ago, 43 messages
Absolutely
sub_1PgAItIp6MB4p4mqF6BCOwRb
Here's what I want to do:
Jan 2, 2024: Start subscription with priceID p1
Schedule updating the priceID to p2 when the subscription renews on Jan 2, 2025
Looks like you didn't correctly update the Subscription schedule as the update request failed: https://dashboard.stripe.com/test/logs/req_hbdzmm1G2t5J3b
When you update a Subscription schedule you need to pass in the current phase as phase 0
Ah no, apologies. This is the new subscription I was testing with.
Here's how I am creating a schedule:
schedule, err := sc.sClient.SubscriptionSchedules.New(&stripe.SubscriptionScheduleParams{
FromSubscription: stripe.String(req.SubscriptionID),
})
if err != nil {
return nil, errors.Wrapf(err, "creating new subscription schedule for subscriptionID: %s", req.SubscriptionID)
}
// Update the schedule with new phase
params := &stripe.SubscriptionScheduleParams{
Phases: []*stripe.SubscriptionSchedulePhaseParams{
// Phase 0: this is the existing subscription phase
{
Items: []*stripe.SubscriptionSchedulePhaseItemParams{
{
Price: stripe.String(schedule.Phases[0].Items[0].Price.ID),
Quantity: stripe.Int64(schedule.Phases[0].Items[0].Quantity),
},
},
StartDate: stripe.Int64(schedule.Phases[0].StartDate),
EndDate: stripe.Int64(schedule.Phases[0].EndDate),
},
// Phase 1: this is the new schedule phase
{
Items: []*stripe.SubscriptionSchedulePhaseItemParams{
{
Price: stripe.String(req.PriceID),
// the quantity of the new phase remains the same as the ongoing subscription
Quantity: stripe.Int64(schedule.Phases[0].Items[0].Quantity),
},
},
},
},
}
Note that I am creating phase 0 with ongoing subscription parameters (price and quantity)
Okay well can you provide me the Subscription ID where you correctly set the Subscription Schedule and you didn't see it release after it completed all of its phases?
Sure! Give me ~3 minutes to set it up.
Alright here's the subscription with the attached schedule: sub_1PgAItIp6MB4p4mqF6BCOwRb
Do you want me to advnace the clock on this before you check things on your end?
Yep
On it ๐ซก
I advanced the clock by a year to July 25, 2025 | 12:14 PM PDT (a year from now)
Ah the Schedule is still active until all of its phases complete. Your phase 1 has iterations: 1 meaning it will last a year as well.
Maybe that is the confusion
If you advance another year then you should see the schedule release
I see I see. Is there something I can do make the phase 1 essentially last for an instant long enough to switch the priceID to p2?
Effectively I want to change the priceID at the time of renewal. Having a phase attached even after a renewal makes it difficult to "update" subscriptions. Updates like quantity changes....
Right! So I can just put end_date as Jan 2, 2025 + 1 minute?
Yep that should work
Interesting. Thank you!
Would you say this is an idiomatic approach of achieving what I described?
Yeah it's a fine way to go.
Gotcha, thank you so much. I appreciate your help! ๐ Have a wonderful day!