Download the PHP package konthaina/khqr-php without Composer
On this page you can find all versions of the php package konthaina/khqr-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package khqr-php
konthaina/khqr-php
KHQR / EMVCo merchant-presented QR payload generator for PHP (Bakong / Cambodia). Includes CRC16 (CRC-16/CCITT-FALSE), MD5, and verification helpers.
Namespace:
Konthaina\KhqrMain class:Konthaina\Khqr\KHQRGenerator
Features
- Generate KHQR payload string (EMV Tag-Length-Value format)
- Supports Individual and Merchant account structures
- Supports Static QR and Dynamic QR
- Optional fields: amount, bill number, mobile number, store label, terminal label, purpose, alternate language, etc.
- CRC16 calculation + verification
- Returns md5 hash of the full QR payload string
Requirements
- PHP >= 8.0
- Composer
Installation
Install via Composer (Packagist)
Install from local path (during development)
In your main app composer.json:
Then:
Quick Start
Returned structure:
Static QR vs Dynamic QR
- Static QR uses POI=11 and includes Tag 99 sub-tag 00 as the create timestamp.
- Dynamic QR is the default mode (POI=12) and includes Tag 99 sub-tag 00 as the create timestamp plus sub-tag 01 as the expiration timestamp.
- Dynamic QR defaults to expiring 300 seconds after creation. Use
setExpirationTimestamp(...)orsetExpirationDuration(...)to control it. - For a "no amount" QR, use static mode.
Static example:
Timestamp example:
Both timestamp values are 13-digit Unix timestamps in milliseconds.
Merchant Type Examples
Individual (Tag 29)
Merchant (Tag 30)
Verify KHQR (CRC)
Verify Transaction by MD5 (Bakong Open API)
Requires a Bakong Open API access token.
Renew Access Token (Bakong Open API)
Based on Bakong Open API POST /v1/renew_token:
Verify MD5 Output
Success
Not found
Fields / Limits
The generator truncates fields based on common KHQR limits used in the code:
- Bakong account id: 32
- Merchant name: 25
- Merchant ID: 32
- Acquiring bank: 32
- Account information: 32
- City: 15
- Bill number: 25
- Mobile number: 25
- Store label: 25
- Terminal label: 25
- Purpose: 25
- Language preference: 2
- Merchant name alternate: 25
- City alternate: 15
- UPI account info: 31
- Created timestamp: 13 digits, Unix milliseconds
- Expiration timestamp: 13 digits, Unix milliseconds
Note: EMV length uses byte length. If you use Khmer or Unicode characters, byte length may differ from character count.
Development / Testing
Install dev dependencies:
Run tests:
Generate autoload:
Release to GitHub / Packagist
Create a new version tag when you update the library:
Packagist will pick up tags like vX.Y.Z as stable versions (if webhook enabled).
License
MIT