-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreateLinkUPI.py
78 lines (64 loc) · 2.07 KB
/
CreateLinkUPI.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Generate UPI URL based on Specification Document 1.5
# Install Dependencies:
# pip install pyperclip
# pip install qrcode
# pip install git+git://github.com/ojii/pymaging.git#egg=pymaging
# pip install git+git://github.com/ojii/pymaging-png.git#egg=pymaging-png
#
#
import sys, os, pyperclip
import urllib.parse
import qrcode, qrcode.image.svg
from qrcode.image.pure import PymagingImage
def generateURL(pa="xxxx@okaxis",
pn="Payee Name",
mc="0000",
tid="06-December-2019",
tr="BILL-0091",
tn="Lunch at GLENS",
am="10",
mam='null',
cu="INR",
url="https://www.google.com"):
"""
Documentation : Generate URL based on the parameters passed
Usage GenerateURL <PARAMS>
<VPA Address>
<PayeeName>
<MCC>
<Transaction ID>
<Transaction Ref. #>
<Transaction Note>
<Transaction Amount>
<Min. Transaction Amount>
<Currency Code>
<URL>
"""
# Define Payload for URL Parser
payload = urllib.parse.urlencode({"pa":pa, "pn":pn, "mc": mc, "tid":tid, "tr": tr, "tn": tn, "am": am, "mam": mam, "cu": cu, "url": url},quote_via=urllib.parse.quote)
# Generate UPI Link
link = "upi://pay?%s" % payload
print("\nEncoded URL: \n",link)
# Copy Link
pyperclip.copy(link)
return link
def GenerateQR(upilink):
qr = qrcode.QRCode(
version=None,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(upilink)
qr.make(fit=True)
# Generate QR Image on Terminal in ASCII Format
qr.print_ascii()
# Set Colors
img = qr.make_image(fill_color="black", back_color="white")
# Show Image
img.show()
# Save Image
img.save("QR.png")
#Newimg = qrcode.make(upilink, image_factory=PymagingImage)
qr = generateURL(am="1000")
GenerateQR(qr)