#kirito
1 messages ยท Page 1 of 1 (latest)
subscription_schedule.updated is the best event for being notified when a Subscription Schedule updates (it moving from one phase to the next will update the phases list).
However, you don't need to wait for a Subscription Schedule to move to the next phase before you add another, unless that is a requirement of the business process you're handling, you can queue up as many phases as you like/need.
ok, it is just that every 12 month, will have it own configuration (plan, price, metadata), and the customer should be able to change only the next phase
so when moving from phase to the other a new default phase would be created base on the previews one.
The event.data.object would be of type Stripe.SubscriptionSchedule?
We do not automatically create new phases. If a Subscription Schedule reaches its final phase, then it will execute its end_behavior. That will result in the Subscription being released from (disassociated from) the Subscription Schedule if that is set to release and will cancel the Subscription if it is set to cancel.
So you would need to ensure that there are already multiple phases if you want the Subscription Schedule to remain associated with the Subscription.
I do get the compiling error :
Argument of type '{ items: Stripe.SubscriptionSchedule.Phase.Item[]; start_date: number; iterations: number; metadata: Stripe.Metadata; }' is not assignable to parameter of type 'Phase'.
Object literal may only specify known properties, and 'iterations' does not exist in type 'Phase'.
when I'ma trying to update the SubscriptionSchedule
Hi ๐
Can you share the request ID of the API request that throws that error?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
What version of stripe-node are you using?
"stripe": "^11.5.0",
Okay so that's the current vertsion
yes
And I'm looking at the definition for the type Phase here: https://github.com/stripe/stripe-node/blob/master/types/SubscriptionSchedules.d.ts#L211-L308
I'm not seeing iteration either ๐ค
Yeah but if use it with javascript and not type typescript it work.
the problem only happen with typescript
That makes sense. I'm not sure why iterations are not in the definition for Phase because our API definitely accepts them
Maybe some one forgot to add it ๐
That seems like an odd oversight. We list it here: https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-phases
I am going to raise this internally. Can you share the code you use to create/update the Subscription Schedule?
Ok
```const subscriptionSchedule = await stripe.subscriptionSchedules.update(id, { phases })````
with :
{
items: [{ oldSubscription.items.data[0].price.id }],
start_date: starting,
end_date: ending,
metadata: oldSubscription.metadata,
},
{
items: [{ price: planId }],
start_date: ending,
iterations: 12,
metadata: newMetadata,
},
]````