Create a .env file in your project root with:
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key_here
VITE_BASE_URL=http://localhost:8000In your backend, you'll need these environment variables:
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_hereUse these test card numbers for testing:
- Success: 4242 4242 4242 4242
- Decline: 4000 0000 0000 0002
- Insufficient Funds: 4000 0000 0000 9995
Your backend needs these endpoints:
POST /api/payments/create-payment-intent- Creates a Stripe PaymentIntentPOST /api/orders- Creates an order (already exists)GET /api/payments/session-status- Gets payment session status (optional)
- User fills shipping address → Order created
- User redirected to payment page → PaymentIntent created
- User enters card details → Payment processed
- On success → Redirected to complete page with order details
- Cart cleared and localStorage cleaned up