#brayden_schedule-phase
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/1261084101293637672
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hahaha yesss koopajah is who I was hoping to see here
brayden_schedule-phase
Hello, happy to try and help. Can you provide an exact example with all the details please? Try to summarize it all in one clear paragraph, exact object ids, exact code, current phases, what you want them to be instead, etc.
Yeah, so current schedule has a phase starting on Nov. 13th, 2023 and ending on Nov. 13th, 2024. I need to update the current phase so that the subscription is set to start on April 15th, 2024 and end on April 15th, 2025. I don't want to charge the customer or affect the subscription financially in any way, just to update the dates so that if there is an update to the subscription in the future, the proration calculates off of the correct schedule. What I've done is this:
subscription = policy.stripe_subscription #Ruby SDK object Stripe::Subscription
Stripe::SubscriptionSchedule.release(subscription.schedule)
#Creating a fresh schedule from the subscription itself
schedule = Stripe::SubscriptionSchedule.create(from_subscription: subscription.id)
new_start_date = 1713182077
new_end_date = 1744718077
new_phases = schedule.phases
new_phases.first["start_date"] = new_start_date
new_phases.first["end_date"] = new_end_date
schedule["phases"] = new_phases
Stripe::SubscriptionSchedule.update(
sched.id,
{
end_behavior: "release",
phases: [sched.phases.first.to_hash],
# Ensure that no charge happens
proration_behavior: "none"
}
)
Then obviously I get the error described You can not modify the start date of the current phase. (Stripe::InvalidRequestError), which makes sense because it's exactly what I'm trying to do. Is there another way to do this?
Subscription in question: https://dashboard.stripe.com/subscriptions/sub_JJGILQuykZDaAZ
Log of the failed request: https://dashboard.stripe.com/logs/req_w9qKh0EzGvgMix
(will take me a while)
I'll be around
Okay, I read a few times but I'm quite lost. You are saying the phase starts in the future, but you have a real Subscription which means it doesn't.
You must have a current phase and then a separate one that will start on November 13 2024.
I think you're misunderstanding how this all works (which is not on you, it's unnecesarily complex honestly).
When you create that SubscriptionSchedule from the existing Subscription it has a current phase that represents the current billing cycle that is already in progress on your Subscription.
You can't just go and update the SubscriptionSchedule to erase the current phase and just have a future one. You have to tell us exactly the list of phases that need to apply to this Subscription between now and whatever is your next phase (the current) and then from that date to the end date.
ah gotcha okay. It's forbidden to change the start date of the current phase though so why are you changing it?
Yeah, it's from an error on our end. We charged this customer on Nov 13th, 2023 for this annual subscription, however, this is an insurance policy with annual start dates on April 15th. It's a random error that happened a long time ago that I'm trying to reconcile this year.
So the issue is, if the subscription price is adjusted due to increased or decreased insurance coverage, we'll process a charge/refund based on the prorated remaining time left on the subscription. As it currently stands, if the customer makes an update, they'll get charged/refunded somewhere around 40% of their sub price. We'd like them to be refunded as if they started on April 15th so they get more like ~80% charged/refunded.
Does that make sense?
Like I said, it's insurance, so it's a little bit tricky on our end to just change the policy to have the Nov 13th start date, even though that's obviously the easy answer.
Wanted to explore how possible accomplishing this on the Stripe end was. I realize it's kind of breaking all the rules.
Does that make sense?
Not yet no, I don't really get it unfortunately.
But what you are trying to do is impossible unfortunately, you can't change the start date. You can force a new phase to start in the future but it can't start in the past with a SubscriptionSchedule so I don't think that what you are trying to do is possible
Okay, that's helpful. I was afraid that might be the answer. We've run into this before.
Couldn't remember if there was a workaround we could exploit
Sounds like it may be impossible.
I can't think of one unfortunately ๐ฆ
No worries at all. We'll figure out some way to handle it without updating the current schedule. Thanks for the help!