PHP code example of matok / pay-by-square-svk

1. Go to this page and download the library: Download matok/pay-by-square-svk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

matok / pay-by-square-svk example snippets


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

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

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