keenthekeen / php-promptpay-qr
PHP 库,用于生成 PromptPay 的 QR 码负载
v1.1.0
2023-11-17 07:53 UTC
Requires
- php: >=7.4
- bacon/bacon-qr-code: ^2.0
- kittinan/php-crc: 1.0.0
Requires (Dev)
- laravel/pint: ^1.2
- pestphp/pest: ^1.22
- php-coveralls/php-coveralls: ^2.5
- phpstan/phpstan: ^1.8
This package is auto-updated.
Last update: 2024-09-17 11:14:30 UTC
README
使用流畅接口生成 Thai QR Code Standard for Payment Transactions(PromptPay)的 QR 码负载的 PHP 库
灵感来自 dtinth/promptpay-qr 和 pheerathach/promptpay
安装
您可以通过 composer 安装此包
composer require keenthekeen/php-promptpay-qr
用法
use PromptPayQR\Builder; // Generate PromptPay Payload Builder::staticMerchantPresentedQR('0899999999')->build(); // 00020101021129370016A000000677010111011300668999999995802TH53037646304FE29 // Generate PromptPay Payload With Amount Builder::staticMerchantPresentedQR('089-999-9999')->setAmount(420)->build(); // 00020101021229370016A000000677010111011300668999999995802TH53037645406420.006304CF9E // Generate PromptPay Payload With Amount (one-time use) Builder::dynamicQR()->creditTransfer()->phoneNumber('083-888-3333')->setAmount(420)->build(); // Generate PromptPay Bill Payment (Tag 30) Payload Builder::dynamicQR()->billPayment() ->setBillerIdentifier('099400015804189', 'Ref1', 'Ref2') ->setAmount(1999.99)->build(); // Generate QR Code SVG string $svgString = Builder::staticMerchantPresentedQR('1-2345-67890-12-3')->toSvgString(); // Laravel example: respond with header Content-Type: image/svg+xml return response($svgString, 200)->header('Content-Type', 'image/svg+xml')->header('Cache-Control', 'no-store'); // Generate QR Code SVG file Builder::staticMerchantPresentedQR('1-2345-67890-12-3')->toSvgFile($path);
许可协议
MIT 许可协议(MIT)。有关更多信息,请参阅 许可文件。