QR Payment String Generator is a pure-PHP library for generating the payment strings stored inside payment QR codes. It supports three formats:
- Slovak PAY by square
- Czech QR Platba (SPD 1.0)
- EPC / SEPA credit transfer QR codes
The package creates only the payment payload, not a QR image. Pass the generated string to any QR code renderer that fits your application. There are many good libraries and services available for that purpose.
The project was created because the available PHP implementations either required some external libraries to be installed in the system, required commonly blocked functions like proc_open or did not produce a scannable PAY by square code. This is dependency-free and usable anywhere.
- PHP 7.4 to 8.5
- No libraries, no frameworks, no extra services, no special functions
- Requires only the common
mbstringPHP extension for UTF-8 length validation
| Format | Required fields | Practical minimum | Supported setters |
|---|---|---|---|
| Slovak PAY by square | IBAN, beneficiary name | IBAN, amount, beneficiary name, variable symbol, payment note | setBic, setCurrency, setDueDate, setVariableSymbol, setConstantSymbol, setSpecificSymbol, setOriginatorsReferenceInformation, setPaymentNote, setInvoiceId, setBeneficiaryAddressLine1, setBeneficiaryAddressLine2 |
| Czech QR Platba | IBAN | IBAN, amount, variable symbol | setAmount, setBeneficiaryName, setCurrency, setDueDate, setVariableSymbol, setConstantSymbol, setSpecificSymbol, setPaymentNote, setPaymentType |
| EPC / SEPA QR | IBAN, beneficiary name | IBAN, amount, beneficiary name, payment reference or payment note | setAmount, setBic, setPaymentNote, setOriginatorsReferenceInformation, setPurpose, setInformation |
All formats expose the same fluent API. You may call every setter on any generator; values not supported by the selected format are safely ignored.
| Setter | Example data | PAY by square | Czech QR Platba | EPC / SEPA |
|---|---|---|---|---|
setIban() |
'SK8075000000004022466192' |
Required | Required | Required |
setAmount() |
'125.50' |
Used if set | Used if set | Used if set |
setBeneficiaryName() |
'Example company s.r.o.' |
Required | Used if set | Required |
setBic() |
'CEKOSKBX' |
Used if set | Ignored | Used if set |
setCurrency() |
'EUR' or 'CZK' |
Used if set | Used if set | Ignored; EPC is always EUR |
setDueDate() |
'2026-08-15' |
Used if set | Used if set | Ignored |
setVariableSymbol() |
'001234' |
Used if set | Used if set | Ignored |
setConstantSymbol() |
'0558' |
Used if set | Used if set | Ignored |
setSpecificSymbol() |
'1234567890' |
Used if set | Used if set | Ignored |
setOriginatorsReferenceInformation() |
'202600123' |
Used if set | Ignored | Ignored |
setStructuredReference() |
'RF18539007547034' |
Ignored | Ignored | Used if set; payment note is ignored |
setPaymentNote() |
'Invoice 202600123' |
Used if set | Used if set | Used as unstructured remittance information |
setInvoiceId() |
'202600123' |
Used if set | Ignored | Ignored |
setBeneficiaryAddressLine1() / setBeneficiaryAddressLine2() |
'Main Street 1' |
Used if set | Ignored | Ignored |
setPaymentType() |
'IP' |
Ignored | Used if set | Ignored |
setPurpose() |
'GDDS' |
Ignored | Ignored | Used if set |
setInformation() |
'Thank you' |
Ignored | Ignored | Used if set |
Note
For EPC, setStructuredReference() is a structured creditor reference (a structured payment reference for the recipient): a standardized machine-readable reference beginning with RF, for example RF18539007547034. setPaymentNote() is unstructured remittance information (a free-text payment reference for the recipient), such as Invoice 202600123. When both are set, the structured reference takes precedence and the payment note is ignored. setInformation() is beneficiary-to-originator information (a message from the recipient to the payer).
Pass the values in their business form. The generators normalize IBAN and BIC whitespace and letter case, validate format-specific limits, and throw InvalidArgumentException when a value is invalid.
$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 DateTimeInterfacePayment QR formats require an exact decimal representation with a period as the decimal separator. PHP floats cannot safely represent many decimal values: for example, 0.1 + 0.2 can internally become 0.30000000000000004. Pass an exact string such as '125.50' instead.
If your application stores money in minor units, for example 12550 cents, convert it to an exact decimal string at the application boundary before calling setAmount(). Do not pass a value formatted with a comma, currency symbol, or thousands separator.
| Setter | Type | Accepted format |
|---|---|---|
setIban() |
string |
IBAN; spaces are accepted and removed. |
setBic() |
string or null |
BIC / SWIFT; spaces are accepted and removed. |
setAmount() |
string or null |
Decimal number with .; never a float. |
setBeneficiaryName() / setPaymentNote() |
string |
Plain UTF-8 text; do not URL-encode it yourself. |
setVariableSymbol() / setConstantSymbol() / setSpecificSymbol() |
string or null |
Digits only; use strings to preserve leading zeroes. |
setDueDate() |
string, DateTimeInterface, or null |
YYYY-MM-DD when passing a string. |
composer require hlavtox/qr-payment-string-generatoruse 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();