Projects › Intermediate
E-commerce Store with Cart & Payments
Products, filters, cart, checkout with Razorpay test payments, orders and an admin panel.
Level: Intermediate · Time: 2–3 weeks · Tech stack: React, Node.js, MongoDB, Razorpay (test mode)
Features to build
- Product list with search, category filters and sorting
- Cart that survives refresh
- Checkout with address and Razorpay test payment
- Order history and status
- Admin: add products, manage stock and orders
What you will learn
- Complex state (cart)
- Payment gateway flow and webhooks
- Transactions / stock updates
- Role-based access
Step-by-step guide
1. Models
Product (name, price, stock, images, category), Order (user, items[{product, qty, price}], total, status, payment), User (role).
2. Never trust the client's price
When creating an order, look up prices on the server; the browser only sends product ids and quantities.
3. Payment flow (Razorpay test mode)
- Server creates a Razorpay order for the total → returns
order_id. - Browser opens Razorpay Checkout with that id.
- On success, server verifies the signature:
const expected = crypto.createHmac('sha256', KEY_SECRET).update(`${orderId}|${paymentId}`).digest('hex');
if (expected !== signature) return res.status(400).json({ message: 'Payment verification failed' });
- Mark the order paid and reduce stock.
4. Stock without overselling
Product.updateOne({ _id, stock: { $gte: qty } }, { $inc: { stock: -qty } }) — if nothing updated, it's out of stock.
5. Cart
Keep it in React context + localStorage for guests; merge into the server cart on login.
6. Admin
Protect admin routes with role === 'admin'; tables for products and orders with status updates.
Level it up
- Coupons and wishlists
- Email invoices (PDF)
- Product recommendations
On your resume
- Developed a full-stack e-commerce store with cart, Razorpay payment verification, stock-safe order placement and an admin dashboard (React, Node, MongoDB).