This guide will help you set up Stripe test payments for vendor bazaar and booth participation fees.
-
Create a Stripe Account (if you don't have one)
- Go to https://stripe.com
- Sign up for a free account (no credit card required for test mode)
-
Get Your Test Secret Key
- Go to Stripe Dashboard - Test API Keys
- You'll see two keys:
- Publishable key (starts with
pk_test_...) - Used in frontend - Secret key (starts with
sk_test_...) - Used in backend⚠️ Keep this secret!
- Publishable key (starts with
-
Copy Your Secret Key
- Click "Reveal test key" next to the Secret key
- Copy the entire key (it will look like:
sk_test_51SWWoMQ5n8P6RrQg0zD...)
- Navigate to the
serverfolder - Open or create a
.envfile - Add this line:
Important: Replace
STRIPE_SECRET_KEY=sk_test_your_actual_secret_key_here
sk_test_your_actual_secret_key_herewith your actual secret key from Step 1.
- Navigate to the project root folder
- Open or create a
.envfile - Add this line:
STRIPE_SECRET_KEY=sk_test_your_actual_secret_key_here
Your .env file should look something like this:
# Server Configuration
PORT=5001
NODE_ENV=development
# Database
MONGODB_URI=mongodb+srv://your-connection-string
# JWT
JWT_SECRET=yourSuperSecretKey
# Stripe Payment (TEST MODE)
STRIPE_SECRET_KEY=sk_test_51SWWoMQ5n8P6RrQg0zD0zD0zD0zD0zD0zD0zD0zD0zD0zD0zD
# Email Configuration (Optional)
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-passwordAfter adding the Stripe key, restart your server:
# Stop the current server (Ctrl+C)
# Then restart:
npm run dev:server
# or
node server.js- Use Test Card Number:
4242 4242 4242 4242 - Use Any Future Date: e.g.,
12/34 - Use Any CVC: e.g.,
123 - Use Any ZIP Code: e.g.,
12345
- Card Number:
4242 4242 4242 4242(Visa) - Expiry Date: Any future date (e.g.,
12/34) - CVC: Any 3 digits (e.g.,
123) - ZIP Code: Any 5 digits (e.g.,
12345)
- Visa:
4242 4242 4242 4242 - Visa (debit):
4000 0566 5566 5556 - Mastercard:
5555 5555 5555 4444 - American Express:
3782 822463 10005
Possible Causes:
- ❌ Stripe key not added to
.envfile - ❌ Using wrong key (using publishable key instead of secret key)
- ❌ Key has extra spaces or quotes
- ❌ Server not restarted after adding key
- ❌ Using live key (
sk_live_...) instead of test key (sk_test_...)
Solutions:
- ✅ Check that
STRIPE_SECRET_KEYis in your.envfile - ✅ Make sure you're using the Secret key (starts with
sk_test_), NOT the publishable key - ✅ Remove any quotes or spaces around the key:
# ❌ WRONG: STRIPE_SECRET_KEY="sk_test_..." STRIPE_SECRET_KEY = sk_test_... # ✅ CORRECT: STRIPE_SECRET_KEY=sk_test_...
- ✅ Restart your server after adding the key
- ✅ Verify you're using a test key (starts with
sk_test_)
This means the Stripe key is missing or invalid. Check:
- Is
STRIPE_SECRET_KEYin your.envfile? - Does it start with
sk_test_? - Did you restart the server?
If EGP (Egyptian Pound) is not supported, the system will automatically fallback to USD. This is normal for test mode.
When you start your server, you should see:
- ✅ If configured correctly: No warnings about Stripe
- ❌ If missing:
⚠️ WARNING: STRIPE_SECRET_KEY is not set or using placeholder
- Never commit your
.envfile to Git (it should be in.gitignore) - Never share your secret key publicly
- Use test keys (
sk_test_...) for development - Use live keys (
sk_live_...) only in production
When you're ready to accept real payments:
- Switch to Live mode in Stripe Dashboard
- Get your live secret key (starts with
sk_live_...) - Update
STRIPE_SECRET_KEYin your production.envfile - Update your frontend to use the live publishable key
- Stripe Documentation: https://stripe.com/docs
- Test Cards: https://stripe.com/docs/testing
- API Keys: https://dashboard.stripe.com/test/apikeys
- Created Stripe account
- Got test secret key from dashboard
- Added
STRIPE_SECRET_KEY=sk_test_...to.envfile - Verified key starts with
sk_test_(notpk_test_) - Removed quotes/spaces around the key
- Restarted server
- Tested with card
4242 4242 4242 4242 - Payment works! ✅