#Prince
1 messages · Page 1 of 1 (latest)
hi
Hi! Not sure I follow. Trials aren't set on a price object
i am using this below code to get trial days from current price object
price.getRecurring().getTrialPeriodDays();
so how can i get trial days from subscription?
Subscription objects have trial_start and trial_end timestamps that you can use to calculate the number of days left on a trial: https://stripe.com/docs/api/subscriptions/object#subscription_object-trial_end
but does stripe has changed the price object, because i have used the above code before and that gives me the trial days but now i am getting null. could you please explain more on this?
Do you have an example of when this worked (e.g. a Stripe request ID)? Price objects indeed have a recurring property but no trial details as part of that property: https://stripe.com/docs/api/prices/object#price_object-recurring
no i have used this before, it's working fine but now i am getting error
check this subscription id -> sub_1M0PtDKmlDsDVSTggiQCyiB2
it has a trial days under price, if you check his subscription object
Ah, looks like trial_period_days on prices is no longer a recommended approach. Trials should be added to subscriptions instead
so now the only solution is to use trial_start and trial_end?
It's recommended to configure the trial details on the subscription (not the price), either with trial_end or trial_period_days - https://stripe.com/docs/billing/subscriptions/trials