Edviron - NestJS Payment Gateway API
๐ A comprehensive NestJS application with MongoDB Atlas integration, JWT authentication, payment processing, and transaction management.
๐ Features
๐๏ธ NestJS Framework - Progressive Node.js framework with TypeScript
๐ MongoDB Atlas - Cloud database with Mongoose ODM
๐ JWT Authentication - Secure authentication with Passport strategies
๐ณ Payment Gateway - Edviron payment integration with JWT signing
๐ Webhook Processing - Real-time payment status updates
๐ Transaction APIs - Advanced querying with pagination and sorting
๐ก๏ธ Security - Helmet, CORS, input validation, and rate limiting
โ
Validation - Comprehensive request validation with class-validator
๐ Clean Architecture - Well-organized modular structure
๐ API Documentation - Complete Postman collection included
๐ Project Structure
src/
โโโ config/
โ โโโ configuration.ts # Environment configuration
โโโ decorators/
โ โโโ public.decorator.ts # Custom decorators
โโโ dto/
โ โโโ create-user.dto.ts # User validation DTOs
โ โโโ create-payment.dto.ts # Payment validation DTOs
โ โโโ webhook.dto.ts # Webhook validation DTOs
โ โโโ transaction-query.dto.ts # Transaction query DTOs
โโโ guards/
โ โโโ jwt-auth.guard.ts # JWT authentication guard
โ โโโ jwt-auth-enhanced.guard.ts # Enhanced JWT guard with public routes
โ โโโ jwt.strategy.ts # JWT Passport strategy
โ โโโ local.strategy.ts # Local Passport strategy
โโโ middlewares/
โ โโโ logger.middleware.ts # HTTP request logging
โโโ modules/
โ โโโ auth/
โ โ โโโ auth.controller.ts # Authentication endpoints
โ โ โโโ auth.service.ts # Authentication logic
โ โ โโโ auth.module.ts # Auth module configuration
โ โโโ user/
โ โ โโโ user.controller.ts # User CRUD endpoints
โ โ โโโ user.service.ts # User business logic
โ โ โโโ user.module.ts # User module configuration
โ โโโ payment/
โ โโโ payment.controller.ts # Payment endpoints
โ โโโ payment.service.ts # Payment processing logic
โ โโโ webhook.service.ts # Webhook processing
โ โโโ transaction.service.ts # Transaction queries
โ โโโ transaction.controller.ts # Transaction endpoints
โ โโโ payment.module.ts # Payment module configuration
โโโ schemas/
โ โโโ user.schema.ts # User MongoDB schema
โ โโโ order.schema.ts # Order MongoDB schema
โ โโโ order-status.schema.ts # OrderStatus MongoDB schema
โ โโโ webhook-logs.schema.ts # WebhookLogs MongoDB schema
โโโ app.controller.ts
โโโ app.module.ts # Main application module
โโโ app.service.ts
โโโ main.ts # Application entry point
๐ง Prerequisites
Node.js (v18 or higher)
npm or yarn
MongoDB Atlas account
Postman (optional, for API testing)
๐ Quick Start
1. Clone and Install
# Clone the repository
git clone <repository-url>
cd edviron
# Install dependencies
npm install
2. Environment Configuration
# Copy environment template
cp .env.example .env
Edit the
.env file with your configuration:# Application Configuration
PORT=3000
NODE_ENV=development
# CORS Configuration
CORS_ORIGIN=http://localhost:3000,http://localhost:3001
# Payment Gateway Configuration
PAYMENT_API_KEY=your-edviron-api-key
PG_KEY=your-payment-gateway-key
PAYMENT_BASE_URL=https://dev-vanilla.edviron.com
# Security Configuration
BCRYPT_SALT_ROUNDS=10
API_KEY=your-api-key-here
3. MongoDB Atlas Setup
Create Account: Visit MongoDB Atlas
Create Cluster: Set up a free tier cluster
Database User: Create a user with read/write permissions
Network Access: Whitelist your IP (use
0.0.0.0/0 for development)Connection String: Copy and update
MONGODB_URI in .env4. Run the Application
# Development mode with hot reload
npm run start:dev
# Production mode
npm run start:prod
# Debug mode
npm run start:debug
๐ Application will be available at:
http://localhost:3000๐ API Documentation
๐ Authentication Endpoints
Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST | /auth/login | User login | โ |
GET | /auth/profile | Get user profile | โ
|
๐งช Usage Examples
Authentication Flow
# 1. Create a user
curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"email": "john@example.com",
"password": "password123",
"firstName": "John",
"lastName": "Doe"
}'
# 2. Login to get JWT token
curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "john@example.com",
"password": "password123"
}'
# 3. Use JWT token for protected routes
curl -X GET http://localhost:3000/auth/profile \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
๐ฎ Postman Collection
Import the included Postman collection for easy API testing:
Open Postman
Click Import
Select
Edviron-API.postman_collection.jsonUpdate environment variables:
baseUrl: http://localhost:3000accessToken: Your JWT token from login๐ License
This project is MIT licensed.
image2
image3
image4
image5
0 likes ยท 6 views ยท May 28, 2026
A comprehensive NestJS application for payment processing and transaction management.