ion-bazan/pl-qr-payment

这个库可以帮助您为波兰银行移动应用程序生成支付二维码

v2.0.0 2022-09-05 06:04 UTC

README

Latest Stable Version Build Status Codecov Mutation testing badge Total Downloads Monthly Downloads License

此库可以帮助您为波兰银行移动应用程序生成支付二维码。这在发票生成器等工具中非常有用,可以让您的客户更快地完成支付 💸。

使用endroid/qr-code生成二维码,但您也可以使用任何库,因为二维码字符串可通过getQrString()方法获取。

请注意,此库仅适用于波兰银行系统

安装

使用Composer安装此库。

composer require ion-bazan/pl-qr-payment

最小使用示例

use IonBazan\PaymentQR\Poland\QrPayment;

$payment = new QrPayment(
    '4249000050026313017364142', // Account number
    'Testowy odbiorca',          // Recipient name
    'Tytuł płatności',           // Payment title
    12345                        // Amount in gr
);

/** @var \Endroid\QrCode\QrCode $qrCode */
$qrCode = $payment->getQrCode(); // Do anything you want with the QrCode object

header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();

高级使用

use IonBazan\PaymentQR\Poland\QrPayment;

$payment = new QrPayment(
    '4249000050026313017364142', // Account number
    'Testowy odbiorca',          // Recipient name
    'Tytuł płatności',           // Payment title
    12345,                       // Amount in gr
    '5214349636',                // Recipient NIP (optional)
    'PL',                        // Country code (only PL is supported) (optional)
    '11223344',                  // Customer ID for Direct Debit (optional)
    '990066'                     // Invoobill ID (optional)
);

$qrString = $payment->getQrString(); // You can encode it using the QR library of your choice ...
echo $qrString;                      // ... or just print it for debug

验证

目前,此库不提供任何复杂的验证。它通过删除无效字符来尝试阻止您破坏东西,但请不要期望太多。在生成二维码之前,您应该确保您的数据是有效的。

脚注

此库是快速实现所谓的波兰银行协会关于二维条码的推荐(“2D”),该条码可实现在波兰市场上执行转账指令以及激活银行服务的功能 - 第1.0版的快速方法

根据该文件,二维码应具有以下参数

许可

此库受MIT许可协议的约束。