7.8 KiB
🎭 Testing Stripe with Fake Accounts - Super Simple Guide
🚀 Quick Start (5 Minutes)
Step 1: Make Sure Stripe Test Mode is ON
In Stripe Dashboard, ensure you're in TEST MODE (toggle in top-right corner should say "Test mode").
Step 2: Create "Standard" Product in Stripe
- Go to Products in Stripe Dashboard
- Click Add product
- Name:
Standard - Monthly price:
€9.99/month - Click Add product
- Copy the price ID (looks like
price_1O7...) - Add to
apps/main/.env:VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID=price_YOUR_ID_HERE
Step 3: Start Everything
Terminal 1 - API:
cd apps/api
npm run dev
Terminal 2 - Frontend:
cd apps/main
npm run dev
Terminal 3 - Stripe Webhooks:
stripe listen --forward-to http://localhost:3000/api/v1/stripe/webhook
Copy the webhook secret (whsec_...) and add to api/.env:
STRIPE_WEBHOOK_SECRET=whsec_YOUR_SECRET_HERE
Restart your API (Terminal 1).
Step 4: Create Fake Test Accounts
Create 3 test users in your app:
Account 1: Free User (stays free)
Email: free.user@test.com
Password: TestPass123!
Name: Free User
Account 2: Premium User (will subscribe)
Email: premium.user@test.com
Password: TestPass123!
Name: Premium User
Account 3: Canceling User (subscribe then cancel)
Email: cancel.user@test.com
Password: TestPass123!
Name: Cancel User
🧪 Testing Scenarios
Test 1: Free User ✅
- Login as
free.user@test.com - Go to Settings
- You should see:
- Badge: "Gratuit"
- Message: "Passez à Standard..."
- Button: "Passer à Standard"
Verify in database:
SELECT email, is_paying, subscription_tier
FROM profiles
WHERE email = 'free.user@test.com';
-- Should show: is_paying = false, subscription_tier = 'free'
Test 2: Subscribe to Standard 💳
-
Login as
premium.user@test.com -
Go to Settings
-
Click "Passer à Standard"
-
In Stripe Checkout, enter:
Email: premium.user@test.com Card: 4242 4242 4242 4242 Expiry: 12/34 CVC: 123 Name: Premium User -
Click Subscribe
-
Watch Terminal 3 - You should see:
✓ customer.created ✓ customer.subscription.created ✓ invoice.created ✓ invoice.paid ✓ payment_intent.succeeded -
You'll be redirected back to Settings
-
You should see:
- Badge: "Actif" (green)
- Message: "Plan Standard"
- Renewal date displayed
- Buttons: "Gérer l'abonnement" and "Annuler"
Verify in database:
-- Check profile updated
SELECT email, is_paying, subscription_tier
FROM profiles
WHERE email = 'premium.user@test.com';
-- Should show: is_paying = true, subscription_tier = 'standard'
-- Check subscription exists
SELECT status, current_period_end, cancel_at_period_end
FROM stripe_subscriptions
WHERE user_id = (SELECT id FROM profiles WHERE email = 'premium.user@test.com');
-- Should show: status = 'active', cancel_at_period_end = false
-- Check customer exists
SELECT * FROM stripe_customers
WHERE email = 'premium.user@test.com';
Test 3: Customer Portal 🏪
- Still logged in as
premium.user@test.com - Click "Gérer l'abonnement"
- Opens Stripe Customer Portal where you can:
- View/download invoices
- Update payment method
- View subscription details
- Cancel subscription
Test 4: Cancel Subscription ❌
- In your app (as
cancel.user@test.com) - Subscribe first (follow Test 2)
- Click "Annuler" button
- Watch Terminal 3:
✓ customer.subscription.updated - You should see:
- Orange warning: "Abonnement en cours d'annulation"
- Message: "Sera annulé le [date]"
- Button: "Réactiver l'abonnement"
Verify in database:
SELECT cancel_at_period_end, current_period_end
FROM stripe_subscriptions
WHERE user_id = (SELECT id FROM profiles WHERE email = 'cancel.user@test.com');
-- Should show: cancel_at_period_end = true
-- Note: is_paying should STILL be true until period ends
SELECT is_paying FROM profiles WHERE email = 'cancel.user@test.com';
-- Should show: is_paying = true (until period_end)
Test 5: Reactivate Subscription ↩️
- Click "Réactiver l'abonnement"
- Watch Terminal 3:
✓ customer.subscription.updated - Should return to normal active state
Verify in database:
SELECT cancel_at_period_end
FROM stripe_subscriptions
WHERE user_id = (SELECT id FROM profiles WHERE email = 'cancel.user@test.com');
-- Should show: cancel_at_period_end = false
🎯 Quick Verification Script
Run this in Supabase SQL Editor after testing:
-- View all test users and their subscriptions
SELECT
p.email,
p.is_paying,
p.subscription_tier,
s.status as sub_status,
s.cancel_at_period_end as canceling,
to_char(s.current_period_end, 'YYYY-MM-DD') as expires
FROM profiles p
LEFT JOIN stripe_subscriptions s ON s.user_id = p.id
WHERE p.email LIKE '%test.com'
ORDER BY p.created_at DESC;
Expected results:
free.user@test.com | false | free | null | null | null
premium.user@test.com | true | standard | active | false | 2025-12-02
cancel.user@test.com | true | standard | active | true | 2025-12-02
🎴 Test Card Cheat Sheet
| Scenario | Card Number | Use For |
|---|---|---|
| ✅ Success | 4242 4242 4242 4242 |
Normal subscription |
| ❌ Decline | 4000 0000 0000 0002 |
Test payment failure |
| 💳 3D Secure | 4000 0027 6000 3184 |
Test authentication |
| 🏦 Insufficient | 4000 0000 0000 9995 |
Test insufficient funds |
For all cards:
- Expiry: Any future date (e.g.,
12/34) - CVC: Any 3 digits (e.g.,
123) - ZIP: Any 5 digits (e.g.,
12345)
🐛 Troubleshooting
"Passer à Standard" button doesn't work
Check:
// In browser console:
console.log(import.meta.env.VITE_STRIPE_STANDARD_MONTHLY_PRICE_ID);
// Should show: price_xxxxx
If undefined, add to apps/main/.env and restart frontend.
Webhook not received
Terminal 3 should show:
⣾ Ready! Your webhook signing secret is whsec_xxxxx
If not, run:
stripe listen --forward-to http://localhost:3000/api/v1/stripe/webhook
is_paying not updating
Check webhook was processed:
# In Terminal 3, you should see:
✓ customer.subscription.created [200]
Manually trigger update:
-- Force update profile
UPDATE profiles
SET is_paying = true, subscription_tier = 'standard'
WHERE email = 'premium.user@test.com';
Can't see SubscriptionCard
Add to settings.tsx:
import { SubscriptionCard } from "../components/SubscriptionCard";
// In the cards section:
<SubscriptionCard />
✅ Success Checklist
After testing all 3 accounts, you should have:
- Free user shows upgrade prompt
- Premium user shows active subscription
- Webhook events appear in Terminal 3
- Database shows correct subscription data
is_payingupdates automatically- Can cancel subscription
- Cancellation shows warning
- Can reactivate subscription
- Customer portal opens correctly
- Each user only sees their own data
🎉 You're Done!
If all checks pass, your Stripe integration is working perfectly!
Next steps:
- Test with more edge cases (different cards, failed payments)
- Add subscription checks to premium features
- Build pricing page
- Prepare for production deployment
🔗 More Information
- Complete Setup:
docs/STRIPE_SETUP.md - Quick Reference:
docs/STRIPE_QUICK_REFERENCE.md - Detailed Testing:
docs/STRIPE_TESTING_GUIDE.md - API Documentation:
docs/STRIPE_IMPLEMENTATION_SUMMARY.md
Pro Tip: Keep these test accounts for future testing. You can reset them by deleting subscriptions in Stripe Dashboard (Test Mode → Subscriptions).