Skip to content

Commit

Permalink
Fixed Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wannaphong committed Feb 28, 2020
1 parent b9d7e53 commit 2a86d9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pypromptpay.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
import libscrc
import crc16
import qrcode
def qr_code(account,one_time=True,path_qr_code="",country="TH",money="",currency="THB"):
"""
Expand All @@ -26,7 +26,7 @@ def qr_code(account,one_time=True,path_qr_code="",country="TH",money="",currency
del account[0] # ตัดเลข 0 หน้าเบอร์ออก
merchant_account_information+=''.join(account)
else:
merchant_account_information+="02"+account.replace('-','') # กรณีที่ไม่รับมือถือ แสดงว่าเป็นเลขบัตรประชาชน
merchant_account_information+="0213"+account.replace('-','') # กรณีที่ไม่รับมือถือ แสดงว่าเป็นเลขบัตรประชาชน
country="5802"+country # ประเทศ
if currency=="THB":
currency="5303"+"764" # "764" คือเงินบาทไทย ตาม https://en.wikipedia.org/wiki/ISO_4217
Expand All @@ -37,9 +37,9 @@ def qr_code(account,one_time=True,path_qr_code="",country="TH",money="",currency
else:
money="54"+"0"+str(len(str(float(money))))+str(float(money)) # กรณีที่มีทศนิยมครบ
check_sum=Version+one_time+merchant_account_information+country+currency+money+"6304" # เช็คค่า check sum
check_sum1=hex(libscrc.ccitt(check_sum.encode("ascii"),0xffff)).replace('0x','')
check_sum1=hex(crc16.crc16xmodem(check_sum.encode('ascii'),0xffff)).replace('0x','')
if len(check_sum1)<4: # # แก้ไขข้อมูล check_sum ไม่ครบ 4 หลัก
check_sum1=("0"*(4-len(check_sum1)))+check_sum1
check_sum1 = ("0"*(4-len(check_sum1)))+check_sum1
check_sum+=check_sum1
if path_qr_code!="":
img = qrcode.make(check_sum.upper())
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
requirements = [
'qrcode',
'CRC-ITU',
'libscrc'
'crc16'
]
with open("README.md", "r", encoding="utf-8") as readme_file:
readme = readme_file.read()

setup(
name='pypromptpay',
version='0.4',
version='0.5',
description="PromptPay QR code in Python",
author='Wannaphong Phatthiyaphaibun',
long_description=readme,
Expand Down

0 comments on commit 2a86d9b

Please sign in to comment.