Documentation
PaymentsProviders

Stripe

Practical Stripe setup for subscriptions, credits, and one-time payments.

1. Stripe setup

Create a Stripe account

Create your account at Stripe.

Get your API keys

Retrieve your API keys from the Stripe dashboard.

Add environment variables

Add the following environment variables to your project:

STRIPE_SECRET_KEY=sk_live_or_test_key
STRIPE_WEBHOOK_SECRET=whsec_from_stripe_webhook

Note: STRIPE_WEBHOOK_SECRET is needed for both production and local testing.

2. Create products with prices

Go to Stripe products

Navigate to the products section in your Stripe dashboard.

Create product

Click the button to create a new product.

Create product prices

Add the necessary price tiers for your new product.

Choose type

Select recurring with a billing period (month, year) or one-off for a one-time purchase.

Use cases

3. Stripe local testing

Install Stripe CLI

Install the CLI and login.

brew install stripe/stripe-cli/stripe
stripe login

Forward events

Listen and forward webhook events to your local server.

stripe listen --forward-to localhost:3000/api/payments/webhook/stripe

Update local .env file

Copy the webhook secret provided by the output of stripe listen and add it to your environment.

STRIPE_WEBHOOK_SECRET=whsec_...

Trigger events

Trigger test events manually.

stripe trigger payment_intent.succeeded

Or finish the checkout flow manually. You can use Stripe test credit cards to complete the checkout.

4. Production

Go to Stripe Webhooks Dashboard

Navigate to the Webhooks page on your Stripe dashboard.

Add endpoint

Register your production URL for webhooks.

https://your-domain.com/api/payments/webhook/stripe

Select events to listen for

Choose the required events to track:

  • checkout.session.completed
  • invoice.payment_succeeded
  • customer.subscription.created
  • customer.subscription.updated
  • customer.subscription.deleted

Copy to environment variables

Copy the production webhook secret and add it to your live .env variables.

STRIPE_WEBHOOK_SECRET=whsec_...

On this page