Skip to Content
Iris Saas Kit documentation is under construction.
How-tosSetting up Payment

Setting up Payment

Configure Stripe integration to enable subscription billing and payment processing for your SaaS application.

💡 Getting started? Complete Installation, Build Product Context, and Landing Page Setup first to have your foundation ready!

🎯 Overview

This section will guide you through setting up a complete payment system using Stripe, including:

  • Stripe account creation and API key configuration
  • Environment variables setup for secure integration
  • Webhook configuration for real-time payment events
  • Product and pricing creation for your subscription plans
  • Testing the payment flow end-to-end

⏱️ Estimated time: 20-30 minutes

🔧 Stripe Account Setup

1. Create Stripe Account

If you don’t have a Stripe account yet:

  1. Visit Stripe.com and create an account
  2. Complete business verification (can be done later for testing)
  3. Access your Dashboard at dashboard.stripe.com

2. Get API Keys

Locate your API keys:

  1. Go to Developers → API keys in your Stripe dashboard
  2. Copy your Publishable key and Secret key
  3. Use test keys for development (they start with pk_test_ and sk_test_)
# Test keys look like this: pk_test_51234567890abcdef... # Publishable key sk_test_51234567890abcdef... # Secret key

⚠️ Important: Never expose secret keys in frontend code or public repositories.

🔐 Environment Configuration

1. Set Convex Environment Variables

Configure your Stripe keys in the Convex backend:

# Set Stripe secret key (backend only) npx convex env set STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key # You'll set the webhook secret after creating webhooks (next step)

2. Frontend Configuration (Optional)

For advanced Stripe integrations, you might need the publishable key in frontend:

# Add to .env.local if needed for custom Stripe components NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key

⚠️ Note: The boilerplate handles most Stripe operations through the backend, so frontend keys are typically not needed.

🔗 Webhook Setup

Webhooks are crucial for real-time payment processing and subscription management.

1. Create Webhook Endpoint

In your Stripe dashboard:

  1. Go to Developers → Webhooks
  2. Click “Add endpoint”
  3. Endpoint URL: https://your-convex-deployment.convex.cloud/stripe/webhook
  4. Select events to listen to:
    • checkout.session.completed
    • customer.subscription.created
    • customer.subscription.updated
    • customer.subscription.deleted
    • invoice.payment_succeeded
    • invoice.payment_failed

2. Get Webhook Secret

After creating the webhook:

  1. Click on your webhook in the Stripe dashboard
  2. Copy the “Signing secret” (starts with whsec_)
  3. Set it in Convex:
npx convex env set STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret

3. Webhook URL Format

Your webhook URL should be:

https://your-deployment-name.convex.cloud/stripe/webhook

Find your deployment URL:

  • Run npx convex dashboard and copy the URL
  • Or check your NEXT_PUBLIC_CONVEX_URL in .env.local

💰 Products and Pricing Setup

The boilerplate includes a built-in Stripe management interface:

  1. Access admin interface:

    • Go to http://localhost:3000/dev-app in development
    • Navigate to “Stripe Price Manager”
  2. Create products:

    • Click “Create Product”
    • Add product name, description, and features
    • Set monthly and yearly pricing
    • Configure feature metadata
  3. Activate pricing:

    • Only one price per interval can be active
    • Mark your recommended plan as “Popular”
    • Test different pricing configurations

2. Manual Stripe Dashboard Setup

Alternatively, create products directly in Stripe:

  1. Go to Products in your Stripe dashboard
  2. Create a new product:
    • Name: “Starter Plan”
    • Description: “Perfect for small teams”
  3. Add pricing:
    • Monthly: $29/month
    • Yearly: $290/year (save 17%)
  4. Repeat for other plans (Professional, Enterprise, etc.)

3. Example Product Structure

Starter Plan - $29/month - Up to 5 workspaces - Basic features - Email support Professional Plan - $99/month - Up to 25 workspaces - Advanced features - Priority support Enterprise Plan - $299/month - Unlimited workspaces - All features - Dedicated support

🧪 Testing Payment Flow

1. Test User Journey

Complete flow test:

  1. Sign up for a new account
  2. Create a workspace (should prompt for subscription)
  3. Select a plan and proceed to checkout
  4. Use test card: 4242 4242 4242 4242
    • Any future expiry date
    • Any 3-digit CVC
  5. Complete payment and verify subscription activation

2. Test Cards

Stripe provides test cards for different scenarios:

# Successful payment 4242 4242 4242 4242 # Declined payment 4000 0000 0000 0002 # Requires 3D Secure authentication 4000 0027 6000 3184 # Expired card 4000 0000 0000 0069

3. Verify Integration

Check these work correctly:

  • Checkout flow completes successfully
  • User subscription shows as active
  • Webhook events are received (check Convex logs)
  • Billing portal is accessible from workspace settings
  • Plan features are properly enabled/disabled

🔍 Troubleshooting

Common Issues

“Stripe keys not configured” error:

# Verify your environment variables are set npx convex env list | grep STRIPE

Webhook events not received:

# Check webhook URL format https://your-deployment.convex.cloud/stripe/webhook # Verify webhook secret is correct npx convex env get STRIPE_WEBHOOK_SECRET

Checkout session creation fails:

# Ensure you have active prices in Stripe # Check Convex logs for detailed error messages npx convex logs

Testing Webhook Delivery

In Stripe dashboard:

  1. Go to Developers → Webhooks
  2. Click on your webhook endpoint
  3. Check “Recent deliveries” for success/failure status
  4. Use “Send test webhook” to verify connectivity

Environment Verification

Check your setup:

# Verify all required environment variables npx convex env list # Should show: # STRIPE_SECRET_KEY=sk_test_... # STRIPE_WEBHOOK_SECRET=whsec_...

🚀 Production Setup

1. Switch to Live Mode

When ready for production:

  1. Get live API keys from Stripe dashboard
  2. Update environment variables:
# Production Stripe keys npx convex env set --prod STRIPE_SECRET_KEY=sk_live_your_live_secret_key npx convex env set --prod STRIPE_WEBHOOK_SECRET=whsec_your_live_webhook_secret
  1. Create new webhook with production URL
  2. Update products and pricing for live customers

2. Business Verification

For live payments, Stripe requires:

  • Business information verification
  • Bank account connection
  • Tax information (if applicable)
  • Identity verification for account owner

3. Production Checklist

  • Live API keys configured in production environment
  • Production webhook created with live URL
  • Business verification completed in Stripe
  • Bank account connected for payouts
  • Products and pricing finalized for launch
  • Tax settings configured (if applicable)
  • Payment flow tested end-to-end in production

📊 Monitoring and Analytics

Built-in Analytics

The admin interface provides:

  • Revenue tracking and subscription metrics
  • Plan performance analysis
  • Customer lifecycle insights
  • Failed payment monitoring

Stripe Dashboard

Monitor in Stripe:

  • Revenue reports and growth trends
  • Customer behavior and retention
  • Payment failures and recovery
  • Subscription metrics and churn analysis

🔐 Security Best Practices

API Key Management

  • Never expose secret keys in frontend code
  • Use test keys for development and staging
  • Rotate keys periodically for security
  • Monitor key usage in Stripe dashboard

Webhook Security

  • Verify webhook signatures (handled automatically)
  • Use HTTPS for all webhook endpoints
  • Monitor webhook deliveries for failures
  • Handle duplicate events gracefully

Next Steps

After completing payment setup:

  1. Customizing the App - Adapt the boilerplate to your specific needs
  2. Test your complete user journey from signup to paid subscription
  3. Review Stripe Price Manager documentation for advanced features

💡 Note: You’ve already completed Build Product Context and Landing Page Setup, so you have a clear plan and can start building your audience!

Your SaaS now has a complete payment system ready for subscription billing! 🎉


Next: Continue with Customizing the App →

Last updated on