Spaces:
Sleeping
Sleeping
File size: 1,680 Bytes
2682f0f |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import streamlit as st
import qrcode
from io import BytesIO
from PIL import Image
# Page config
st.set_page_config(page_title="πΈ PhonePe QR Generator ", page_icon="π°", layout="centered")
# Title
st.title("πΈ PhonePe Payment QR Code Generator")
st.markdown("Generate a QR code for PhonePe/UPI payments.")
# Inputs
upi_id = st.text_input("Enter your UPI ID (e.g., vinayakpatil@xyz):")
name = st.text_input("Enter Payee Name:eg vinayak patil")
amount = st.number_input("Enter Amount (Optional)", min_value=0, step=1)
# Generate QR Code button
if st.button("Generate QR Code"):
if upi_id.strip() == "":
st.error("β Please enter a valid UPI ID")
else:
# Create UPI payment link
if amount > 0:
data = f"upi://pay?pa={upi_id}&pn={name}&am={amount}&cu=INR"
else:
data = f"upi://pay?pa={upi_id}&pn={name}&cu=INR"
# Generate QR Code
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=12,
border=4,
)
qr.add_data(data)
qr.make(fit=True)
# Create image
img = qr.make_image(fill_color="black", back_color="white")
buffer = BytesIO()
img.save(buffer, format="PNG")
buffer.seek(0)
# Display QR code
st.image(buffer, caption="π± Scan with PhonePe/UPI App",width=300)
# Download option
st.download_button(
label="β¬οΈ Download QR Code",
data=buffer,
file_name="phonepe_qrcode.png",
mime="image/png"
)
|