phumin/promptparse

All-in-one PHP library for PromptPay & EMVCo QR Codes

1.0.1 2024-04-23 15:25 UTC

This package is auto-updated.

Last update: 2024-11-19 10:02:33 UTC


README

"All-in-one PHP library for PromptPay & EMVCo QR Codes"

No dependency. Just install and enjoy!

This is a PHP port of maythiwat/promptparse

Features

  • Parse — PromptPay & EMVCo QR Code data strings into object
  • Generate — QR Code data from pre-made templates (for example: PromptPay AnyID, PromptPay Bill Payment, TrueMoney, etc.)
  • Manipulate — any values from parsed QR Code data (for example: transfer amount, account number) and encodes back into QR Code data
  • Validate — checksum and data structure for known QR Code formats (for example: Slip Verify API Mini QR)

Usage

Parsing data and get value from tag

use phumin\PromptParse\Parser;

// Example data
$ppqr = Parser::parse("000201010211...");

// Get Value of Tag ID '00'
$ppqr->getTagValue("00") // Returns '01'

Build QR data and append CRC tag

use phumin\PromptParse\Library\TLV;

// Example data
$data = [
  TLV::tag("00", "01"),
  TLV::tag("01", "11"),
  ...
];

// Set CRC Tag ID '63'
TLV::withCrcTag(TLV::encode($data), '63'); // Returns '000201010211...'

Generate PromptPay Bill Payment QR

use phumin\PromptParse\Generate;

$payload = Generate::billPayment("1xxxxxxxxxxxx", "300.0", "INV12345");

// TODO: Create QR Code from payload

Validate & extract data from Slip Verify QR

use phumin\PromptParse\Validate;

$data = Validate::slipVerify("00550006000001...");

list($sendingBank, $transRef) = $data;
// or
$sendingBank = $data[0];
$transRef = $data[1];

// TODO: Inquiry transaction from Bank Open API

Convert BOT Barcode to PromptPay QR Tag 30 (Bill Payment)

use phumin\PromptParse\Parser;

$botBarcode = Validate::parseBarcode("|310109999999901\r...");

$payload = $botBarcode->toQrTag30();

// TODO: Create QR Code from payload

References

License

This project is MIT licensed (see LICENSE.md)