Complete checkout system with Razorpay payment gateway integration and Cash on Delivery option.
- ✅ Checkout page with shipping information form
- ✅ Payment method selection (Razorpay Online Payment / Cash on Delivery)
- ✅ Order summary with cart items
- ✅ Subtotal, shipping cost calculation (free above ₹50,000)
- ✅ Form validation (email, phone, pincode)
- ✅ Razorpay SDK integration
- ✅ Payment verification flow
- ✅ Responsive design matching website theme (gold #D4AF37, charcoal)
- ✅ Razorpay order creation endpoint
- ✅ Payment verification endpoint
- ✅ Order creation with customer details
- ✅ Support for both online and COD payments
- ✅ Signature verification for secure payments
Server dependencies are already installed. If needed:
cd SEE_MEE-master/server
npm install razorpay- Sign up at Razorpay Dashboard
- Go to Settings → API Keys
- Generate Test/Live API Keys
- Copy Key ID and Key Secret
Server (.env):
# SEE_MEE-master/server/.env
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxxx
RAZORPAY_KEY_SECRET=your_secret_key_hereFrontend (.env):
# SEE_MEE-master/.env
VITE_API_URL=http://localhost:5000
VITE_RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxxxTerminal 1 - Start Backend:
cd SEE_MEE-master/server
npm startTerminal 2 - Start Frontend:
cd SEE_MEE-master
npm run devSEE_MEE-master/
├── src/
│ ├── pages/
│ │ ├── Checkout.jsx # Checkout page component
│ │ └── Checkout.css # Checkout page styles
│ ├── components/
│ │ └── Cart.jsx # Updated with checkout button
│ ├── config/
│ │ └── api.js # API endpoints configuration
│ └── App.jsx # Updated with checkout route
├── server/
│ ├── routes/
│ │ └── orders.js # Updated with Razorpay endpoints
│ └── .env # Server environment variables
└── .env # Frontend environment variables
POST /api/orders/create-razorpay-order
Body: { amount: number }
Response: { success: true, data: razorpayOrder }
POST /api/orders/verify-payment
Body: {
razorpay_order_id: string (for online payment),
razorpay_payment_id: string (for online payment),
razorpay_signature: string (for online payment),
customer: {
name: string,
email: string,
phone: string,
address: {
street: string,
city: string,
state: string,
pincode: string,
country: string
}
},
items: [{
productId: string,
name: string,
price: number,
quantity: number,
image: string
}],
totalAmount: number,
paymentMethod: 'online' | 'cod'
}
Response: { success: true, data: order }
- Add to Cart: User adds products to cart
- View Cart: User opens cart sidebar
- Proceed to Checkout: User clicks "Proceed to Checkout" button
- Fill Shipping Info: User enters name, email, phone, address
- Select Payment Method:
- Online Payment (Razorpay)
- Cash on Delivery
- Place Order:
- Online: Razorpay modal opens → User completes payment → Order created
- COD: Order created immediately
- Confirmation: Cart cleared, user redirected to orders page
- Email: Valid email format (user@example.com)
- Phone: 10-digit number
- Pincode: 6-digit code
- All fields: Required
- Free Shipping: Orders ≥ ₹50,000
- Standard Shipping: ₹500 for orders < ₹50,000
- ✅ Razorpay signature verification
- ✅ Server-side payment validation
- ✅ HTTPS required for production
- ✅ Environment variables for sensitive data
- ✅ CORS configuration
Use test credentials from Razorpay dashboard:
- Test cards: Razorpay Test Cards
- Example: 4111 1111 1111 1111 (any CVV, future expiry)
- Add items to cart
- Go to checkout
- Fill shipping information
- Select "Cash on Delivery"
- Click "Place Order"
- Order should be created with status "pending"
-
Switch to Live Keys:
- Replace
rzp_test_withrzp_live_keys - Update both server and frontend .env files
- Replace
-
Update API URL:
VITE_API_URL=https://your-production-domain.com
-
Enable HTTPS:
- Razorpay requires HTTPS in production
- Configure SSL certificate
-
Environment Variables:
- Set all environment variables in hosting platform
- Never commit .env files to git
-
Test Thoroughly:
- Test complete checkout flow
- Verify payment webhooks
- Test order creation
- Check internet connection
- Verify script URL:
https://checkout.razorpay.com/v1/checkout.js - Check browser console for errors
- Verify Razorpay Key Secret in server .env
- Check signature generation logic
- Ensure order_id matches
- Check MongoDB connection
- Verify Product model exists
- Check server logs for errors
- Verify CORS is enabled in server.js
- Check API_BASE_URL in frontend config
- Ensure correct origin in CORS settings
For Razorpay integration issues:
- Order confirmation page
- Email notifications
- Order tracking
- Payment webhooks for async updates
- Multiple shipping addresses
- Discount codes/coupons
- Invoice generation
- Order history page