Ikhode-Technologies / khqr-php-composer-setup

khqr payment method implement in php composer environment

Repository from Github https://github.comIkhode-Technologies/khqr-php-composer-setupRepository from Github https://github.comIkhode-Technologies/khqr-php-composer-setup

khqr-php-composer-setup

đź’ˇ Only Silver Membership can access this private repo - let's our join discord server

Portfolio Portfolio Portfolio Portfolio Portfolio Portfolio Portfolio Linkedin image

Profile Image I'm a Software Developer who passionate about coding and building tools that help people with their daily tasks. I'm currently exploring AI solutions and working with modern tech stacks. I'm also on a journey to level up my Spaghetti Code skills. Support us by make some donate and I really appricate that.

Got a question? Feel free to contact me anytime.

Bakong KHQR Payment Integration

This project implements a payment gateway for the Bakong KHQR system (Cambodia's QR code-based payment system). It allows merchants to generate KHQR codes and verify payment status through the Bakong API.

Features

  • Generate KHQR codes for payments
  • Display QR codes for customer scanning
  • Poll payment status in real-time
  • Simple user interface for payment processing

Prerequisites

  • PHP 8.0 or higher
  • Composer for PHP dependency management
  • A Bakong merchant account with API access
  • Web server (Apache, Nginx, etc.)

Profile Image

screenshot image of khqr php composer setup with simple ui

Installation

  1. Clone the repository:

    git clone https://github.com/ikhode-technologies/private-repo.git
    cd private-repo
  2. Install PHP dependencies using Composer:

    composer require khqr-gateway/bakong-khqr-php endroid/qr-code guzzlehttp/guzzle
  3. Configure your Bakong API credentials:

    • Open khqr_api.php and replace 'bakong api key' with your actual Bakong API key
    • Update the Bakong account ID in the $individualInfo object:
      $individualInfo = new IndividualInfo(
          bakongAccountID: 'your_bakong_account@domain',
          // ... other settings
      );

Configuration

Merchant Information

Modify the merchant details in the khqr_api.php file:

$individualInfo = new IndividualInfo(
    bakongAccountID: 'your_bakong_account@domain',  // Your Bakong ID
    merchantName: 'Your Business Name',            // Your business name
    merchantCity: 'Your City',                     // Your business city
    currency: KHQRData::CURRENCY_USD,              // Currency (USD or KHR)
    amount: floatval($amount),                     // Amount from request
    billNumber: $transactionId,                    // Transaction ID
    purposeOfTransaction: 'Payment'                // Purpose description
);

Payment Settings

You can modify the payment amount in index.html:

body: JSON.stringify({
    amount: 0.1,  // Change to your desired default amount
    transactionId: 'TEST' + Date.now()
})

Usage

  1. Start your web server pointing to the project directory
  2. Access the application through your browser (e.g., http://localhost/index.html)
  3. Click "Generate QR Code" to create a new payment request
  4. The customer scans the QR code using their Bakong app
  5. The system automatically checks for payment confirmation
  6. Once payment is confirmed, the status will update to "Successfully Paid!"

File Structure

  • khqr_api.php - Main PHP backend for KHQR generation and payment verification
  • index.html - Frontend interface for payment processing
  • payment.log - Log file for transaction records
  • vendor/ - Composer dependencies

Troubleshooting

Common Issues

  1. QR Code Not Generating

    • Check if all required PHP extensions are installed
    • Verify your Bakong API key is correct
    • Check the PHP error logs
  2. Payment Status Not Updating

    • Ensure the Bakong API is accessible from your server
    • Check if the polling interval is working correctly
    • Verify your Bakong account has the correct permissions
  3. CORS Issues

    • The application includes CORS headers, but if you're running on a different domain, you may need to adjust the Access-Control-Allow-Origin header

Logging

The application logs important events to payment.log. Check this file for debugging information:

tail -f payment.log

License

MIT - See the LICENSE file for details

Support

For support, please contact with this contact list or create an issue in the repository.

About

khqr payment method implement in php composer environment

License:MIT License