Initial Setup
Payments
Stripe
Subscriptions

Subscriptions

For payment processing, we use Stripe (opens in a new tab). You can create a free account and use their test mode to test the subscription process.

First update the environment variables in .env.local with your Stripe keys (opens in a new tab).

STRIPE_API_KEY=sk_test_123
STRIPE_WEBHOOK_SECRET=whsec_123
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_123

Now create 3 products in your Stripe dashboard (opens in a new tab) and copy the product IDs into the .env.local file.

NEXT_PUBLIC_STRIPE_PRO_PRICE_ID=prod_123
NEXT_PUBLIC_STRIPE_QUATER_PRICE_ID=prod_123
NEXT_PUBLIC_STRIPE_YEAR_PRICE_ID=prod_123

Now run the server in one terminal window:

npm run dev

And run the Stripe webhook listener in another terminal window:

npm run stripe:listen

Now you can create a new user and subscribe to a plan. You can use the following test card numbers:

  • 4242 4242 4242 4242 (Visa)
  • 5555 5555 5555 4444 (Mastercard)
  • 3782 822463 10005 (American Express)