๐Ÿ”‘ Getting API Keys

1

Create Stripe Account

Go to stripe.com and create an account.

2

Access API Keys

Go to Developers โ†’ API keys. Copy both the publishable and secret keys.

3

Add to Environment

Add keys to your .env.local file.

.env.local
STRIPE_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXX
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXXXXXXXX
STRIPE_WEBHOOK_SECRET=whsec_XXXXXXXXXXXXXXXXXXXXXXXX

๐Ÿ”— Webhook Setup

โš ๏ธ
Required for Payments

Webhooks are required for BetterLearn to process payments and add credits to user accounts.

1

Go to Webhooks

Stripe Dashboard โ†’ Developers โ†’ Webhooks โ†’ Add endpoint

2

Enter Endpoint URL

https://yourdomain.com/api/stripe-webhook

3

Select Events

Select checkout.session.completed and payment_intent.succeeded

4

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 NumberResult
4242 4242 4242 4242Successful payment
4000 0000 0000 0002Card declined
4000 0000 0000 9995Insufficient funds

Use any future expiry date and any 3-digit CVC.

๐Ÿš€ Going Live

  1. Complete Stripe account verification
  2. Switch from test to live API keys
  3. Create a new webhook with your production URL
  4. Update environment variables on your hosting platform
โœ…
Ready!

Stripe is configured. Create pricing plans in Admin Panel โ†’ Pricing.