Skip to content

Testing Monthly Plan Changes

1. Start Stripe CLI to forward webhooks

bash
stripe listen --forward-to localhost:3000/api/auth/stripe/webhook

Copy the whsec_... secret it prints and set it as STRIPE_WEBHOOK_SECRET in your .env.

2. Use Stripe test cards

ScenarioCard Number
Successful payment4242 4242 4242 4242
Card declined4000 0000 0000 0002
Insufficient funds4000 0000 0000 9995

Use any future expiry (e.g. 12/34) and any 3-digit CVC.

3. Test flows

Subscribe (Free → Gold/Diamond)

  1. Go to /membership
  2. Click subscribe on a plan → redirects to Stripe Checkout
  3. Pay with test card → webhook checkout.session.completed fires → 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.updated fires
  • 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_end set to true, access continues until period end
  • When period ends → customer.subscription.deleted fires → tier drops to FREE

Resume cancelled subscription

  • Click "Resume" on /membership → calls authClient.subscription.restore()

4. Trigger webhooks manually (optional)

bash
stripe trigger customer.subscription.updated
stripe trigger customer.subscription.deleted
stripe trigger invoice.payment_succeeded

5. Verify results

  • Check /membership page 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

Internal documentation for MysticX team