Skip to content

Instantly share code, notes, and snippets.

@Nempickaxe
Created May 5, 2023 09:49
Show Gist options
  • Save Nempickaxe/6078fe31174c3bdc8e6663512ba17a45 to your computer and use it in GitHub Desktop.
Save Nempickaxe/6078fe31174c3bdc8e6663512ba17a45 to your computer and use it in GitHub Desktop.
Generate UPI code to receive payment at merchant's end
import qrcode
def generate_upi_qr_code(merchant_upi_id, merchant_name, payment_description, payment_amount):
# create the QR code string
qr_string = "upi://pay?pa={}&pn={}&tn={}&am={}".format(merchant_upi_id, merchant_name, payment_description, payment_amount)
# generate the QR code
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4)
qr.add_data(qr_string)
qr.make(fit=True)
# save the QR code as an image file
img = qr.make_image(fill_color="black", back_color="white")
img.save("erupi_payment.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment