ion-bazan/pl-qr-payment

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

v1.0.0 2019-08-30 07:49 UTC

This package is auto-updated.

Last update: 2020-03-10 08:32:55 UTC


README

Latest Stable Version Build Status Codecov 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:

Parameter Value
Type QR
Size 250 px (min. 1.8 cm x 1.8 cm)
Error Correction Low (L)
Encoding UTF-8

License

This library is under the MIT license.