matok/pay-by-square-svk

Payment QR Code generator for Slovak banks.

1.0 2025-04-13 14:03 UTC

This package is auto-updated.

Last update: 2025-07-13 20:11:52 UTC


README

Overview

This PHP library hanle generation of QR Code Payment.

Installation

You can install the library using Composer:

composer require matok/pay-by-square-svk

Requirements

You need https://en.wikipedia.org/wiki/XZ_Utils in order to generate pyament QR Code. To set this dependecy you have to pass path to this application in constructor.

use Matok\PayBySquare\PaymentGenerator\Generator;
...
$generator = new Generator('/usr/bin/xz');

How to use

use Matok\PayBySquare\Value\DueDate;
use Matok\PayBySquare\Value\Iban;
use Matok\PayBySquare\Value\PriceEur;
use Matok\PayBySquare\Value\Message;
...

$iban = new Iban('SK39 8360 5207 0042 0320 8125');
$price = new PriceEur('2.50');
$variableSymbol = VariableSymbol(123);
$message = new Message('my payment message');

$payment = $generator->generatePayment(
    $iban,
    $price,
    $variableSymbol,
    $message,
    DueDate::today()
);

You have several possibilities how to display QR Code:

// inline:
echo '<img src="' . $payment->toQrCode()->toPngInline(); .'" alt="qr code">';
// generate in controller:
header('Content-Type: image/png');
echo $payment->toQrCode()->toPng();
// you can generate QR Code by any library using payment string
showQrCode($payment->toString());

License

This library is released under the MIT License.