#andrew.cai
1 messages · Page 1 of 1 (latest)
I need to set the number of subscriptions in one cycle in advance for the next cycle
how can i do in api
This can be done with Subscription Schedule API.
- Create subscription schedule on existing subscription: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
- Update the quantity in the next phase: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#increasing-quantity
what is the start_date
this?
Is this to cancel the original subscription and re subscribe?
The example in the doc is for creating a new subscription schedule without existing subscription.
For existing subscription, Update subscription schedule API should be used and start_date is not required to set: https://stripe.com/docs/api/subscription_schedules/update
Example request with updating subscription schedule:
{
end_behavior: 'release',
phases:[
{
items: [
{price: 'price_xxx', quantity: 1}
],
iterations: 1,
start_date: subscription.current_phase.start_date
},
{
items: [
{price: 'price_xxx', quantity: 2}
],
iterations: 1
}
]
}
For example, these subscriptions this month are 0, and they will be changed to other quantities starting next month.
"subscription.current_phase.start_date" Is it a value or a meaning?
Yup! You can set the with Subscription Schedule API by scheduling to update the quantity in next month
The usage scenario is as follows: starting from next month, billing will be based on the number of new subscriptions until the next time the number needs to be modified. Is this the step?
1、create a subscription schedule
2、update this schedule quantity
If the start_date is not set, it will automatically start from the next cycle, right
Above steps are correct. The start_date will be using the start_date from the existing subscription if it's not set
You should be able to see an icon displaying Update scheduled in the subscription page
You cannot set phases if from_subscription is set.
Could you share the request ID (req_xxx) where you received this error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_5llJVtULmq19Z7
You can't add phases when creating a subscription schedule on existing subscription. The steps will be:
- Create a subscription schedule with only
from_subscription - Then update the phases with update subscription schedule API
As mentioned in the response, you'd need to set the iteration or end_date of the first phase. First phase is usually the existing phase. If you wish to end the currenct cycle as usual, then you can set the iteration of first phase to 1 and the quantity change in second phase will kick in next month.
iterations: https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases-iterations
Integer representing the multiplier applied to the price interval. For example, iterations=2 applied to a price with interval=month and interval_count=3 results in a phase of duration 2 * 3 months = 6 months. If set, end_date must not be set.
After this iteration is set, will the quantity change back when the time is up?
req_o6caRXpR7g1Vdf
For example,
- Subscription is created with quantity of 1 for monthly price on 1 Jan 2023
- Create subscription schedule and update the first phase (existing cycle) to iteration to 1 and second phase (next cycle) to 2
- The quantity of existing cycle will remain as 1 and change to quantity 2 once the next phase reaches on 1 Feb 2023
I provided you an example above just now:
{
end_behavior: 'release',
phases:[
{
items: [
{price: 'price_xxx', quantity: 1}
],
iterations: 1,
start_date: subscription.current_phase.start_date
},
{
items: [
{price: 'price_xxx', quantity: 2}
],
iterations: 1
}
]
}
You'd need to set the start_date of the first phase to the start_date of current phase
req_iXwOjHe18Sgv6B
you don't have specifiy start_date in the second phase. it'll pick up the end date from the first_phase
could you please have a look at the example request i shared above?
Is that mean?
phases[0] is current cycle
phases[1] is next cycle
Yep, correct
If my current cycle does not need to be changed,
is still need to fill in phases[0].items?
yes! current phase is required to set in phases[0]. you can retrieve it in the response when you create subscription schedule
ok i got it! thanks!
another question
Is there a pre quotation interface
like
how much will it cost if I modify the subscription quantity in the next cycle
👋 taking over here
I think you can use Upcoming Invoice API
passing in conditions and it will output a simulated Invoice based on the provided conditions
If there are documents, I can read them first, and then come to ask you if there are any questions later
Sure, there is a Doc for Upcoming Invoice API here: https://stripe.com/docs/billing/invoices/subscription#previewing and API Reference here https://stripe.com/docs/api/invoices/upcoming