ion-bazan/pl-qr-payment

This library helps you generate payment QR codes for Polish bank mobile applications

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

README

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

This library helps you generate payment QR codes for Polish bank mobile applications. This is useful in invoice generators, etc to let your customers pay event faster 💸.

Makes use of endroid/qr-code for QR-code generation but you can use any library, because the QR string is available via getQrString() method.

Please note, that this library is only suitable for Polish bank systems

Installation

Use Composer to install the library.

composer require ion-bazan/pl-qr-payment

Minimal usage example

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();

Advanced usage

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

Validation

Currently, this library does not offer any fancy validation. It tries to stop you from breaking things by stripping invalid characters but don't expect too much. You should already have your data valid before generating the QR code.

Footnotes

This library is a quick approach to implement so called Rekomendacja Związku Banków Polskich dotycząca kodu dwuwymiarowego („2D”), umożliwiającego realizację polecenia przelewu oraz aktywację usług bankowych na rynku polskim - wersja 1.0

According to that document, QR codes should have following parameters:

License

This library is under the MIT license.