Complete guide to setting up Stripe for Broadcast subscriptions.
Broadcast uses Stripe for:
- Subscription management (Creator, Professional, Enterprise)
- 14-day free trials
- Automatic billing
- Customer portal (change cards, cancel, invoices)
- Webhook notifications
- Go to stripe.com
- Sign up for a free account
- Complete business verification (required for live mode)
-
Copy these keys:
- Publishable key (starts with
pk_test_) - Secret key (starts with
sk_test_) - Keep this secure!
- Publishable key (starts with
-
Add to your
.env:
STRIPE_SECRET_KEY=sk_test_your_key_here
STRIPE_PUBLISHABLE_KEY=pk_test_your_key_here- Complete Stripe activation
- Go to dashboard.stripe.com/apikeys
- Copy live keys (start with
pk_live_andsk_live_) - Update production
.env
- Go to Products
- Click "+ Add product"
- Fill in:
- Name: Creator Plan
- Description: For serious content creators - unlimited posts to 5 platforms
- Pricing model: Standard pricing
- Price: $15.00
- Billing period: Monthly
- Currency: USD
- Click "Save product"
- Copy the Price ID (starts with
price_) - Repeat for Yearly pricing ($144/year)
- Create another product:
- Name: Professional Plan
- Description: For teams and businesses - unlimited posts to all platforms
- Price: $49.00 monthly
- Price: $470.00 yearly
- Copy both Price IDs
STRIPE_PRICE_CREATOR_MONTHLY=price_xxx
STRIPE_PRICE_CREATOR_YEARLY=price_xxx
STRIPE_PRICE_PROFESSIONAL_MONTHLY=price_xxx
STRIPE_PRICE_PROFESSIONAL_YEARLY=price_xxxWebhooks notify your app when subscriptions change.
-
Install Stripe CLI: stripe.com/docs/stripe-cli
-
Login to Stripe CLI:
stripe login- Forward webhooks to local server:
stripe listen --forward-to localhost:3000/api/stripe/webhook-
Copy the webhook signing secret (starts with
whsec_) -
Add to
.env:
STRIPE_WEBHOOK_SECRET=whsec_your_secret- Keep this terminal running while developing
- Go to Webhooks
- Click "+ Add endpoint"
- Enter endpoint URL:
https://yourdomain.com/api/stripe/webhook - Select events to listen for:
checkout.session.completedcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_failedinvoice.payment_succeeded
- Click "Add endpoint"
- Copy the Signing secret
- Add to production
.env
The customer portal lets users manage their subscriptions.
- Go to Customer Portal Settings
- Click "Activate test link"
- Configure settings:
- ✅ Allow customers to update payment methods
- ✅ Allow customers to view invoice history
- ✅ Allow customers to cancel subscriptions
- ✅ Prorate subscription changes
- Set cancellation options:
- ✅ Cancel at period end (recommended)
- Or: Cancel immediately
- Save changes
Free trials are already configured in the code (14 days).
To adjust trial length, edit:
// server/api/stripe/create-checkout.post.ts
subscription_data: {
trial_period_days: 14, // Change this number
// ...
}Use these test cards in development:
Success:
4242 4242 4242 4242- Visa5555 5555 5555 4444- Mastercard- Any future expiry date
- Any 3-digit CVC
Requires 3D Secure:
4000 0027 6000 3184
Declined:
4000 0000 0000 0002- Generic decline4000 0000 0000 9995- Insufficient funds
- Start your app:
npm run dev - Go to
/pricing - Click "Start Free Trial" on Creator plan
- Use test card:
4242 4242 4242 4242 - Check:
- ✅ Redirects to dashboard
- ✅ Dashboard shows "Free Trial" status
- ✅ Profile updated in database
- ✅ Post limit changed
- Test webhook:
- Cancel subscription in Stripe dashboard
- Verify user downgraded to Starter
Before going live:
- Switch to live API keys
- Create live products/prices
- Set up production webhook
- Update
SITE_URLin.env - Test live payment flow
- Verify webhook events work
- Enable Customer Portal in live mode
- Add business information
- Set up bank account for payouts
- Configure tax collection (if applicable)
- Set up email receipts
- Configure branding (logo, colors)
- Set statement descriptor (what appears on credit card)
- Never commit
.envfile - Use environment variables in production
- Verify webhook signatures
- Use HTTPS for all webhooks
- Set up Stripe webhook IP allowlist (optional)
User clicks "Subscribe"
↓
Create Stripe Checkout Session
↓
User enters payment info
↓
14-day trial starts
↓
checkout.session.completed webhook
↓
Update database (trial status)
↓
User has full access
↓
After 14 days: First payment
↓
invoice.payment_succeeded webhook
↓
Update database (active status)
- When: User completes checkout
- Action: Create subscription record, start trial
- When: Plan change, trial ends, reactivation
- Action: Update subscription status
- When: User cancels or subscription expires
- Action: Downgrade to free plan
- When: Payment declined
- Action: Mark as past_due, email user
- When: Successful payment
- Action: Ensure active status
Problem: Webhook endpoint not getting called
Solutions:
- Check Stripe CLI is running (development)
- Verify webhook URL is correct
- Check webhook secret matches
- Ensure endpoint is publicly accessible (production)
- Review webhook logs in Stripe dashboard
Problem: Test payments don't work
Solutions:
- Use test mode API keys
- Use test credit card numbers
- Check for JavaScript errors in console
- Verify Stripe publishable key is correct
Problem: User subscribed but database not updated
Solutions:
- Check webhook is configured
- Verify webhook secret is correct
- Check server logs for errors
- Ensure RLS policies allow updates
- Verify Supabase service key is used in webhook handler
Problem: "Manage Subscription" button doesn't work
Solutions:
- Activate Customer Portal in Stripe dashboard
- Verify stripe_customer_id exists in database
- Check for JavaScript errors
- Ensure user has a subscription
Monitor your business:
- Revenue: Total MRR, churn rate
- Customers: Active subscribers, trial conversions
- Payments: Success rate, failed payments
- Events: Webhook delivery status
- MRR (Monthly Recurring Revenue)
- Churn Rate (% of cancellations)
- Trial Conversion (% who convert to paid)
- Failed Payments (requires follow-up)
- Average Revenue Per User
- Start with monthly pricing
- Add yearly option with 20% discount
- Offer 14-day trial (no credit card required)
- Use tiered pricing (we already have this)
- Allow easy upgrades/downgrades
- ✅ Position middle tier as "Most Popular"
- ✅ Show annual savings ($180 vs $144)
- ✅ Use social proof ("Join 1000+ creators")
- ✅ Offer trial with no credit card
- ✅ Make starter plan generous enough to hook users
Create discount codes in Stripe:
- Go to Coupons
- Create coupon (%, fixed amount, or trial extension)
- Users enter at checkout
Already enabled in code:
allow_promotion_codes: trueFor pay-as-you-go pricing:
- Metered billing
- Report usage via API
- Charge based on posts sent
Stripe Tax handles sales tax automatically:
- Enable in Stripe settings
- Add one line to checkout session
- Stripe calculates tax per region
- Stripe Support
- Stack Overflow
- Stripe Discord Community
- Standard: 2.9% + $0.30 per successful charge
- No monthly fees (pay-as-you-go)
- No setup fees
- Free failed payments
100 customers at $15/month = $1,500 revenue
Stripe fees: ~$50 (2.9% + $0.30 × 100)
Your net: ~$1,450/month
Annual net (assuming no churn): ~$17,400/year
- ✅ Create Stripe account
- ✅ Set up products & prices
- ✅ Configure webhook
- ✅ Test with test cards
- ✅ Enable Customer Portal
- 🚀 Launch and start earning!
Your payment system is now ready to generate revenue! 💰