cuongnm / viet_qr_pay_generator
VietQR Pay Package
v1.0.0
2025-05-08 10:22 UTC
Requires
- php: >=8.2
- endroid/qr-code: ^6.0
Requires (Dev)
- phpunit/phpunit: ^12.0
Suggests
- ext-gd: Enables you to write PNG images
- khanamiryan/qrcode-detector-decoder: Enables you to use the image validator
- roave/security-advisories: Makes sure package versions with known security issues are not installed
- setasign/fpdf: Enables you to use the PDF writer
README
Library supporting VietQR, VietQRPay
Installation
Use Composer to install the library. Also make sure you have enabled and configured the GD extension if you want to generate images.
composer require cuongnm/viet_qr_pay_generator
Import lib
{ "require": { "cuongnm/viet_qr_pay_generator": "^1.0" } }
Tạo mã VietQRPay
use cuongnm\viet_qr_pay_generator\QRPay; $merchantId = '123456789'; // Replace with your merchant ID $acqId = '987654321'; // Replace with your acquirer ID $amount = 10000; // Amount in VND $ref = 'Test Transaction'; // Reference or description of the transaction $returnText = true; // Set to true to return text, false for image in base64 $content = QRPay::create() ->merchantId($merchantId) // merchant id ->acqId($acqId) // acquirer id ->amount($amount) // Money ->info($ref) // Ref ->category('5611') // Adding category ->returnText($returnText) // if true, return text. If false, return image in base64 ->generateVietQRPay(); // Debug output echo "\nGenerated VietQR content: " . $content . "\n"; // Generated VietQR content: {"code":200,"desc":"ok","data":"00020101021238560010A0000007270126000998765432101091234567890208QRIBFTTA5204561153037045405100005802VN62200816Test Transaction6304C3FA"}
Tạo mã VietQR
use cuongnm\viet_qr_pay\QRPay; $merchantId = '0102154778'; $merchantName = 'TUGIACOMPANY'; $store = 'TU GIA COMPUTER'; $terminal = 'TUGIACO1'; $qrPay = QRPay::initVNPayQR( $merchantId, $merchantName, $terminal, $terminal ); $content = $qrPay->build(); echo $content; // 00020101021126280010A0000007750110010531314453037045408210900005802VN5910CELLPHONES62600312CPSHN ONLINE0517021908061613127850705ONLHN0810CellphoneS63047685