PHP code example of hlavtox / qr-payment-string-generator
1. Go to this page and download the library: Download hlavtox/qr-payment-string-generator 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/ */
hlavtox / qr-payment-string-generator example snippets
$generator
->setIban('SK80 7500 0000 0040 2246 6192') // string; spaces are accepted
->setBic('CEKOSKBX') // string; Czech QR Platba safely ignores it
->setBeneficiaryName('Řehoř Žížala') // UTF-8 string
->setAmount('125.50') // exact decimal string, never a float
->setVariableSymbol('001234') // string to preserve leading zeroes
->setDueDate('2026-08-15'); // YYYY-MM-DD string or DateTimeInterface
use Hlavtox\QrPaymentStringGenerator\PayBySquarePaymentStringGenerator;
$payload = (new PayBySquarePaymentStringGenerator())
->setIban('SK8075000000004022466192')
->setAmount('49.00')
->setBeneficiaryName('Example company s.r.o.')
->setBic('CEKOSKBX')
->setVariableSymbol('202600123')
->setPaymentNote('Invoice 202600123')
->setDueDate('2026-08-15')
->generate();
use Hlavtox\QrPaymentStringGenerator\CzechQrPaymentStringGenerator;
$payload = (new CzechQrPaymentStringGenerator())
->setIban('CZ330100000000002970297')
->setAmount('555.55')
->setVariableSymbol('202600123')
->generate();
use Hlavtox\QrPaymentStringGenerator\EpcQrPaymentStringGenerator;
$payload = (new EpcQrPaymentStringGenerator())
->setIban('SK8075000000004022466192')
->setAmount('49.00')
->setBeneficiaryName('Example company s.r.o.')
->setBic('CEKOSKBX')
->setPaymentNote('Invoice 202600123')
->generate();
use Hlavtox\QrPaymentStringGenerator\CzechQrPaymentStringGenerator;
use Hlavtox\QrPaymentStringGenerator\EpcQrPaymentStringGenerator;
use Hlavtox\QrPaymentStringGenerator\PayBySquarePaymentStringGenerator;
// Store the recipient details once in application configuration
$shopConfiguration = [
'iban' => 'SK8075000000004022466192',
'bic' => 'CEKOSKBX',
'beneficiaryName' => 'Example company s.r.o.',
];
// Take payment-specific data from the order or invoice
$orderInformation = [
'amount' => '49.00',
'currency' => 'EUR',
'country' => 'AT',
'orderNumber' => '202600123',
];
// Select the appropriate QR type
if ($orderInformation['currency'] === 'CZK' && $orderInformation['country'] === 'CZ') {
$generator = new CzechQrPaymentStringGenerator();
} elseif ($orderInformation['currency'] === 'EUR' && $orderInformation['country'] === 'SK') {
$generator = new PayBySquarePaymentStringGenerator();
} elseif ($orderInformation['currency'] === 'EUR') {
$generator = new EpcQrPaymentStringGenerator();
} else {
// Exception, return...
}
$payload = $generator
->setIban($shopConfiguration['iban'])
->setBic($shopConfiguration['bic'])
->setBeneficiaryName($shopConfiguration['beneficiaryName'])
->setAmount($orderInformation['amount'])
->setCurrency($orderInformation['currency'])
->setVariableSymbol($orderInformation['orderNumber'])
->setPaymentNote('Order ' . $orderInformation['orderNumber'])
->generate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.