File size: 1,143 Bytes
40722f2
 
a89fb87
40722f2
 
cf311c9
44013fe
 
40722f2
 
 
cf311c9
40722f2
 
 
 
 
44013fe
41d5d66
44013fe
40722f2
a89fb87
44013fe
40722f2
 
41d5d66
40722f2
 
bd94e1f
9827984
44013fe
 
40722f2
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import qrcode
from PIL import Image
import time

def generate_upi_qr_sticker(VPA, Amount, VPN=None):
    if not VPN is None:
        VPN = VPA.split('@')[0]

    # Generate UPI QR code
    qr = qrcode.QRCode(version=1, box_size=10, border=5)
    qr_data = f"upi://pay?pa={VPA}&pn={VPN}&am={Amount}&cu=INR"

    qr.add_data(qr_data)
    qr.make(fit=True)
    qr_image = qr.make_image(fill="black", back_color="white").convert("RGB")

   
    # Resize the QR code if needed
    qr_image = qr_image.resize((500, 500))

    # Return the final image
    return qr_image

iface = gr.Interface(
    fn=generate_upi_qr_sticker,
    inputs=["text", "text", "text"],
    outputs="image",
    title="Dynamic UPI Payment QR Code",
    description="A Dynamic UPI QR code sticker image is generated by entering the Virtual Payment Address (VPA), Virtual Private Name/ UPI Id (VPN), and payment amount. The system then creates a QR code that changes with each transaction, allowing users to scan it with a UPI-enabled app to make payments of the specified fixed amount effortlessly."
   

)

if __name__ == "__main__":
    iface.launch()