Using this library you can generate a QR code for a UPN payment order, which is used in Slovenia. The technical specification is defined by the Slovenian Bank Association.
This library can output a PNG, SVG or EPS image to a local file.
The code is fully tested, including OCRing of the generated QR code.
- PHP >= 7.4
- mbstring and iconv PHP extensions
- imagick PHP extension, but only if you want to generate PNG (raster) QR code images — not required for vector formats (SVG, EPS)
Download it with composer:
composer require datalinx/php-upn-qr-generator
In order to generate a QR code you need to pass at least these parameters:
- recipientIban
- recipientCity
The minimal required parameters are based on the Android applications ISPS and Banka IN offered by the Intesa Sanpaolo Bank Slovenia.
See class docblocks for accepted parameter formats and length.
This code shows a typical use-case. See the UPNQR class for more stuff you can put into the QR code.
// Create an instance of the UPNQR class
$QR = new UPNQR();
// Set payer
$QR ->setPayerName("Janez Novak")
->setPayerStreetAddress("Lepa ulica 33")
->setPayerCity("Koper");
// Set recipient
$QR ->setRecipientIban("SI56020360253863406")
->setRecipientName("Podjetje d.o.o.")
->setRecipientStreetAddress("Neka ulica 5")
->setRecipientCity("Ljubljana");
// Transaction details
$QR ->setAmount(55.58)
->setRecipientReference("SI081236-17-34565")
->setPurposeCode("GDSV")
->setPaymentPurpose("Plačilo spletnega naročila št. 304");
try {
// Generate QR code image of type svg (use .png for PNG images)
$QR->generateQrCode("./qrcode.svg");
} catch (Exception $e) {
throw new Exception("Error generating QR code image: " . $e->getMessage());
}
The above code will generate this QR code:
If you have some suggestions how to make this package better, please open an issue or even better, submit a pull request.
Should you want to contribute, please see the development guidelines in the DataLinx PHP package template.
- QR code technical specification (see chapter 5.2)
All notable changes to this project are automatically documented in the CHANGELOG.md file using the release workflow, based on the release-please GitHub action.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
For all this to work, commit messages must follow the Conventional commits specification, which is also enforced by a Git hook.