-
Notifications
You must be signed in to change notification settings - Fork 824
Description
Describe the bug
The Stripe.SubscriptionSchedule.Phase
type in TypeScript is missing the trial
property. I am currently using SubscriptionSchedules to sign up my users for a free 30-day trial of my product, then, I move them to the free tier. If a user wants to make changes to their subscription before the trial runs out, I have to know this since they can only make certain changes to the trial. To create the first phase, I am using trial: true
and end_date: _in 30 days_
, since this phase should only be a trial. When checking currentPhase.trial
, TypeScript complains that trial
isn't part of Phase
. But when I log out my phases to the console, the first phase has trial: true
and the rest of the phases just don't have trial
, so this should be an optional property. Currently, I have to extend the Phase
type into my own custom type and add trial
.
To Reproduce
- Create a Subscription Schedule where the first phase is a trial phase
await stripe.subscriptionSchedules.create({
customer: CUSTOMER_ID,
start_date: Math.floor(Date.now() / 1000),
phases: [
{
items: [{ price: PRO_MONTHLY_PRICE, quantity: 1 }],
trial: true,
end_date: Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60,
},
{
items: [{ price: FREE_TIER_PRICE, quantity: 1 }],
},
],
});
- Retrieve your Subscription Schedule
const schedule = await stripe.subscriptionSchedules.retrieve(NEW_SCHEDULE_ID);
- Log the phases out to the console and verify that the first phase indeed does have a
trial
property set totrue
.
console.log(schedule.phases);
- Make an attempt to access the
trial
property in the first phase
const isTrial = schedule.phases[0].trial;
Expected behavior
When attempting to access the trial
property in a Phase, I should not see an error saying that the trial
property does not exist in my phase.
Code snippets
OS
macOS
Node version
Node v20.12.1
Library version
stripe v17.7.0
API version
2025-02-24.acacia
Additional context
No response