Created
March 18, 2019 21:13
-
-
Save benstigsen/ff158aa929c80b916da19e0e779e85c4 to your computer and use it in GitHub Desktop.
Python script to generate a QR for MobilePay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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