An open API service indexing awesome lists of open source software.

https://github.com/dev-vivekkumarverma/payment_integration

This is a simple fast api app for payment integration
https://github.com/dev-vivekkumarverma/payment_integration

docker docker-compose fastapi payment-gateway payment-integration python3 sqlite3 upi upi-integration upi-payment

Last synced: 2 months ago
JSON representation

This is a simple fast api app for payment integration

Awesome Lists containing this project

README

          

# Payment Integration
---
# FastAPI Razorpay Donation System
---
## πŸ“Œ Project Overview
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.

### Features:
- 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.

---

## πŸ—οΈ Project Structure
```
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
```

---

## πŸ› οΈ Setup Instructions

### 1️⃣ Prerequisites
- **Docker & Docker Compose** installed
- **Razorpay Account** (for API keys)
- **Git** installed (optional but recommended)

### 2️⃣ Clone the Repository
```sh
git clone https://github.com/yourusername/fastapi-razorpay-donation.git
cd fastapi-razorpay-donation
```

### 3️⃣ Create and Configure the `.env` File
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` :
```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

```
---

## πŸš€ Running the Project (Dockerized)
1️⃣ **Build & Run Containers**
```sh
docker-compose up --build
```
2️⃣ **Access the App**
- Open **`http://localhost`** in your browser.
- Click the **Donate** button.
- Complete the Razorpay checkout process.

---

## ⏹️ Stopping the Containers
To stop the running containers, use:
```sh
docker-compose down
```
This will shut down and remove all running containers.

---

## βœ… Expected Behavior
- 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.

---

## ❓ Troubleshooting
- **If Razorpay modal doesn’t appear:**
- Check browser console for errors.
- Verify backend is running (`docker ps` should show `backend` container running).
- **If API requests fail:**
- Ensure `nginx.conf` correctly proxies `/create-order` to `backend:8000`.

---

## πŸ“§ Support
If you face any issues, feel free to open an issue in the repository.

*This is just for tech demonstration purpose