#TonyS
1 messages · Page 1 of 1 (latest)
đŸ‘‹ happy to help
I give you some example of code here :
const subscriptionSchedule = await stripe.subscriptionSchedules.create({
from_subscription: "sub_XXX",
})
const currentPhaseItem = subscriptionSchedule.phases[0]
console.log(currentPhaseItem)
await stripe.subscriptionSchedules.update(
"sub_sched_XXXX",
{
proration_behavior: "none",
end_behavior: "release",
phases: [
{
items: [{ price: currentPhaseItem.items[0].price }],
iterations: 1,
},
{
start_date: subscriptionSchedule.current_phase.end_date,
items: [{ price: "price_XXXX", quantity: 1 }],
},
],
}
)
Thank you Tarzan! Hope you are doing well!
Thanks I'm doing fine, reading through your code will be with you in a sec
Great, thank you! Take your time!
what is the result that you're getting and what are you expecting instead?
What we are expecting is : 1) not do anything about current subsription 2) Add a monthly subscription after the end of the yearly one that will renew every month
The errror is the following : StripeInvalidRequestError: The subscription schedule update is missing at least one phase with a start_date to anchor end dates to.
The problem being, if we add a start_start in the first phase it throw this error :
StripeInvalidRequestError: You can not modify the start date of the current phase.
I think we are doing something wrong but I'm unsure about the best way to handle this situation
would you mind sharing the request IDs? https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
there's something I might have missed at first
I thought that the Subscription was already ongoing
and you wanted to make a change
but looking at your logs, the Subscription was created today
Yes we are testing it
we created a yearly subscription to simulate our case
and try to add a monthly subscirption AFTER the end of the active yearly subscirption
sub_1MP20TDhXwH3fVpP6eqrJvCO is the sub_id
so my question is, is your use case regarding a new Subscription where you have that schedule or is it an ongoing Subscription where the customers chooses to change the plan to monthly?
The second one if I understand correctly
An user pay yearly on our service
and decide "I want to pay monthly after the end of my yearly period it will be better"
Sorry if i'm unclear
ok could you maybe be more specific?
yes I will sorry for the confusion I just wanted to make sure we're moving in the right direction
Ok thank you!
would you mind trying out this code?
"sub_sched_XXXX",
{
proration_behavior: "none",
end_behavior: "release",
phases: [
{
...currentPhaseItem
},
{
start_date: subscriptionSchedule.current_phase.end_date,
items: [{ price: "price_XXXX", quantity: 1 }],
iterations: 1
},
],
}
)
Ok i'll try right away
StripeInvalidRequestError: You passed an empty string for ‘phases[0][collection_method]’. We assume empty values are an attempt to unset a parameter; however ‘phases[0][collection_method]’ cannot be unset. You should remove ‘phases[0][collection_method]’ from your request or supply a non-empty value.
const {start_date, end_date, items} = currentPhaseItem;
await stripe.subscriptionSchedules.update(
"sub_sched_XXXX",
{
proration_behavior: "none",
end_behavior: "release",
phases: [
{
start_date, end_date, items
},
{
start_date: subscriptionSchedule.current_phase.end_date,
items: [{ price: "price_XXXX", quantity: 1 }],
iterations: 1
},
],
}
)
did that work for you?
Sorry I'm off to lunch break, I'll test in a moment