#dev_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/1324333547359567914
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! you need to use SubscriptionSchedules to accomplish that.
https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases
can i achive this by setting billing_cycle_anchor to unchanged while updating the subscription
no. The only way to have the update only apply at the end of the current cycle is to either make the API call at that time, or use a SubscriptionSchedule to schedule the change to happen at that time.
what happens if i use this?
nothing really, updates don't usually change the billing anchor anyway, the default is unchanged.
if "selectedPrice" is for example $50 a month, and the current price is $25 a month, and the subscription is anchored on Jan 1st
if you make that API call right now, the subscription changes to the $50 a month price immediately, and the next invoice will be Feb 1st(the same as it was going to be, nothing there has changed) and it might include proration.
if you want the change to the $50 a month price to only happen on Feb 1st, you either make the API call at that time, or use a SubscriptionSchedule to schedule the change to happen at that time
can you give me a short example of subscription schedule here
there are various examples in the docs linked above.
a random snippet too :
// schedule a change from gold to silver at the end of the period
$sched = \Stripe\SubscriptionSchedule::create([
'from_subscription' => $subscription->id,
]);
\Stripe\SubscriptionSchedule::update($sched->id, [
'phases' => [
[
"start_date" => $subscription->current_period_start,
"end_date" => $subscription->current_period_end,
'items' => [
[
'price' => $gold->id,
'quantity' => 1,
],
],
],
[
"start_date" => $subscription->current_period_end,
'items' => [
[
'price' => $silver->id,
'quantity' => 1,
],
],
],
],
"end_behavior" => "release"
]);