Environment Variables Setup
Last updated
Last updated
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.
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
.
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
.
Create a Product:
In the Products section, click on Add product.
Enter the product details and save it.
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
.
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
.
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
.
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
.
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
.
MongoDB URL:
Obtain your MongoDB connection string (e.g., from MongoDB Atlas).
Add it to your .env
file as MONGO_URL
.
JWT Secret:
Generate a strong secret key for signing JWT tokens.
Add it to your .env
file as JWT_SECRET
.
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
Log in to your Mailgun account and navigate to the Dashboard.
Go to Sending > Domains to manage your domains.
Obtain Your Mailgun API Key
In the left sidebar, go to Settings and select API keys.
Copy the Private API Key and add it to your .env
file:
Configure Your Mailgun Domain
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.
Once verified, copy the domain and add it to your .env
file:
Your Mailgun configuration is now complete!
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
.
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
.
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).