#oftysterista_api
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/1397054778726416425
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- oftysterista_api, 17 hours ago, 76 messages
- oftysterista_api, 21 hours ago, 31 messages
- oftysterista_api, 3 days ago, 13 messages
hello orakaro
i am trying to do update price base on the documentation
// Create a subscription schedule with the existing subscription
const schedule = await stripe.subscriptionSchedules.create({
from_subscription: 'sub_ERf72J8Sc7qx7D',
});
// Update the schedule with the new phase
const subscriptionSchedule = await stripe.subscriptionSchedules.update(
schedule.id,
{
phases: [
{
items: [
{
price: schedule.phases[0].items[0].price,
quantity: schedule.phases[0].items[0].quantity,
},
],
start_date: schedule.phases[0].start_date,
end_date: schedule.phases[0].end_date,
},
{
items: [
{
price: '{{PRICE_PRINT_BASIC}}',
quantity: 1,
},
],
iterations: 1,
},
],
}
);
but if my subscription is on trial the trial is end when i run the code
hello are u there?
phases: [
{
items: [
{
price: schedule.phases[0].items[0].price,
quantity: schedule.phases[0].items[0].quantity,
},
],
start_date: schedule.phases[0].start_date,
end_date: schedule.phases[0].end_date,
},
{
items: [
{
price: '{{PRICE_PRINT_BASIC}}',
quantity: 1,
},
],
iterations: 1,
},
],
}
i just did this
Could you share the request id which created the SubSchedule and Update the Schedule?
same as documentation
actually i already update the subscription multiple times
where can i got the id?
i see when i run this
const schedule = await stripe.subscriptionSchedules.create({
from_subscription: 'sub_ERf72J8Sc7qx7D',
});
when i try to log the result, it have 2 phases if the subscription still have a trial
req_6bIp1iGmd4lrPS
this one
i think the trial ends because of when we update the schedule, the first phase is not the trial phase
Yes true, so you want to call the Update SubSchedule API that it preserve the first phase, and only change the second phase
okay so when update the subSchedule, I have to keep the first phase right?
so the trial ends because i font put the trial end value here in the first index
what values do I need to rewrite? because I see the tax is also missing.
So based off the response when you create SubSchedule from_subscription, take everything from there, include the id, make sure they are identical.
Then you only change the sencond phase price id from old id -> new id
so for the sencond phase i only need to copy the last phase from the created SubSchedule then change the priceid?
Yes, but make sure you also include the first phase (the trial one) exactly as the response from previous request
phases: [
// Exactly first phase from previous response,
// Taking second phase from previous response, then change price id,
]
yes i understand, lemme try
i think the second phase we need to get change the start_date and also the end_date? because it is possible if the subscription is not intrialing so the secong phase from created Schedule is not exist
is it correct?
It all depends on the previous response of from_subscription request. You would want to look at its content and decide which phase to change
do i need to copy the phase manually?
I suggest to do so. Not sure what you mean by manually but while you code it, take the response and parse to your parameters
can i just directly update the subcription if i want to change the price for the next period?
or does it have to use a schedule?
hi there, taking over the thread from my colleague ๐ give me some time to catch up
if you are changing price on a subscription that is held by a subscription schedule, you need to update the subscription schedule directly
you cannot update the subscription directly because that will result in conflicts with the subscription schedule it is tied to.
no i mean like,
my goal is update a price for the next period.
so to achieve that goal can i just use subscription.update api or i have to use the subSchedule api?
if you intend the price to only take effect in the next period, then you should use the subscription schedule API
i see
actually i have an issue when i want to copy the phase
as u can see in this docs, it create a schdule then update it with the first phase is comming from the created schedule
but the issue is it only takes the item, start date and end date. some value is missing for example like trial ends, and default tax
i can defined two of those (trial ends and the default tax) but i worry if there is other is missing
I see. That's ultimately a sample provided in our docs. You should refer to our API reference as the source of truth to know what parameters phases accept: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases
For example, if your subscription changes collection_method in different phases, that's also something you can define under phases
generally you only need to define parameters you have changed but you should also check your subscription's configuration and ensure it aligns to the default values for each parameters under phases just to ensure nothing else changes
lemme try, cause what i have tried is for example i want to keep the current phase. but i dont defined the trial_end it makes the current phase end the trial period immediately
hi @acoustic fiber to clarify, when you are creating a subscription schedule off an existing subscription that is trialing, the first phase of the schedule must mirror your subscription's existing state. so if your subscription is currently running on a trial, you can use phases.trial and phases.trial_end to signify that the trial is in progress and when it ends.
yes i did it
it is the same with the default_tax_rates
if i dont set it the tax is missing too
but i dont know if is there any other things that i need to rewrite it
do you have a subscription ID that you could share?
I'm looking at the creation request [0] of that subscription, from what I can see, passing tax rates and price and specifying the trial is sufficient when defining phases on the subscrption schedule.
[0] https://dashboard.stripe.com/test/logs/req_eq3PUwSwRuTLsi
so price, trial and tax is enough?
Yes. Those are the attributes of the subscription you want to keep, right? When updating subscription schedules, you need to pass in any previously set parameters that you want to keep: https://docs.stripe.com/billing/subscriptions/subscription-schedules#updating
Let us know if you run into anything unexpected during your test
yes i think it is good enough at least for now