Skip to content

Instantly share code, notes, and snippets.

@benstigsen
Created March 18, 2019 21:13
Show Gist options
  • Save benstigsen/ff158aa929c80b916da19e0e779e85c4 to your computer and use it in GitHub Desktop.
Save benstigsen/ff158aa929c80b916da19e0e779e85c4 to your computer and use it in GitHub Desktop.
Python script to generate a QR for MobilePay
import PySimpleGUI as sg
import qrcode
text = sg.PopupGetText("Telefonnummer / BoxID", "12345678 / box12345")
amount = sg.PopupGetText("Automatisk Beløb", "0")
text = text.lower()
text = text.replace(" ", "")
text = text.replace("box", "")
text = text.strip()
amount = amount.replace(" ", "")
amount = amount.strip()
print(f"{text}: {len(text)}")
print(f"{amount}")
if len(text) > 5 or amount == "0" or amount == "":
amount = ""
else:
amount = f"&amount={amount}"
url = f"https://mobilepay.dk/box?phone=box{text}{amount}"
img = qrcode.make(url)
img = img.resize((320, 320))
img.save("QR-code.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment