This monorepo contains the complete, full-stack application logic necessary for the Payment Wallet system within the broader Bicycle Stand Locker IoT platform. It is the financial backbone that enables secure top-ups and facilitates automated, usage-based billing driven by real-time data from the physical IoT locker devices.
A full-stack web application designed to handle digital wallet recharges, automated ride fare deductions, and secure transaction tracking for a bicycle rental ecosystem.
Built using React + Node.js, the system integrates Razorpay APIs to enable secure, verifiable payments with backend-level signature validation.
- Razorpay Integration: Secure handling of user top-ups via Razorpay's payment gateway (supporting multiple channels).
- Automated Post-Ride Deduction (IoT Billing): Implements a precise billing mechanism where final usage fees are instantly and automatically deducted from the user's wallet balance upon receiving the ride-end data from the IoT device.
- Real-Time Balance: Manages and displays the user's current account balance for immediate oversight.
- Transaction Transparency: Provides a detailed, auditable ledger of all wallet top-ups and final ride deductions.
- Backend generates Razorpay Order IDs securely
- Frontend handles checkout via Razorpay Checkout.js
- Backend verifies payments using HMAC SHA256 cryptographic signature validation
- Prevents tampering and ensures end-to-end payment integrity
- Automatically calculates ride fare post-trip
- Deducts wallet balance without manual intervention
- Ensures real-time wallet consistency
- Maintains persistent, chronological transaction history
- Tracks:
- Credits (wallet recharges)
- Debits (ride fares)
- Stored using MongoDB with Mongoose schema validation
- Built using React + Tailwind CSS + Shadcn UI
- Displays:
- Current wallet balance
- Transaction history
- Fully responsive and optimized for real-time updates
| Technology | Purpose |
|---|---|
| React (Vite) | UI framework & build tool |
| Tailwind CSS | Utility-first styling |
| Radix UI / Shadcn UI | Accessible component library |
| Razorpay Checkout.js | Payment gateway integration |
| Lucide React | Icon library |
| Technology | Purpose |
|---|---|
| Node.js & Express.js | Server framework |
| MongoDB & Mongoose | Database & schema validation |
| Razorpay Node SDK | Payment order creation |
| Crypto (HMAC SHA256) | Signature verification |
bicycle-wallet-system/
โโโ bicycle-backend/ # Node.js/Express API server
โ โโโ config/ # Razorpay configuration
โ โโโ controllers/ # Recharge, verification, auto-debit logic
โ โโโ models/ # Wallet & transaction schemas
โ โโโ routes/ # API endpoints
โ โโโ server.js # Entry point
โโโ bicycle-frontend/ # React/Vite client
โโโ src/
โ โโโ components/ui/ # Reusable UI components
โ โโโ App.jsx # Dashboard & state logic
โ โโโ main.jsx # Entry point
โโโ package.json
- Node.js installed
- MongoDB (local or Atlas)
- Razorpay Developer Account (Test Keys)
cd bicycle-backend
npm installCreate a .env file:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/bicycle_wallet
RAZORPAY_KEY_ID=your_key
RAZORPAY_KEY_SECRET=your_secretRun the server:
npm run devServer runs on:
http://localhost:5000
cd bicycle-frontend
npm install
npm run devApp runs on:
http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/wallet/:userId |
Fetch wallet balance |
POST |
/api/wallet/auto-debit |
Deduct ride fare |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/payment/create-order |
Generate Razorpay order |
POST |
/api/payment/verify-payment |
Verify payment signature |
1. Dashboard โ User views current wallet balance
2. Recharge โ User selects amount
โ Frontend requests Razorpay Order ID from backend
โ Razorpay Checkout modal opens
3. Verification โ Razorpay returns payment signature
โ Backend verifies using HMAC SHA256
4. Credit Wallet โ Balance updated in database
โ Transaction logged in ledger
- HMAC SHA256 signature verification prevents payment tampering
- Backend-controlled order creation ensures a secure payment lifecycle
- Data integrity maintained via validated MongoDB schemas
- Separation of payment verification logic and wallet management
- Scalable backend architecture using Express modular routing
- Persistent ledger system for auditability and traceability
- JWT-based authentication system
- Razorpay Webhooks for async payment handling
- Automated PDF invoice generation
- Multi-user support with role-based access control
This project is open-source and available under the MIT License.