🚀
eziSaas
Github Repository
  • Welcome
  • 📕GUIDES
    • Getting Started
    • Environment Variables Setup
  • 🖥️SERVER
    • Overview
    • /config/mail.js
    • /controllers/authController.js
    • /routes/payment.js
    • /routes/webhook.js
  • 📦Components & PAGES
    • Landing
      • Navbar
      • CheckoutButton
      • Hero
      • SellingPoints
        • SellingPoint
        • Filter
      • Title
        • OfferPill
      • Video
      • Pricing
        • PricingCard
      • Faq
        • Accordion
      • FinalMessage
      • Footer
        • FooterSection
    • Login
    • Success
    • Failure
    • Dashboard
      • ChangePassword
  • OTHER
    • Github Repository
Powered by GitBook
On this page
  • Step 1: Create Your Stripe Account
  • Step 2: Access the Stripe Dashboard
  • Step 3: Obtain Your Stripe API Keys
  • Step 4: Create a Product and Price
  • Step 5: Create a Coupon (Optional)
  • Step 6: Set Up Webhooks
  • Step 7: Configure MongoDB and JWT
  • Step 8: Configure Mailgun for Email functionality
  1. GUIDES

Environment Variables Setup

PreviousGetting StartedNextOverview

Last updated 5 months ago

To ensure your eziSaas application runs smoothly, you'll need to set up several environment variables in your .env file. This guide will walk you through obtaining the necessary values from Stripe and configuring your .env file.

Step 1: Create Your Stripe Account

Step 2: Access the Stripe Dashboard

Step 3: Obtain Your Stripe API Keys

  1. Secret Key (Live Mode):

    • Go to the Developers section on the left sidebar.

    • Click on API keys.

    • Copy the Secret key and add it to your .env file as STRIPE_SECRET.

  2. Secret Key (Test Mode):

    • Toggle the View test data switch at the top of the page.

    • Copy the Secret key and add it to your .env file as TEST_STRIPE_SECRET.

Step 4: Create a Product and Price

  1. Create a Product:

    • In the Products section, click on Add product.

    • Enter the product details and save it.

  2. Create a Price:

    • After creating the product, go to the Pricing section of the product page.

    • Click on Add price.

    • Set the pricing details and save it.

    • Copy the Price ID and add it to your .env file as PRODUCT_PRICE_ID.

  3. Create a Test Price:

    • Toggle the View test data switch at the top of the page.

    • Repeat the steps to create a test price.

    • Copy the Price ID and add it to your .env file as TEST_PRODUCT_PRICE_ID.

Step 5: Create a Coupon (Optional)

  1. Create a Coupon:

    • In the Coupons section under Billing, click on Add coupon.

    • Set the coupon details and save it.

    • Copy the Coupon ID and add it to your .env file as COUPON_ID.

  2. Create a Test Coupon:

    • Toggle the View test data switch at the top of the page.

    • Repeat the steps to create a test coupon.

    • Copy the Coupon ID and add it to your .env file as TEST_COUPON_ID.

Step 6: Set Up Webhooks

  1. Create a Webhook Endpoint:

    • In the Developers section, go to Webhooks.

    • Click on Add endpoint.

    • Set the endpoint URL (e.g., https://yourdomain.com/webhook-onetime-payment) and select the events you want to listen to (e.g., checkout.session.completed).

    • Save the webhook endpoint.

    • Copy the Webhook signing secret from the webhook endpoint details and add it to your .env file as STRIPE_WEBHOOK_SECRET.

Step 7: Configure MongoDB and JWT

  1. MongoDB URL:

    • Obtain your MongoDB connection string (e.g., from MongoDB Atlas).

    • Add it to your .env file as MONGO_URL.

  2. JWT Secret:

    • Generate a strong secret key for signing JWT tokens.

    • Add it to your .env file as JWT_SECRET.

Step 8: Configure Mailgun for Email functionality

To enable email functionality in your eziSaas application, you need to configure Mailgun. Follow the steps below to set up Mailgun and obtain the necessary API key and domain values.

Create Your Mailgun Account

Access the Mailgun Dashboard

  1. Log in to your Mailgun account and navigate to the Dashboard.

  2. Go to Sending > Domains to manage your domains.

Obtain Your Mailgun API Key

  1. In the left sidebar, go to Settings and select API keys.

  2. Copy the Private API Key and add it to your .env file:

MAILGUN_API_KEY=your-mailgun-private-api-key

Configure Your Mailgun Domain

  1. In the Domains section, select or add a new domain. Mailgun will provide DNS records you need to add to your domain provider for verification.

  2. Once verified, copy the domain and add it to your .env file:

MAILGUN_DOMAIN=your-mailgun-domain

Your Mailgun configuration is now complete!


Client side .env variables:

  1. VITE_STRIPE_PUBLISHABLE_KEY

    • Purpose: This is your live Stripe publishable key, required for the production environment. This key is used on the frontend to initiate and manage payments.

    • How to Get It:

      • Navigate to Developers > API keys.

      • Copy your Publishable key and paste it as the value of VITE_STRIPE_PUBLISHABLE_KEY.

  2. VITE_TEST_STRIPE_PUBLISHABLE_KEY

    • Purpose: This is your Stripe test publishable key, used in development to enable testing without processing real payments.

    • How to Get It:

      • Go to Developers > API keys.

      • Copy your Test publishable key and set it as the value of VITE_TEST_STRIPE_PUBLISHABLE_KEY.

  3. VITE_REACT_APP_BACKEND_BASEURL

    • Purpose: Defines the base URL for the backend server, allowing the frontend to make API requests.

    • Value for Local Development: http://localhost:3000

    • Setting It for Production: Replace with your production backend URL when deploying the application.


That’s it! Your environment variables are now set up, and you’re ready to run your eziSaas application. Happy coding!


If you don’t already have a Stripe account, sign up for one at .

Log in to your Stripe account and navigate to the .

If you don’t have a Mailgun account, sign up at .

Log in to your .

Log in to your and ensure the test mode is enabled (toggle in the upper right).

📕
stripe.com
Stripe Dashboard
mailgun.com
Stripe Dashboard
Stripe Dashboard
server .env file
client .env file