# MVP Technical Documentation

## UPI Auto Payment System (PHP + Supabase + Android Listener)

---

# 1. Overview

This document describes the **Minimum Viable Product (MVP)** implementation of the **UPI Auto Payment System** used to automatically credit user wallets after a successful UPI payment.

The MVP is designed for fast deployment for platforms such as:

* Online games
* Wallet-based applications
* Entry-fee gaming platforms

The system avoids traditional payment gateways and instead detects incoming payments through Android notification monitoring.

---

# 2. MVP Goals

The MVP version focuses on the core features required to process deposits automatically.

Primary goals:

* Detect incoming UPI payments
* Extract transaction details
* Send payment data to backend
* Prevent duplicate transactions
* Automatically credit user wallet

---

# 3. Technology Stack

| Layer          | Technology          |
| -------------- | ------------------- |
| Frontend       | PHP Website         |
| Backend API    | PHP                 |
| Database       | Supabase PostgreSQL |
| Mobile Service | Android (Java)      |
| Payment Source | UPI Apps            |

Supported UPI Apps:

* Google Pay
* PhonePe
* Paytm
* BHIM

---

# 4. High Level Architecture

System flow:

User → Website → UPI Payment → Android Notification → Listener App → PHP API → Supabase Database → Wallet Credit

Steps:

1. User initiates deposit.
2. UPI app processes payment.
3. Payment notification appears on Android device.
4. Listener service reads notification.
5. App extracts payment details.
6. Payment data sent to backend API.
7. Backend validates transaction.
8. Wallet balance updated.

---

# 5. Core System Components

## 5.1 Android Notification Listener

Purpose:
Detect payment notifications from UPI apps.

Responsibilities:

* Monitor device notifications
* Filter UPI apps
* Extract payment details
* Send data to backend API

Extracted Fields:

* Amount
* UTR
* Sender name
* Timestamp

---

## 5.2 Backend API (PHP)

The backend API processes payment requests from the Android listener.

Responsibilities:

* Receive payment data
* Validate UTR
* Store transaction
* Update wallet balance

API Endpoint Example:

/api/payment.php

Required Parameters:

* user_id
* amount
* utr

---

## 5.3 Supabase Database

Supabase provides PostgreSQL database storage.

Database stores:

* User accounts
* Wallet balances
* Payment transactions

---

# 6. Database Schema

## Users Table

Fields:

* id (Primary Key)
* username
* wallet_balance

Example:

users

id | username | wallet_balance

---

## Transactions Table

Fields:

* id (Primary Key)
* user_id
* amount
* utr
* status
* created_at

Example:

transactions

id | user_id | amount | utr | status | created_at

---

# 7. Payment Processing Flow

Step 1
User clicks **Deposit ₹100**.

Step 2
Website launches UPI payment link.

Step 3
User completes payment in UPI app.

Step 4
UPI notification appears.

Example notification:

"₹100 received from Rahul. UPI Ref No: 324567891234"

Step 5
Listener service captures notification.

Step 6
Application extracts amount and UTR.

Step 7
Data sent to backend API.

Step 8
Backend checks:

* Valid request
* Unique UTR
* Valid amount

Step 9
Transaction stored in database.

Step 10
Wallet balance updated.

---

# 8. Security Design

Basic security mechanisms in MVP:

### Duplicate UTR Prevention

Each transaction must have a unique UTR.

### Notification Source Filtering

Only allow notifications from:

* Google Pay
* PhonePe
* Paytm
* BHIM

### Backend Validation

Server validates:

* Amount
* UTR format
* User ID

### Logging

All transactions should be logged.

---

# 9. Deployment Setup

Recommended environment:

Server:

* Ubuntu VPS
* Apache / Nginx
* PHP 8+

Database:

* Supabase PostgreSQL

Android Device:

* Dedicated Android phone
* Notification access enabled

---

# 10. Limitations (MVP)

Current limitations of the MVP system:

* Requires an Android device online
* Notification format may vary between UPI apps
* No automatic reconciliation
* No admin dashboard

---

# 11. Future Improvements

After MVP validation, the following features can be added:

* Admin dashboard
* Dynamic payment requests
* Fraud detection
* Real-time payment monitoring
* Multiple listener devices
* Payment analytics
* Automatic reconciliation system

---

# 12. Conclusion

The MVP version of the **UPI Auto Payment System** provides a lightweight and efficient solution for wallet-based payment systems without requiring a traditional payment gateway.

This architecture enables automatic wallet credit using:

* Android notification detection
* PHP backend processing
* Supabase database storage

It is suitable for early-stage gaming platforms and payment-based applications that require a fast and flexible deposit system.
