Skip to content

Latest commit

 

History

History
173 lines (128 loc) · 5.15 KB

File metadata and controls

173 lines (128 loc) · 5.15 KB

Stripe Payment Setup Guide

Overview

This guide will help you set up Stripe test payments for vendor bazaar and booth participation fees.

Step 1: Get Your Stripe Test API Keys

  1. 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)
  2. 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!
  3. Copy Your Secret Key

    • Click "Reveal test key" next to the Secret key
    • Copy the entire key (it will look like: sk_test_51SWWoMQ5n8P6RrQg0zD...)

Step 2: Add Stripe Key to Environment Variables

Option A: If .env file is in the server folder

  1. Navigate to the server folder
  2. Open or create a .env file
  3. Add this line:
    STRIPE_SECRET_KEY=sk_test_your_actual_secret_key_here
    Important: Replace sk_test_your_actual_secret_key_here with your actual secret key from Step 1.

Option B: If .env file is in the project root

  1. Navigate to the project root folder
  2. Open or create a .env file
  3. Add this line:
    STRIPE_SECRET_KEY=sk_test_your_actual_secret_key_here

Complete .env Example

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-password

Step 3: Restart Your Server

After adding the Stripe key, restart your server:

# Stop the current server (Ctrl+C)
# Then restart:
npm run dev:server
# or
node server.js

Step 4: Test the Payment

  1. Use Test Card Number: 4242 4242 4242 4242
  2. Use Any Future Date: e.g., 12/34
  3. Use Any CVC: e.g., 123
  4. Use Any ZIP Code: e.g., 12345

Test Card Details

  • 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)

Other Test Cards (if needed)

  • Visa: 4242 4242 4242 4242
  • Visa (debit): 4000 0566 5566 5556
  • Mastercard: 5555 5555 5555 4444
  • American Express: 3782 822463 10005

Troubleshooting

Error: "Stripe authentication failed"

Possible Causes:

  1. ❌ Stripe key not added to .env file
  2. ❌ Using wrong key (using publishable key instead of secret key)
  3. ❌ Key has extra spaces or quotes
  4. ❌ Server not restarted after adding key
  5. ❌ Using live key (sk_live_...) instead of test key (sk_test_...)

Solutions:

  1. ✅ Check that STRIPE_SECRET_KEY is in your .env file
  2. ✅ Make sure you're using the Secret key (starts with sk_test_), NOT the publishable key
  3. ✅ 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_...
  4. ✅ Restart your server after adding the key
  5. ✅ Verify you're using a test key (starts with sk_test_)

Error: "Payment system not configured"

This means the Stripe key is missing or invalid. Check:

  • Is STRIPE_SECRET_KEY in your .env file?
  • Does it start with sk_test_?
  • Did you restart the server?

Error: "Currency not supported"

If EGP (Egyptian Pound) is not supported, the system will automatically fallback to USD. This is normal for test mode.

Check Server Logs

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

Security Notes

⚠️ IMPORTANT:

  • Never commit your .env file 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

Going Live

When you're ready to accept real payments:

  1. Switch to Live mode in Stripe Dashboard
  2. Get your live secret key (starts with sk_live_...)
  3. Update STRIPE_SECRET_KEY in your production .env file
  4. Update your frontend to use the live publishable key

Need Help?

Quick Checklist

  • Created Stripe account
  • Got test secret key from dashboard
  • Added STRIPE_SECRET_KEY=sk_test_... to .env file
  • Verified key starts with sk_test_ (not pk_test_)
  • Removed quotes/spaces around the key
  • Restarted server
  • Tested with card 4242 4242 4242 4242
  • Payment works! ✅