Stripe Setup Guide
Complete guide to setting up Stripe integration for TinyKit SaaS's billing and subscription system.
Prerequisites
- Stripe account (free to create)
- Access to Stripe Dashboard
Local Development Workflow
When You Need Stripe
You only need Stripe configured when:
- Testing subscription checkout flows
- Verifying webhook event handling
- Debugging billing-related features
- Testing plan upgrades/downgrades
For most development work (UI, authentication, organization management, etc.), pnpm dev is sufficient without Stripe.
Setting Up Stripe for Local Development
When you're ready to test billing features:
-
Run the guided setup (recommended):
pnpm run setup:credentials --stripeThis will guide you through setting up your Stripe API keys and configuring a webhook endpoint in the Stripe Dashboard.
-
Start development:
pnpm dev
Manual Stripe Configuration
If you prefer manual setup, you'll need to set these Convex environment variables:
npx convex env set STRIPE_SECRET_KEY sk_test_...
npx convex env set STRIPE_WEBHOOK_SECRET whsec_...Then create a webhook endpoint in the Stripe Dashboard pointing to your Convex site URL (see "Configure Webhooks" section below).
1. Create Stripe Account
- Sign Up: Go to stripe.com and create an account
- Verify Email: Complete email verification
- Business Information: Add business details (can be updated later)
- Dashboard Access: Access your Stripe Dashboard
2. Get API Keys
Test Mode Keys (Development)
- Navigate to API Keys: Go to Developers > API Keys
- Copy Secret Key: Copy the secret key to set in Convex:
# Test mode key (for development)
npx convex env set STRIPE_SECRET_KEY sk_test_51ABC123...Note: TinyKit SaaS uses Convex backend actions for all Stripe operations, so no publishable key is needed in the frontend.
Live Mode Keys (Production)
Important: Only use live keys in production environments.
- Toggle to Live Mode: Switch to Live mode in top-left of dashboard
- Get Live Secret Key: Copy the live secret key
- Production Environment: Set in Convex production environment
# Live mode key (for production only)
npx convex env set STRIPE_SECRET_KEY sk_live_51ABC123... --prod3. Create Products and Prices
TinyKit SaaS includes a smart product sync system that can create products automatically from seed configuration.
Option A: Automatic Product Creation (Recommended)
- Access Admin Panel: Navigate to
/admin/productsas an admin user - Product Status: System will detect you have no products
- Create from Seed: Click "Sync from Stripe" button
- Confirmation: Review the products that will be created from seed configuration
- Execute: Confirm to create all products in Stripe and sync to database
The system will create these products automatically:
Personal Plans:
- Free: Basic workspace access
- Solo: $9/month, unlimited personal workspaces
- Premium: $19/month, advanced features and API access
Team Plans:
- Starter: $19/month or $190/year, up to 5 team members
- Professional: $29/month or $290/year, up to 20 team members (recommended)
- Enterprise: $39/month or $390/year, unlimited members
- Lifetime: $500 one-time payment, everything included
Option B: Manual Product Creation
If you prefer to create products manually:
Using Stripe Dashboard
- Navigate to Products: Go to Products
- Add Product: Click "Add product"
- Product Details:
- Name: "Professional Plan"
- Description: "Advanced features for growing teams"
- Pricing:
- Price: $29.00
- Billing: Monthly or Yearly
- Currency: USD
- Save Product: Click "Save product"
- Repeat: Create all needed products and prices
Sync Products to Database
After creating products in Stripe (manually or automatically):
- Access Admin Panel: Go to
/admin/products - Sync from Stripe: Click "Sync from Stripe" if you have existing products
- Verify: Check that all products and prices appear correctly
4. Configure Webhooks
Webhooks are essential for keeping your database synchronized with Stripe events.
Automatic Webhook Setup (Recommended)
The stripe:seed script automatically creates and configures the webhook endpoint:
pnpm run stripe:seedThis will:
- Check if a webhook endpoint already exists for your Convex site URL
- Create a new endpoint if none exists, with all required events pre-configured
- Auto-set
STRIPE_WEBHOOK_SECRETin your Convex environment - Update an existing endpoint if it's missing any required events
The webhook URL is derived from NEXT_PUBLIC_CONVEX_SITE_URL in your .env.local:
https://your-project.convex.site/stripe/webhookManual Webhook Setup
If you prefer to configure webhooks manually:
- Go to Stripe Dashboard > Developers > Webhooks
- Click "Add endpoint"
- Set endpoint URL to your Convex site URL:
https://your-project.convex.site/stripe/webhook - Select events: Click "Select all events" (recommended) or choose specific events
- Click "Add endpoint"
- Copy the Signing Secret and set it in Convex:
npx convex env set STRIPE_WEBHOOK_SECRET whsec_...
Production Webhooks
For production, follow the manual setup steps above but:
- Switch to Live mode in the Stripe Dashboard (top-left toggle)
- Create a new webhook endpoint pointing to your production Convex site URL
- Set the live webhook secret in Convex production environment:
npx convex env set STRIPE_WEBHOOK_SECRET whsec_... --prod
Testing Webhooks
# Check your application logs to verify events are received
npx convex logs --tail | grep "stripe\|webhook"
# View webhook delivery status in Stripe Dashboard:
# Developers > Webhooks > [your endpoint] > Recent deliveries5. Configure Customer Portal
The Customer Portal allows customers to manage their own billing.
Enable Customer Portal
Important: This is required for the "Manage Billing" feature to work.
- Access Portal Settings: Go to Billing > Customer portal
- Activate Portal: Click "Activate test link" (for test mode)
- Configure Features:
- ✅ Subscriptions: Allow customers to cancel and switch plans
- ✅ Payment methods: Allow adding and updating payment methods
- ✅ Billing history: Show invoices and payments
- ✅ Customer information: Allow updating customer details
Business Information
-
Business Details:
- Business name: "Your Company Name"
- Support email: "support@yourdomain.com"
- Support phone: Your support phone number
-
Branding (optional):
- Upload logo
- Choose brand colors
- Customize appearance
Policies and Terms
- Terms of Service: Add link to your terms of service
- Privacy Policy: Add link to your privacy policy
- Cancellation Policy: Configure cancellation behavior
Save Configuration
Click "Save" to activate the Customer Portal. Test it works:
# Test customer portal access
# Visit your app and try "Manage Billing" button
# Should redirect to Stripe Customer Portal6. Test Clock Setup (Development)
Test clocks help test time-based features like billing cycles and proration.
Create Test Clock
# Create test clock with specific frozen time
stripe test_clocks create --frozen-time $(date +%s)
# Create test clock for specific date
stripe test_clocks create --frozen-time 1640995200 # Jan 1, 2022
# List test clocks
stripe test_clocks listAdvance Test Clock
# Advance test clock to simulate time passage
stripe test_clocks advance clock_1234567890 --frozen-time $(date -d "+1 week" +%s)
# Advance to specific date
stripe test_clocks advance clock_1234567890 --frozen-time 1641600000 # Jan 8, 2022Use Test Clock in Development
When creating subscriptions in development, they will automatically use the active test clock for accurate proration testing.
7. Environment Variables Summary
All Stripe configuration is done through Convex environment variables (backend-only). No Stripe keys are needed in .env.local since TinyKit SaaS uses Convex backend actions for all Stripe operations.
Convex Environment Variables (Development)
# Set Stripe configuration in Convex
npx convex env set STRIPE_SECRET_KEY sk_test_51ABC123...
npx convex env set STRIPE_WEBHOOK_SECRET whsec_1a2b3c4d5e6f7g8h9i0j...Production Environment Variables
Convex Environment (Production)
# Set production Stripe configuration in Convex
npx convex env set STRIPE_SECRET_KEY sk_live_51ABC123... --prod
npx convex env set STRIPE_WEBHOOK_SECRET whsec_production_secret... --prodSecurity Note: TinyKit SaaS stores all Stripe keys securely in the Convex environment. Secret keys never appear in frontend code or .env.local. No publishable key is required since all Stripe operations use Convex backend actions.
API Version: TinyKit SaaS automatically uses your Stripe account's default API version when no version is specified, ensuring compatibility and allowing you to upgrade API versions through your Stripe Dashboard.
8. Testing the Integration
Basic Functionality Test
- Product Sync: Verify products appear in admin panel
- Subscription Flow: Test creating a subscription
- Webhook Delivery: Verify events are received and processed
- Customer Portal: Test billing management features
Test Card Numbers
Use Stripe test cards for testing:
# Successful payment
4242 4242 4242 4242
# Declined payment
4000 0000 0000 0002
# Requires authentication (3D Secure)
4000 0025 0000 3155
# Insufficient funds
4000 0000 0000 9995Subscription Testing
- Create Subscription: Go through checkout flow
- Upgrade Plan: Test plan changes and proration
- Cancel Subscription: Test cancellation flow
- Reactivate: Test reactivation if applicable
9. Production Preparation
Business Activation
Before going live:
- Business Verification: Complete Stripe business verification
- Bank Account: Add bank account for payouts
- Tax Settings: Configure tax collection if required
- Payout Schedule: Set payout frequency
Security Review
- API Key Security: Ensure live keys are never exposed in client-side code
- Webhook Security: Verify webhook signature validation is working
- Environment Separation: Confirm test and live environments are properly separated
Monitoring Setup
- Stripe Dashboard: Set up email alerts for important events
- Application Monitoring: Monitor webhook processing and errors
- Revenue Tracking: Set up revenue and churn monitoring
Troubleshooting
Common Issues
"No configuration provided" error in Customer Portal
- Solution: Complete Customer Portal configuration in Stripe Dashboard
- Check: Ensure portal is activated for the correct mode (test/live)
Webhook signature verification failed
- Solution: Verify
STRIPE_WEBHOOK_SECRETmatches the endpoint secret - Check: Copy the Signing Secret from your webhook endpoint in the Stripe Dashboard
Products not appearing in admin panel
- Solution: Use admin interface to sync products from Stripe
- Check: Verify Stripe API keys are correctly configured
Test payments failing
- Solution: Use official Stripe test card numbers
- Check: Ensure you're in test mode and using test API keys
Proration amounts incorrect in development
- Solution: Create and use Stripe test clocks for consistent testing
- Check: Verify subscription is attached to test clock
Debug Commands
# Monitor Convex logs for webhook processing
npx convex logs --tail | grep "stripe\|webhook"
# Check webhook delivery in Stripe Dashboard:
# Developers > Webhooks > [your endpoint] > Recent deliveries