#borys
1 messages · Page 1 of 1 (latest)
here is the code snippet
const subscription = await stripe.subscriptions.retrieve(
"sub_1Lmgn81WJGsEk3QvMNTN03yG"
);
const subscriptionSchedule = await stripe.subscriptionSchedules.retrieve(
subscription.schedule
);
const newQuantity = 2;
const phases = [];
console.log(subscriptionSchedule);
subscriptionSchedule.phases.forEach((phase) => {
if (new Date(phase.end_date * 1000).getTime() < Date.now()) {
// phase ended, cannot be updated, but need to preserve the order
phases.push({
items: [], // because of "Missing required param: phases[0][items]" error
end_date: phase.end_date,
start_date: phase.start_date,
});
} else {
phases.push({
items: phase.plans.map((item) => ({
price: item.price,
quantity: newQuantity,
})),
end_date: phase.end_date,
start_date: phase.start_date,
});
}
});
console.log("updating with", phases);
const subscriptionScheduleUpdated = await stripe.subscriptionSchedules.update(
subscription.schedule,
{ phases }
);
console.log("updated", subscriptionScheduleUpdated);
but the update request still fails
What error message do you get back on the failure?
when running that code, still getting missing error
StripeInvalidRequestError: Missing required param: phases[0][items].
Can you send me a request ID from a time you got that error? https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thank you, checking in to that request
So I am interested in your because of "Missing required param: phases[0][items]" error comment. You introduced that line of code to address that error?