Stripe Configuration
Set up Stripe for payment processing in BetterLearn. Enable credit purchases and manage subscriptions.
๐ Getting API Keys
Create Stripe Account
Go to stripe.com and create an account.
Access API Keys
Go to Developers โ API keys. Copy both the publishable and secret keys.
Add to Environment
Add keys to your .env.local file.
STRIPE_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXX
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXXXXXXXX
STRIPE_WEBHOOK_SECRET=whsec_XXXXXXXXXXXXXXXXXXXXXXXX
๐ Webhook Setup
Webhooks are required for BetterLearn to process payments and add credits to user accounts.
Go to Webhooks
Stripe Dashboard โ Developers โ Webhooks โ Add endpoint
Enter Endpoint URL
https://yourdomain.com/api/stripe-webhook
Select Events
Select checkout.session.completed and payment_intent.succeeded
Copy Signing Secret
Copy the webhook signing secret (starts with whsec_) and add to your environment.
๐งช Testing Payments
Use Stripe test cards to verify your setup:
| Card Number | Result |
|---|---|
4242 4242 4242 4242 | Successful payment |
4000 0000 0000 0002 | Card declined |
4000 0000 0000 9995 | Insufficient funds |
Use any future expiry date and any 3-digit CVC.
๐ Going Live
- Complete Stripe account verification
- Switch from test to live API keys
- Create a new webhook with your production URL
- Update environment variables on your hosting platform
Stripe is configured. Create pricing plans in Admin Panel โ Pricing.