Testing Monthly Plan Changes
1. Start Stripe CLI to forward webhooks
bash
stripe listen --forward-to localhost:3000/api/auth/stripe/webhookCopy the whsec_... secret it prints and set it as STRIPE_WEBHOOK_SECRET in your .env.
2. Use Stripe test cards
| Scenario | Card Number |
|---|---|
| Successful payment | 4242 4242 4242 4242 |
| Card declined | 4000 0000 0000 0002 |
| Insufficient funds | 4000 0000 0000 9995 |
Use any future expiry (e.g. 12/34) and any 3-digit CVC.
3. Test flows
Subscribe (Free → Gold/Diamond)
- Go to
/membership - Click subscribe on a plan → redirects to Stripe Checkout
- Pay with test card → webhook
checkout.session.completedfires → tier updates, credits granted
Upgrade (Gold → Diamond)
- Use the Manage Billing button on
/membership→ opens Stripe Customer Portal - Change plan to Diamond → webhook
customer.subscription.updatedfires - Upgrade is immediate with proration (charged the difference now)
- Differential credits granted (e.g. 24,000 − 4,000 = 20,000 extra)
Downgrade (Diamond → Gold)
- Same portal flow → downgrade takes effect at period end (no immediate refund)
- Tier stays Diamond until the billing period ends
Cancel
- Cancel in portal →
cancel_at_period_endset to true, access continues until period end - When period ends →
customer.subscription.deletedfires → tier drops to FREE
Resume cancelled subscription
- Click "Resume" on
/membership→ callsauthClient.subscription.restore()
4. Trigger webhooks manually (optional)
bash
stripe trigger customer.subscription.updated
stripe trigger customer.subscription.deleted
stripe trigger invoice.payment_succeeded5. Verify results
- Check
/membershippage for updated tier and credit balance - Check
/api/v1/membership(GET) for subscription status and transaction history - Check Stripe Dashboard (test mode) for subscription details