Skip to content

Commit 9d7fdfe

Browse files
committed
docs(stripe): add trial period configuration documentation
- Document trialDays parameter in billing.ts - Explain how trials work (trialing status, auto-charge after N days) - Add table showing configuration location and defaults - Note that trial is set in code, not Stripe Dashboard
1 parent 8078f98 commit 9d7fdfe

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

docs/features/STRIPE_INTEGRATION.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,49 @@ async function createCheckout(userId: string, priceId: string) {
137137
metadata: { userId, priceId },
138138
subscription_data: {
139139
metadata: { userId },
140+
trial_period_days: 3, // ← Free trial before first charge
140141
},
141142
});
142143
return session.url;
143144
}
144145
```
145146

147+
### Trial Period Configuration
148+
149+
> **Important**: Trial periods are configured in code, NOT in the Stripe Dashboard.
150+
151+
| Setting | Location | Default | Notes |
152+
|---------|----------|---------|-------|
153+
| `trialDays` | `billing.ts` line 335 | 3 days | Passed to Stripe at checkout |
154+
| Trial ending email | `customer.subscription.trial_will_end` webhook | 3 days before end | Sends reminder email |
155+
156+
To change the trial period:
157+
158+
```typescript
159+
// packages/api-gateway/src/routes/billing.ts
160+
const session = await stripeService.createCheckoutSession({
161+
userId,
162+
email,
163+
tier: tier as SubscriptionTier,
164+
isYearly,
165+
promoCode,
166+
trialDays: 3, // ← Change this value (0 to disable trials)
167+
});
168+
```
169+
170+
**How trials work:**
171+
1. Customer subscribes → Card is validated but NOT charged
172+
2. Subscription status = `trialing` for the trial period
173+
3. After trial ends → Stripe automatically charges the card
174+
4. Subscription status = `active`
175+
176+
**Trial behaviors:**
177+
- No payment collected during trial (card is authorized only)
178+
- User has full access to paid features during trial
179+
- `customer.subscription.trial_will_end` webhook fires 3 days before end
180+
- If payment fails after trial, status becomes `past_due`
181+
```
182+
146183
### Webhook Events to Handle
147184
148185
| Event | Action |

0 commit comments

Comments
 (0)