#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/1396757497330794529
đ 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, 1 hour ago, 31 messages
- oftysterista_api, 2 days ago, 13 messages
hello sam
it's me again
i have tried the docs u given
but when i try to do stripe.subscriptionSchedules.create
the response doesn't have schedule.phases[
Hi! I had to delete your message as it contained your secret test key. Can you post it again but without the secret key please?
ohh sorry thanks
so yeah
const schedule = await stripe.subscriptionSchedules.create({
from_subscription: 'sub_xxxx',
});
the docs tell to do that
then
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 subscriptionSchedules.create doesn't have schedule.phases[0].items[0].price
For sub_1RlnatKxUzgEvuWhz0WvpPKH, I see that you only created the subscription schedule: https://dashboard.stripe.com/test/logs/req_Me8RArGjKyFJs4
You need to follow the rest of the code in the document (https://dashboard.stripe.com/test/logs/req_Me8RArGjKyFJs4, row 11 onwards) to create the phases.
but how can i fill this value?
price: schedule.phases[0].items[0].price,
quantity: schedule.phases[0].items[0].quantity,
schedule.phases[0] doesn't exist
wait
i think it is exist
sorry my bad
what will happen if we create a more than 1 schedule ?
For the same subscription?
yes
You can only create 1 active subscription schedule per subscription. You can create another one if you release the first schedule: https://docs.stripe.com/api/subscription_schedules/release
You can also set the end_behavior for the subscription schedule: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-end_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
so if i want to create a new update, i need to release the previous one first right?
release the schedule will not roll back the phase that is already running, right?
are u still there sam?
I'm taking over. You should be able to update the existing schedule's phases. No need to release and attach a new schedule
how to do it?
will there be any shortcomings? for example if there is already a phase that is running
what if i just release the current schedule and create a new one?
Yes you can update the current phase. So you just need to make sure you pass the existing phase JSON into the payload for the update if you want it to remain the same
You need to pass in all current and future phases when you update a subscription schedule. You also need to pass in any previously set parameters that you want to keep. **Any parameters that were previously set are unset for the existing phase unless you pass those in the update request. **You still receive information in the response about past phases.
what about this?
what if i just release the current schedule and create a new one?
if I don't want to keep the previous schdule, but want to replace it with a new one, does that mean I only need to enter the current phase and the next phase?
Sure you can do that
I don't understand. What do you mean by 'previous schedule'?
if i realease the schedule, it will not affect the subcription right?
No, the subscription will continue on it's current 'phase'
okay i think it is simpler
but to release the schedule, the status must be active and not_active?
not_started or active, yes: https://docs.stripe.com/api/subscription_schedules/object#subscription_schedule_object-status
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
completed
released
canceled
For these 3 statuses, we can override them with a new schedule, right?
Sort of I guess
i have other question
when create a subsription, i fill this
default_tax_rates : [taxRate.stripeTaxRateId]
when creating a schedule, should i put it again?
Yes you'd pass it to the phase(s): https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-default_tax_rates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
iterations: 12,
what is iterations in the phases?
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.
e.g. how many times the phase runs before it transitions to next phase
okay i see
let's back to the tax rate
so i need to defined the default tax rates even in the first phase?
Yes, in every phase you want the rates to apply
so basically i need to defined all thing like when i want to create the subcription in the phase?
const schedule = await this.stripeClient.subscriptionSchedules.create({
from_subscription: stripeSubscriptionId,
});
await this.stripeClient.subscriptionSchedules.update(schedule.id, {
phases: [
{
items: [
{
price:
typeof schedule.phases[0].items[0].price === 'string'
? schedule.phases[0].items[0].price
: schedule.phases[0].items[0].price.id,
quantity: schedule.phases[0].items[0].quantity,
},
],
start_date: schedule.phases[0].start_date,
end_date: schedule.phases[0].end_date,
},
{
items: [
{
price: prices.data[0].id,
quantity: 1,
},
],
iterations: 1,
},
],
});
in the documentation, i saw it rewrite the first phase,
what if i dont rewrite the first phase. instead i just put the second phase with the start_date : schedule.phases[0].end_date
If you don't rewrite the first phase, then the second phase will be considered as the first phase
You need to keep the first phase, if you want to change just the second phase
so my objective is change the price in the next period.
what if i only give 1 phase which will start at the end of the current period?
forexample current price is 100$ the next month will be 500$
what if i only give 1 phase which will start at the end of the current period?
No you need to specify the 1st/existing phase too
And add a second phase with the new price
i see
okayy
so what should i defined in the first phase?
because previously i am not define the default tax
and it is gone when the schedule is created
{customer: stripeCustomer.customerId,
items: [
{
price: prices.data[0].id,
},
],
expand: ['latest_invoice.payment_intent'],
payment_behavior: 'allow_incomplete',
payment_settings: {
save_default_payment_method: 'on_subscription',
},
default_payment_method: stripePaymentMethodId,
metadata,
default_tax_rates: taxRate ? [taxRate.stripeTaxRateId] : undefined,
trial_period_days: payload.trialPeriodDays,
}
this is the payload when i create the subscription
so what should i defined in the first phase?
You specify the existing phase, you can make a get by Id to the Subscription details before updating it. And then update the schedule by specifying the first phase details from the get by id response