kaio-souza / pix-php
简单的 PIX 生成器
v1.0
2022-10-27 20:36 UTC
Requires
- ext-mbstring: *
- mpdf/qrcode: ^1.2
Suggests
- ext-gd: To output QR codes to PNG files
- ext-simplexml: To output QR codes to SVG files
This package is auto-updated.
Last update: 2024-09-08 17:00:07 UTC
README
一个简单的库,用于生成媒体/数据以便复制粘贴 Pix
可在 Composer 上使用
composer require kaio-souza/pix-php
要求
- 要生成图像,需要启用 ext php-gd 扩展
实例化类
使用常量作为参数(更安全,在更新情况下)
$pix = new PixGenerator([ MandatoryConfig::PIX_KEY => 'teste@teste.com', MandatoryConfig::MERCHANT_NAME => 'Tester', ]);
使用字符串
$pix = new PixGenerator([ 'pix_key' => 'teste@teste.com', 'merchant_name' => 'Tester', ]);
更多参数
$pix = new PixGenerator([ MandatoryConfig::PIX_KEY => 'teste@teste.com', MandatoryConfig::MERCHANT_NAME => 'Tester', OptionalConfig::MERCHANT_CITY => 'SAO PAULO', // 'SAO PAULO' is the DefaultValue OptionalConfig::CURRENCY => '986', // 986 = BRL | is the DefaultValue OptionalConfig::COUNTRY_CODE => 'BR', // 'BR' is the default Alpha2 value ]);
- 货币代码使用 ISO4217 填充 点击此处查看 ISO4217 货币列表
- 国家代码使用 ISO3166-1 alpha 2 填充
获取二维码文本
echo $pix->getQrCodeText(20, 'Teste Lala'); // returns 00020126510014br.gov.bcb.pix0115teste@teste.com0210Teste Lala520400005303986540520,005802BR5906Tester6002BR62270523bca37b925af47abd511393463041FC2
获取二维码图像
// returns QRCode PNG output $code = $pix->getQrCode(20, 'Teste Lala'); // Save the output on file file_put_contents('qr.png', $code);
或
$code = $pix->getBase64QrCode('14,50', 'Teste Lala'); // show QRCODE on HTML img tag echo "<img src='data:image/png;base64, {$code}' />";
** 金额可以使用逗号或点分隔小数位