#axman-schedules-upcoming
1 messages Β· Page 1 of 1 (latest)
Example of sub if it can help sub_1M9qLjIejvM8YGelbtCKg9pn
Thanks for the info. Trying to think of how to achieve that behavior here
So just to confirm, the actual updates are working fine, it is getting the preview to use the current quantity not the quantity in the next phase?
Yes actual update are fine as far as we can see,
- upgrade by adjusting quantityπ
- downgrade with subscription schedule and tested with test clock π
- info on stripe dashboard looks okay on subscription and scheduleπ
- preview of upcoming invoice with change of number of seats (quantity) but no subscription schedule π
- preview of upcoming invoice but there is a schedule subscription seems to take over whatever quantity we put in the upcoming invoice items β οΈ
it is getting the preview to use the current quantity not the quantity in the next phase?
it's actually getting the quantity of the next phase and ignore whatever we give as params of items.quantity
we would have expected to actually ignore the schedule in this case, proration is set none and we want the full price for whatever quantity
sorry Discordis really busy and this is quite a lot of text to get through so will take me some time to respond
No problems at all π for updating
Okay I read through it but I'm unfortunately not following
Can you share a simple end to end code to reproduce the problem?
axman-schedules-upcoming
const subscriptionId = 'sub_1M9qLjIejvM8YGelbtCKg9pn'
// This subscription has currently a quantity of 7
// this subscription also a schedule to go down to to 5 at end of billing cycle
const subscription = await stripe.subscriptions.retrieve(subscriptionId);
// We want to let the user preview what would be the price if we had 3 seat for this subscription, so downgrade even more that current schedule.
const items = [
{
id: subscription.items.data[0].id,
quantity: 3,
},
];
const previewInvoice = await stripe.invoices.retrieveUpcoming({
subscription: subscriptionId,
subscription_items: items,
subscription_proration_behavior: 'none',
});
Here we go more something like that, this work well if there is no schedule subscription, but with a schedule it would return the quantity of 5 whatever with put as quantity π€ it make more sense
someone on my team is working on this
π Hopping in here!
@old bay Just want to confirm - your ideal behavior would be that you you want to preview what the Upcoming Invoice would like if the quantity for the next Subscription Schedule were changed. So say you have a Schedule with a current quantity of 7 and the next phase has a quantity of 5. You want the upcoming Invoice to reflect what it would look like if 5 were changed to 3?
@late rover exactly, I think this would make sense, basically similar as if there was no schedule subscription (which is working well)
to keep it simple I got a schedule sub and want indeed the user to preview the invoice if the schedule quantity was updated to the number of seat user want
I bought 7 seats I pay currently X amount
I go down do 5 with schedule sub so I will pay X amount next billing cycle
Before next billing cycling user want to update number of seat for next billing cycle to another number and preview it (in example to 3 but could be any number)
(trying to replicate a bit what the customer portal do when updating quantities before actually doing the action)
So the reason this isn't working as you expect it to is because of how Subscription updates work when they're backed by a Schedule - say you have a Subscription backed by a Schedule with two phases:
- Phase 1 has quantity 1 and ends at the end of the current cycle
- Phase 2 has quantity 3 and starts after Phase 1
If you were to update that Subscription to have quantity: 5, the Schedule would be updated like this:
- Phase 1 with quantity 1 is ended immediately
- (NEW) Phase 2 with quantity 5 is not started and ends at the end of the current cycle
- Phase 3 has quantity 3 and starts after Phase 2
Since passing subscription_items to the upcoming invoices endpoint mirrors what a Subscription Update would look like, the response you get is showing you what the Invoice will look like at the end of the current cycle (when Phase 3 starts), and Phase 3 is still the same
π this actually make sense when reading it like that, and probably what I expected (but didn't want to hear π )
I'm guessing there is no easy way to go around that? We tried few things while trying to find a workaround but no luck
So my follow up questions are:
- Would it be better for us to not use Schedule if we want to achieve the expected behavior and do something more manual (which we tried to avoid)
- Not great but I guess a simple math based on the schedule quantity return, the total and the quantity we want, should do the job π as tax are already applied etc? (and again doing the action itself work so it would just be as preview) - and given the price is classic price per seat no volume/metered etc
In terms of a workaround it depends on what you're using from the upcoming invoice - if you're only displaying a price for your users to preview, you could do a hack where you also pass in subscription_billing_cycle_anchor: now to preview what the invoice would look like if you reset the billing cycle anchor (which would use the new quantity you just passed in).
π π I actually missed the the api doc on this one, I thought it was only for new subscription π this make sense as a workaround as we only use the total in this case,
we also used the date next billing cycling but this can get on my side as well and prefer to play with a date that doing some math on our side, you're the experts on this not us π
Thanks a lot for your help, got a better understanding of Schedule and a workaround π and quite incredible support (especially when I see the number of message in the channel)