Payment
Set up Stripe for handling payments and subscriptions
Payment
LaunchSaaS uses Stripe for payment management, handling both one-time payments and recurring subscriptions.
Setup
1. Create Stripe Account
- Sign up at stripe.com
- Complete account verification (required for production)
- You can start development with test mode immediately
2. Get API Keys
- Go to Stripe Dashboard →
Developers→API keys - Copy your Secret key (starts with
sk_test_for test mode) - Add to your
.envfile:
STRIPE_SECRET_KEY="sk_test_..."Use test keys (sk_test_...) for development and live keys (sk_live_...)
for production.
3. Create Products and Prices
- Go to Stripe Dashboard →
Product Catalog - Click
Add product - Fill in product details:
- Name: e.g., "Lifetime Access"
- Description: Your product description
- Price: Set your price (one-time or recurring)
- Click "Save product"
- Copy the Price ID (starts with
price_)
4. Configure Products
Update the product configuration in src/config/product.ts:
- For subscriptions: Configure plans with
priceIdfrom Stripe - For one-time payments: Configure products with
priceIdfrom Stripe - Customize
onPaymentCompletehooks for post-payment actions
5. Set Up Webhooks
Webhooks notify your application of payment events in real-time.
Development (Local Testing)
Use the Stripe CLI to forward webhooks to your local server:
- Install Stripe CLI:
# macOS
brew install stripe/stripe-cli/stripe
# Other platforms: https://stripe.com/docs/stripe-cli- Login to Stripe:
stripe login- Forward webhooks:
stripe listen --forward-to localhost:3000/api/auth/stripe/webhook- Copy the webhook secret (starts with
whsec_) and add to your.envfile:
STRIPE_WEBHOOK_SECRET="whsec_..."Keep the stripe listen command running while developing.
Production
- Go to Stripe Dashboard →
Developers→Webhooks - Click
Add endpoint - Set endpoint URL:
https://yourdomain.com/api/auth/stripe/webhook - Select events to listen to:
checkout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedinvoice.payment_succeededinvoice.payment_failed
- Click
Add endpoint - Copy the Signing secret and add to your production environment
If you are setting up the environment, now you can go back to the Environment Setup guide and continue.
Payment Completion Hooks
LaunchSaaS allows you to run custom code when a payment completes. Configure in src/config/product.ts:
One-Time Payments
oneOff: [
{
name: "Lifetime",
priceId: "price_...",
onPaymentComplete: async ({ stripeSession, payment, product }) => {
// Custom logic after payment
// e.g., grant access, send welcome email, add to repository
},
},
];Subscriptions
recurring: {
plans: [...],
onSubscriptionComplete: async ({ subscription, plan }) => {
// Custom logic after subscription created
},
onSubscriptionCancel: async ({ subscription }) => {
// Custom logic after subscription cancelled
},
}GitHub Integration (Optional)
LaunchSaaS can automatically add customers as GitHub collaborators after payment:
- Enable in
.env:
GITHUB_INTEGRATION_ENABLED=true
GITHUB_TOKEN="your-personal-access-token"
GITHUB_REPO="owner/repo"- Generate a GitHub Personal Access Token with
admin:organdreposcopes at GitHub Settings
Testing Cards
For testing Stripe integration, use test credit cards:
| Card Number | Description |
|---|---|
4242 4242 4242 4242 | Successful payment |
4000 0000 0000 3220 | 3D Secure required |
4000 0000 0000 9995 | Insufficient funds |
Use any future expiration date and any 3-digit CVC.