Skip to content

Kv-Logics/wallet-payment-razorpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ณ Payment_Wallet_Page: IoT Billing & Wallet Management Hub

๐ŸŒŸ Project Summary

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.


๐Ÿ“Œ Project Overview

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.


๐Ÿ’ก Core Features

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

๐Ÿš€ Core Functionalities

๐Ÿ” Secure Wallet Recharge (Razorpay Integration)

  • 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

โš™๏ธ Auto-Debit Fare Engine

  • Automatically calculates ride fare post-trip
  • Deducts wallet balance without manual intervention
  • Ensures real-time wallet consistency

๐Ÿ“œ Transaction Ledger System

  • Maintains persistent, chronological transaction history
  • Tracks:
    • Credits (wallet recharges)
    • Debits (ride fares)
  • Stored using MongoDB with Mongoose schema validation

๐Ÿ“Š Real-Time Dashboard

  • Built using React + Tailwind CSS + Shadcn UI
  • Displays:
    • Current wallet balance
    • Transaction history
  • Fully responsive and optimized for real-time updates

๐Ÿ› ๏ธ Tech Stack

๐ŸŽจ Frontend

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

โš™๏ธ Backend

Technology Purpose
Node.js & Express.js Server framework
MongoDB & Mongoose Database & schema validation
Razorpay Node SDK Payment order creation
Crypto (HMAC SHA256) Signature verification

๐Ÿ“‚ Project Structure

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

โš™๏ธ Installation & Setup

๐Ÿ”ง Prerequisites

  • Node.js installed
  • MongoDB (local or Atlas)
  • Razorpay Developer Account (Test Keys)

1๏ธโƒฃ Backend Setup

cd bicycle-backend
npm install

Create a .env file:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/bicycle_wallet
RAZORPAY_KEY_ID=your_key
RAZORPAY_KEY_SECRET=your_secret

Run the server:

npm run dev

Server runs on: http://localhost:5000

2๏ธโƒฃ Frontend Setup

cd bicycle-frontend
npm install
npm run dev

App runs on: http://localhost:5173


๐Ÿ“ก API Endpoints

Wallet Management โ€” /api/wallet

Method Endpoint Description
GET /api/wallet/:userId Fetch wallet balance
POST /api/wallet/auto-debit Deduct ride fare

Payments โ€” /api/payment

Method Endpoint Description
POST /api/payment/create-order Generate Razorpay order
POST /api/payment/verify-payment Verify payment signature

๐Ÿ’ก Usage Flow

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

๐Ÿ”’ Security Highlights

  • HMAC SHA256 signature verification prevents payment tampering
  • Backend-controlled order creation ensures a secure payment lifecycle
  • Data integrity maintained via validated MongoDB schemas

๐Ÿ“ˆ System Design Highlights

  • Separation of payment verification logic and wallet management
  • Scalable backend architecture using Express modular routing
  • Persistent ledger system for auditability and traceability

๐Ÿ”ฎ Future Enhancements

  • JWT-based authentication system
  • Razorpay Webhooks for async payment handling
  • Automated PDF invoice generation
  • Multi-user support with role-based access control

๐Ÿ“„ License

This project is open-source and available under the MIT License.

About

IoT Bicycle Rental System's Financial Hub. Integrates Razorpay for secure multi-channel top-ups and real-time balance management. Implements automated, usage-based billing: final fare is instantly deducted post-ride from wallet based on data from the IoT device. This Rental system is accessed campus wide in Amrita Vishwa Vidhyapeetham.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors