Purpose
Retrieves subscription status directly from Stripe, including trial period information. This enables the frontend to display how many days remain in a userβs free trial.Architecture
How Trial Days Are Calculated
-
Retrieve Subscription: Fetch the subscription object from Stripe using
stripe.Subscription.retrieve(subscription_id) -
Check Status: Verify
subscription.status === "trialing" -
Get Trial End: Extract
subscription.trial_end(Unix timestamp in seconds) - Calculate Remaining Days:
Response Format
| Field | Type | Description |
|---|---|---|
status | string | Stripe subscription status |
trial_end | int | null | Unix timestamp when trial ends |
days_remaining | int | null | Days left in trial (0 if ending today) |
Fallback Behavior
If Stripe API fails, the endpoint falls back to returning thesubscription_status stored in clerk_organization_details table, with trial_end and days_remaining as null.