PHPackages                             pisethchhun/bakong-khqr-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. pisethchhun/bakong-khqr-php

ActiveLibrary[Payment Processing](/categories/payments)

pisethchhun/bakong-khqr-php
===========================

PHP package for generating and parsing Bakong KHQR (Cambodian QR payment) codes

v1.0.4(11mo ago)0172MITPHPPHP ^8.0

Since Jun 5Pushed 11mo agoCompare

[ Source](https://github.com/Yeezuu-web/bakong-khqr-php)[ Packagist](https://packagist.org/packages/pisethchhun/bakong-khqr-php)[ RSS](/packages/pisethchhun-bakong-khqr-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (6)Used By (0)

Bakong KHQR PHP
===============

[](#bakong-khqr-php)

A comprehensive PHP package for generating, parsing, and validating Bakong KHQR (Cambodian QR payment) codes. This package provides tools for developers to easily integrate with Cambodia's Bakong payment system.

[![Latest Version on Packagist](https://camo.githubusercontent.com/41dd831760dbc5d1c1bb93d379e7c63f8d5377e2e5b0d059ad70e37a14855fab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706973657468636868756e2f62616b6f6e672d6b6871722d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pisethchhun/bakong-khqr-php)[![Total Downloads](https://camo.githubusercontent.com/1acfa6cd756581fd1e4dd63879e44cd674867dde09b5b99f44059fc2e4502ec0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706973657468636868756e2f62616b6f6e672d6b6871722d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pisethchhun/bakong-khqr-php)

Features
--------

[](#features)

- Generate Bakong KHQR codes for individuals and merchants
- Parse and validate existing KHQR codes
- Support for both KHR and USD currencies
- Deep link generation for mobile apps
- Token-based operations for account verification
- Comprehensive test suite using Pest
- PSR-4 autoloading and PSR-12 code style

Requirements
------------

[](#requirements)

- PHP 8.0 or higher

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require pisethchhun/bakong-khqr-php
```

Usage
-----

[](#usage)

### Generating Individual KHQR

[](#generating-individual-khqr)

```
use Piseth\BakongKhqr\Models\IndividualInfo;
use Piseth\BakongKhqr\BakongKHQR;

// Create individual information
$individualInfo = new IndividualInfo(
    'username@wing',    // Account ID
    'Your Name',        // Merchant Name
    'Phnom Penh'        // Merchant City
);

// Set optional properties
$individualInfo->merchantID = '012345678';
$individualInfo->currency = 116; // KHR (840 for USD)
$individualInfo->amount = 1000.0;

// Generate the KHQR
$result = BakongKHQR::generateIndividual($individualInfo);

// Get the QR code string
$qrString = $result->getData()['qr'];

// Get the QR code image URL
$qrImageUrl = $result->getData()['qrImageUrl'];
```

### Generating Merchant KHQR

[](#generating-merchant-khqr)

```
use Piseth\BakongKhqr\Models\MerchantInfo;
use Piseth\BakongKhqr\BakongKHQR;

// Create merchant information
$merchantInfo = new MerchantInfo(
    'merchant@wing',      // Account ID
    'Merchant Name',      // Merchant Name
    'Phnom Penh',         // Merchant City
    '987654321',          // Merchant ID
    'Bank Name'           // Acquiring Bank
);

// Set optional properties
$merchantInfo->currency = 840; // USD (116 for KHR)
$merchantInfo->amount = 25.50;

// Generate the KHQR
$result = BakongKHQR::generateMerchant($merchantInfo);
```

### Verifying a KHQR Code

[](#verifying-a-khqr-code)

```
use Piseth\BakongKhqr\BakongKHQR;

// Verify the KHQR code
$verificationResult = BakongKHQR::verify($qrString);

// Check if valid
if ($verificationResult->isValid()) {
    echo "KHQR is valid!";
}
```

### Decoding a KHQR Code

[](#decoding-a-khqr-code)

```
use Piseth\BakongKhqr\BakongKHQR;

// Decode the KHQR code
$decodedResult = BakongKHQR::decode($qrString);

// Access decoded data
$decodedData = $decodedResult->getData();
echo "Merchant Name: " . $decodedData['merchantName'];
echo "Amount: " . ($decodedData['amount'] ?? 'Not specified');
```

### Using Additional Data Fields

[](#using-additional-data-fields)

```
// Set all possible additional fields
$additionalFields = [
    'merchantID' => '123456789',
    'acquiringBank' => 'Test Bank',
    'currency' => 116,
    'amount' => 15000.0,
    'mobileNumber' => '85512345678',
    'billNumber' => 'BILL-2023-001',
    'storeLabel' => 'Main Store',
    'terminalLabel' => 'TERM-001',
    'purposeOfTransaction' => 'Payment for services',
    'languagePreference' => 'KM',
    'merchantNameAlternateLanguage' => 'អ្នកលក់',
    'merchantCityAlternateLanguage' => 'ភ្នំពេញ',
    'upiMerchantAccount' => 'UPI-123456'
];

// Apply additional fields to individual info
foreach ($additionalFields as $field => $value) {
    if (property_exists($individualInfo, $field)) {
        $individualInfo->$field = $value;
    }
}
```

### Token-Based Operations

[](#token-based-operations)

```
use Piseth\BakongKhqr\BakongKHQR;

// Initialize with token
$token = 'your-bakong-api-token';
$bakongKHQR = new BakongKHQR($token);

// Check if a Bakong account exists
$accountResult = $bakongKHQR->checkBakongAccount('test@wing');

// Check transaction status
$transactionMD5 = md5('transaction-reference');
$transactionResult = $bakongKHQR->checkTransactionByMD5($transactionMD5);
```

### Deep Link Generation

[](#deep-link-generation)

```
use Piseth\BakongKhqr\BakongKHQR;

// Generate deep link from KHQR code
$deepLinkResult = BakongKHQR::generateDeepLink($qrString);
$deepLink = $deepLinkResult->getData()['deeplink'];
```

Advanced Usage
--------------

[](#advanced-usage)

For more advanced usage examples, please check the [examples](./examples) directory.

Testing
-------

[](#testing)

The package uses Pest for testing. To run the tests:

```
composer test
```

To run specific test suites:

```
composer test:unit     # Run unit tests only
composer test:feature  # Run feature tests only
```

Code Style
----------

[](#code-style)

This package follows PSR-12 coding standards. You can check and fix code style issues with:

```
composer cs-check  # Check code style
composer cs-fix    # Fix code style issues
```

Static Analysis
---------------

[](#static-analysis)

To run static analysis:

```
composer analyse
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Piseth Chhun](https://github.com/pisethx)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance51

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

342d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8f86494c0fafe04939f2a7454e76fd5c3b33bae7b5e508f41f0a970acd9cb76?d=identicon)[Yeezuu-web](/maintainers/Yeezuu-web)

---

Top Contributors

[![yazugaming18-ctrl](https://avatars.githubusercontent.com/u/255120800?v=4)](https://github.com/yazugaming18-ctrl "yazugaming18-ctrl (10 commits)")

---

Tags

phpqr codepaymentbakongkhqrcambodia

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pisethchhun-bakong-khqr-php/health.svg)

```
[![Health](https://phpackages.com/badges/pisethchhun-bakong-khqr-php/health.svg)](https://phpackages.com/packages/pisethchhun-bakong-khqr-php)
```

###  Alternatives

[yandex-money/yandex-money-sdk-php

Yandex.Money API SDK for PHP

105167.4k2](/packages/yandex-money-yandex-money-sdk-php)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[miracode/stripe-bundle

Symfony bundle to integrate Stripe PHP SDK. Ability to save Stripe objects in database using Doctrine.

1016.1k](/packages/miracode-stripe-bundle)[luyadev/luya-module-payment

LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.

1012.1k](/packages/luyadev-luya-module-payment)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
