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()