#kitem-subscriptions
1 messages · Page 1 of 1 (latest)
Hi there!
If I understand correctly you are using subscriptions schedules to manage upgrades/downgrades to your subscription? Can you clarify exactly what is the issue you are facing?
Hey, sure.
Actually I'm scheduling downgrade with subscriptionSchedules.
After I've set one scheduler, the subscription can only be managed by the scheduler and I can't work directly on it.
So for example, I've scheduled a subscription to downgrade the Plan Pro to Plan Basic.
I had an addon that is 100 Users, I want to buy the addon to get up to 10000 users. So in this case I have
- Scheduler that will downgrade the plan
- The Addon that customer want to buy that will be charged in this moment.
My question is, I can manage more phases on scheduler? Or for this case is better cancel the scheduler, update subscription and recreate the scheduler?
Thank you
P.s. because I'm using the upcoming to show a preview of payments, all this operations can lead to an incorrect count
you can add as many phases as you need to a schedule, and update existing phases.
I'm guessing the addon is a on-off payment? you could add that to a phase with https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases-add_invoice_items
addon are recurring payments too
so basically for the subscriptionSchedule I need to go in this way:
phases[0] -> is the current phase, correct?
phases[1] -> is the first update, that will happen now, how can I specify that?
phases[2] -> is the same update I have before the addon I want to buy + the addon I've bought
Is this the flow? Or I can update directly the phases[0]?
can you try to clarify what exactly what you want to update and when? like:
- you want to move from pro plan to basic plan? now?
- and you also want to change from 100 users to 10000 users? now or later?
Oh ok, sure:
- Now I have the pro plan, renewal will be on 30 June 2022.
- I'm downgrading to basic plan, this downgrade will happen following the billing cycle, so on 30 June 2022.
- I'm changing the addon from 100 users to 10000 users, this change will happen now, and I get charged now for this change.
Sorry for the delay, Discord is a busy right now. Will have a look soon.
Thank you
Hey, taking over here. Can you summarise the issue/Q please?
Have you attempted to make create the schedule with the parameters you might need? Did it work as you needed?
Hello, yes I've created the subscription schedule, the use case is this:
Now I have the pro plan, renewal will be on 30 June 2022.
Step 1: I'm downgrading to basic plan, this downgrade will happen following the billing cycle, so on 30 June 2022.
Step 2: I'm changing the addon from 100 users to 10000 users, this change will happen now, and I get charged now for this change.
I don't understand how I have to update the subscriptionSchedule with this cases
What specifically? Is the documentation not answering your Q? Which code have you attempted to run?
You'd be mostly looking to update the phases field to reflect the schedule you want
Code I'm running is this:
` $subscriptionSchedule = \Stripe\SubscriptionSchedule::create([
'from_subscription' => $subscription_id,
]);
$subscriptionUpdate = \Stripe\SubscriptionSchedule::update(
$subscriptionSchedule->id,
[
'end_behavior' => 'release',
'phases' => [
[
'start_date' => $current_period_start,
'end_date' => $current_period_end,
'plans' => [
$itemsOld
],
],
[
'start_date' => $current_period_end,
'plans' => [
$itemsNew
],
],
],
]
);
`
where itemsNew are the new elements and itemsOld are the current one.
Actually this code is working fine, what I don't undestand how to do is how charge the user for the "addon change" (step 2 mentioned before) without cancelling the scheduling setted before (step 1, downgrade of plan)
Well, you'd add a new phase where you add the new addon line item but also keep the existing $itemsNew line item: https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases-items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That has an example of how you add items (and keep the existing) to a schedule
Ok, I've seen that but can't find how it can works.
What I mean is, the upgrading/downgrading is working fine with the code I've sent.
I don't understand how manage the specific case I've said before, because I have the current/old items inside the itemsOld (phases[0]).
itemsNew contains the items will be changed at the end of the billing cycle.
But after the schedule, what I need to change? I need to add the new addon to itemsOld (phases[0]) and set the start_date to now?
Because I need to charge the user on step 2 "now", but need to mantain the scheduling at the end of billing cycle
I'm afraid I'm really struggling to understand your scenario/use case
Can you share some API request IDs so I can see what's actually going on?
Perhaps if you can share the actual Prices you're subscribing to that will help with the context. itemsOld means nothing to me
sure, here the schedule request req_NcrSK8RbFJG7Y2
actually the subscription has a downgrade scheduled from price_1KyyrrE9n8wrXE2iKqZpgFum to price_1KyHqhE9n8wrXE2ivZDYZpC7
inside the subscription i have
premium_test • price_1KyyrrE9n8wrXE2iKqZpgFum
€299.00 EUR / month
quota +100storage • price_1Kw2DsE9n8wrXE2i0PBKcQZY
€49.00 EUR / month
if I have to upgrade the "quota +100storage" to another one, I need to charge the user instantly, without waiting for scheduling. This is what I cannot achieve
because once you have the scheduler on a subscription, you can use only the scheduler to update the subscription (what i've understand), and i need to update the subscription now but without removing the scheduling of the downgrade
What is price_1KyHqhE9n8wrXE2ivZDYZpC7?
Surely your phases field just needs to mirror that in the update call:
phases[0]is the upgrade toprice_1KyHqhE9n8wrXE2ivZDYZpC7(I assume that's the new quota price) andprice_1KyyrrE9n8wrXE2iKqZpgFumphases[1]keepsprice_1KyHqhE9n8wrXE2ivZDYZpC7and then you perform the downgrade here.
Hey, sorry the delay. price_1KyHqhE9n8wrXE2ivZDYZpC7 is the plan that will substitute price_1KyyrrE9n8wrXE2iKqZpgFum
so the one will change at the end of billing cycle
Ok, my suggestion above still applies (you just need to interchange the Price objects for the correct ones)
Ok, so in phases[0] I'll add the new addon and that will be charged directly and upgrades the plan in that moment
in phases[1] I just keep the oldest phase[1] value + the new one I've already added in phase[0]
is this the flow?
Yes, that sounds logical to me