Skip to main content

Stripe Test Mode Setup

Stripe handles payments for your SaaS. This guide covers setting up Stripe in test mode for development.

Note: Test mode lets you simulate payments without processing real transactions. Look for the banner at the top of your dashboard to confirm you're in test mode.

  1. Create a Stripe Account

    • Sign up at stripe.com if you haven't already.
    • Ensure you're in test mode by checking the toggle in your Stripe Dashboard.
  2. Get Your API Keys

  3. Create Products and Prices

    • Set up your subscription plans in the Stripe dashboard.
    • Note the Price IDs for each product (they start with price_).
    • Store them in your apps/web/.env.local file:
    NEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENT=price_single_payment
    NEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENT_SECONDARY=price_single_payment_secondary
    NEXT_PUBLIC_STRIPE_PRICE_ID_MONTHLY_SUBSCRIPTION=price_monthly_subscription

    Stripe Price Setup

  4. Set Up Webhook Testing

    • Ensure you have the Stripe CLI installed.
    • Run stripe listen in your root directory to get a webhook secret.
    • The CLI will generate a webhook signing secret starting with whsec_.
    • This secret is specifically for local development testing.
  5. Update Environment Variables Add the following to your apps/web/.env.local file:

    NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_your_public_key
    STRIPE_SECRET_KEY=sk_test_your_secret_key
    STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
    NEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENT=price_single_payment
    NEXT_PUBLIC_STRIPE_PRICE_ID_SINGLE_PAYMENT_SECONDARY=price_single_payment_secondary
    NEXT_PUBLIC_STRIPE_PRICE_ID_MONTHLY_SUBSCRIPTION=price_monthly_subscription

Remember to always use test mode keys when developing and switch to live mode only when you're ready to accept real payments.

Important: Never commit your apps/web/.env.local file to version control.