All Projects → pheerathach → promptpay

pheerathach / promptpay

Licence: Apache-2.0 license
Thai QR PromptPay Generator

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to promptpay

vk-qr
VK QR Code generator library
Stars: ✭ 43 (+79.17%)
Mutual labels:  qrcode, qr
go-emv-code
EMV® QR Code Encoder/Decoder for Go.
Stars: ✭ 60 (+150%)
Mutual labels:  qrcode, qr
React Qr Svg
React component for rendering SVG QR codes
Stars: ✭ 134 (+458.33%)
Mutual labels:  qrcode, qr
Qrbtf
An art QR code (qrcode) beautifier. 艺术二维码生成器。https://qrbtf.com
Stars: ✭ 1,391 (+5695.83%)
Mutual labels:  qrcode, qr
QRCode-Decoder
An iOS QRCode Scanner and Decoder
Stars: ✭ 17 (-29.17%)
Mutual labels:  qrcode, qr
Jrqrcode
二维码生成库,把内容生成二维码,以base64编码的图片输出
Stars: ✭ 128 (+433.33%)
Mutual labels:  qrcode, qr
Qrcode Library
Create QrCodes with ease
Stars: ✭ 184 (+666.67%)
Mutual labels:  qrcode, qr
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (+3991.67%)
Mutual labels:  qrcode, qr
emv-qrcode
Golang Based EMV QR Code Generator and Parser (MPM, CPM)
Stars: ✭ 43 (+79.17%)
Mutual labels:  qrcode, qr
Qrcode
qrcode scanner ( decoder ) by golang 二维码扫描识别
Stars: ✭ 233 (+870.83%)
Mutual labels:  qrcode, qr
Awesome Qr.js
An awesome QR code generator written in JavaScript.
Stars: ✭ 1,247 (+5095.83%)
Mutual labels:  qrcode, qr
paper-store
Cold store small files on paper as QR codes -- PGP keys, Bitcoin keys, Tox keys or any other small files in general.
Stars: ✭ 28 (+16.67%)
Mutual labels:  qrcode, qr
Qrious
Pure JavaScript library for QR code generation using canvas
Stars: ✭ 1,160 (+4733.33%)
Mutual labels:  qrcode, qr
Qrscanner
A simple QR Code scanner framework for iOS. Provides a similar scan effect to ios13.
Stars: ✭ 134 (+458.33%)
Mutual labels:  qrcode, qr
Qr Ascii
A small library to generate QR codes with ascii
Stars: ✭ 63 (+162.5%)
Mutual labels:  qrcode, qr
Qr Code Bundle
Bundle for generating QR codes in Symfony
Stars: ✭ 169 (+604.17%)
Mutual labels:  qrcode, qr
Qr Image
Yet another QR code generator
Stars: ✭ 922 (+3741.67%)
Mutual labels:  qrcode, qr
Qr Code Scanner
Full stable QR code scanner android app.
Stars: ✭ 28 (+16.67%)
Mutual labels:  qrcode, qr
Jsqr
A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.
Stars: ✭ 2,722 (+11241.67%)
Mutual labels:  qrcode, qr
pyitau
Unofficial client to access your Itaú bank data
Stars: ✭ 28 (+16.67%)
Mutual labels:  bank, banking

Thai QR PromptPay Generator

ไลบรารีช่วยสร้าง QR สำหรับรับชำระเงินด้วย PromptPay โดยสามารถสร้าง

  1. QR สำหรับบุคคลธรรมดารับโอนเงิน (Credit Transfer)
  2. QR สำหรับธุรกิจรับชำระเงิน (Bill Payment)

ไลบรารีนี้ต้องการ Java เวอร์ชัน 8 ขึ้นไป

การใช้งาน

  1. QR สำหรับบุคคลธรรมดารับโอนเงิน (Credit Transfer) Tag 29
// รับชำระผ่าน PromptPay เบอร์ 081-234-5678 จำนวนเงิน: <ให้ผู้ชำระระบุ>
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().mobileNumber("0812345678").build();

// รับชำระผ่าน PromptPay เลขประจำตัวประชาชน 0-0000-00000-00-0 จำนวนเงิน: <ให้ผู้ชำระระบุ>
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().nationalId("0000000000000").build();

// รับชำระผ่าน PromptPay E-Wallet ID 000000000000000 จำนวนเงิน: <ให้ผู้ชำระระบุ>
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().eWalletId("000000000000000").build();

// รับชำระผ่าน PromptPay เบอร์ 081-234-5678 จำนวนเงิน: 10 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().mobileNumber("0812345678").amount(new BigDecimal("10.00")).build();

// รับชำระผ่าน PromptPay เลขประจำตัวประชาชน 0-0000-00000-00-0 จำนวนเงิน: 136.25 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().nationalId("0000000000000").amount(new BigDecimal("136.25")).build();

// รับชำระผ่าน PromptPay E-Wallet ID 000000000000000 จำนวนเงิน: 0.01 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().staticQR().creditTransfer().eWalletId("000000000000000").amount(new BigDecimal("0.01")).build();
  1. QR สำหรับธุรกิจรับชำระเงิน (Bill Payment) Tag 30
// รับชำระผ่าน PromptPay เลขประจำตัวผู้เสียภาษี 0000000000000 + 99 (SUFFIX 2 หลัก)
// รหัสอ้างอิง 1: 15123141 รหัสอ้างอิง 2: 3654112 จำนวนเงิน: <ให้ผู้ชำระระบุ>
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().dynamicQR().billPayment().billerId("000000000000099").ref1("15123141").ref2("3654112").build();

// รับชำระผ่าน PromptPay เลขประจำตัวผู้เสียภาษี 0000000000000 + 99 (SUFFIX 2 หลัก)
// รหัสอ้างอิง 1: 15123141 รหัสอ้างอิง 2: 3654112 จำนวนเงิน: 200.00 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().dynamicQR().billPayment().billerId("000000000000099").ref1("15123141").ref2("3654112").amount(new BigDecimal("200.00")).build();

// รับชำระผ่าน PromptPay เลขประจำตัวผู้เสียภาษี 0000000000000 + 99 (SUFFIX 2 หลัก)
// รหัสอ้างอิง 1: 15123141 รหัสอ้างอิง 2: 3654112 รหัสอ้างอิง 3: ABCD จำนวนเงิน: 200.00 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().dynamicQR().billPayment().billerId("000000000000099").ref1("15123141").ref2("3654112").ref3("ABCD").amount(new BigDecimal("200.00")).build();

// รับชำระผ่าน PromptPay เลขประจำตัวผู้เสียภาษี 0000000000000 + 99 (SUFFIX 2 หลัก)
// รหัสอ้างอิง 1: 15123141 รหัสอ้างอิง 3: ABCD จำนวนเงิน: 100.00 บาท
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().dynamicQR().billPayment().billerId("000000000000099").ref1("15123141").ref3("ABCD").amount(new BigDecimal("100.00")).build();
  1. QR สำหรับธุรกิจรับชำระเงิน (Bill Payment) ตามมาตรฐานเดิมของธปท.
// รับชำระแบบ Bill Payment เดิมตามธปท. เลขประจำตัวผู้เสียภาษี 0000000000000 + 99 (SUFFIX 2 หลัก)
// รหัสอ้างอิง 1: 15123141 รหัสอ้างอิง 2: 3654112 จำนวนเงิน: <ให้ผู้ชำระระบุ>
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().bot().billPayment().billerId("000000000000099").ref1("15123141").ref2("3654112").build();

ข้อพึงสังเกต

  • QR ที่ถูกสร้างขึ้นเพื่อให้ใช้ได้หลายครั้ง คือ staticQR()
  • QR ที่ถูกสร้างขึ้นเพื่อให้ใช้ได้แค่ครั้งเดียว คือ dynamicQR()

วิธีนำไปใช้

  1. นำเข้าไลบรารีผ่าน Maven โดยเพิ่มโค้ดดังกล่าวใน pom.xml
<dependencies>
...
		<dependency>
			<groupId>com.github.pheerathach</groupId>
			<artifactId>promptpay</artifactId>
			<version>1.0.2</version>
		</dependency>
</dependencies>
  1. เรียกใช้ไลบรารี
ThaiQRPromptPay qr = new ThaiQRPromptPay.Builder().dynamicQR().creditTransfer().mobileNumber("0812345678").amount(new BigDecimal("100.00")).build();

2.1. หากต้องการเนื้อหาสำหรับนำไปสร้างรูป QR

String content = qr.generateContent();

2.2. หากต้องการให้ไลบรารีสร้างรูป QR ให้

2.2.1. เป็นไฟล์ PNG

qr.draw(300, 300, new File("D:\\qr.png")); // width 300 x height 300 pixels | save to D:\qr.png

2.2.2. เป็น Base64 String (PNG)

qr.drawToBase64(300, 300); // width 300 x height 300 pixels

2.2.3. เป็น byte[]

qr.drawToByteArray(400, 400); // width 400 x height 400 pixels

เอกสารอ้างอิง

  • มาตรฐานการรับชำระเงินด้วย QR ของธนาคารแห่งประเทศไทย

https://www.bot.or.th/Thai/FIPCS/Documents/FPG/2562/ThaiPDF/25620084.pdf

  • ZXing 3.4.0

https://github.com/zxing/zxing

  • Apache Commons Codec 1.12

https://commons.apache.org/proper/commons-codec/

  • ขอขอบคุณ คุณ thedayofcondor สำหรับ method ในการหา CRC16

https://stackoverflow.com/questions/13209364/convert-c-crc16-to-java-crc16/13209435

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].