A lightweight API for generating UPI QR codes and rendering a secure payment page. This project is built using Go and the Gorilla Mux router.
Example of payment page
- Generate QR codes for UPI payments.
- Serve a customizable payment page with UPI details.
- Easy-to-use RESTful endpoints.
- Static assets support for additional resources.
- Go - https://golang.org
- Modules:
github.com/skip2/go-qrcode
-
Clone this repository:
git clone https://github.com/AshokShau/upi-qr-generator.git cd upi-qr-generator
-
Install dependencies:
go mod download
-
Run the application:
go run main.go
-
The server will start at
http://localhost:3000
.
upi-qr-generator/
├── api/ // API endpoint handlers for vercel
│ ├── index.go // Handles /
│ ├── pay.go // Handles /pay
│ ├── qr.go // Handles /qr
├── str/ // String constants and HTML templates
│ ├── files.go // HTML templates for payment page
│ ├── handlers.go // Handlers for API endpoints
├── main.go // Main entry point of application
├── README.md // Project README file
└── LICENSE // Project license file
Redirects to the homepage (static/index.html
) that provides usage information.
Generates a UPI QR code based on the provided query parameters:
-
Parameters:
vpa
(string, required): UPI ID (e.g.,example@upi
).name
(string, optional): Payee name (e.g.,John Doe
).amount
(float, required): Payment amount (e.g.,100.50
).
-
Example:
/qr?vpa=example@upi&name=John+Doe&amount=100.50
-
Response: A PNG image of the QR code.
Renders a payment page with UPI details:
-
Parameters:
vpa
(string, required): UPI ID (e.g.,example@upi
).name
(string, optional): Payee name (e.g.,John Doe
).amount
(float, required): Payment amount (e.g.,100.50
).
-
Example:
/pay?vpa=example@upi&name=John+Doe&amount=100.50
-
Response: A rendered HTML page with the QR code and payment details.
- The
/qr
endpoint generates a UPI QR code using theqrcode
library. - The
/pay
endpoint serves a payment page with details dynamically rendered from thetemplate.html
file. - Static assets such as styles and templates are served from the
static
folder.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to explore, use, or contribute to this project. If you encounter any issues or have suggestions, open a GitHub issue or create a pull request!