This project is a donation system built using FastAPI, HTML, CSS, JavaScript, and Razorpay for payment processing. It allows users to donate to an organization and processes the payment via Razorpay.
- Collects Name, Email, Phone Number, and Donation Amount from users.
- Uses Razorpay to handle secure online payments.
- FastAPI backend to create orders and verify payments.
- Dockerized setup with Nginx as a reverse proxy.
fastapi-razorpay-donation/
│── backend/
│ ├── main.py # FastAPI application (handles payment)
│ ├── database.py # SQLite3 database setup
│ ├── models.py # ORM Models
│ ├── schemas.py # Pydantic models
│ ├── services.py # Razorpay integration
│ ├── utils.py # Helper functions
│ ├── .env # Environment variables (to be created manually)
│ ├── requirements.txt # Backend dependencies
│
│── frontend/
│ ├── index.html # Main donation page
│ ├── donation.js # Handles form submission and Razorpay checkout
│ ├── styles.css # Styling
│ ├── nginx.conf # Nginx configuration
│ ├── Dockerfile # Dockerfile for frontend
│
│── docker-compose.yml # Defines services (backend, frontend, nginx)
│── README.md # Documentation
- Docker & Docker Compose installed
- Razorpay Account (for API keys)
- Git installed (optional but recommended)
git clone https://github.com/yourusername/fastapi-razorpay-donation.git
cd fastapi-razorpay-donation
Inside the backend/
directory, create a .env
file with the following content:
DATABASE_URL=sqlite:///data/db.sqlite3
RAZORPAY_KEY=your_razorpay_key_here
RAZORPAY_SECRET=your_razorpay_secret_here
🔹 Replace placeholders with actual values.
Also change the your host IP adderss in donation.js
:
const response = await fetch("http://192.168.29.154:8000/create_payment/", { // replace this `http://192.168.29.154:8000` with your host of backend running machine
1️⃣ Build & Run Containers
docker-compose up --build
2️⃣ Access the App
- Open
http://localhost
in your browser. - Click the Donate button.
- Complete the Razorpay checkout process.
To stop the running containers, use:
docker-compose down
This will shut down and remove all running containers.
- Clicking Donate opens the Razorpay checkout.
- If payment is successful, user sees a thank-you message.
- If payment fails, an alert is shown prompting retry.
- If Razorpay modal doesn’t appear:
- Check browser console for errors.
- Verify backend is running (
docker ps
should showbackend
container running).
- If API requests fail:
- Ensure
nginx.conf
correctly proxies/create-order
tobackend:8000
.
- Ensure
If you face any issues, feel free to open an issue in the repository.
*This is just for tech demonstration purpose