datalinx / php-upn-qr-generator
QR code generator for Slovenian UPN payment order
Installs: 5 594
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
- ext-mbstring: *
- bacon/bacon-qr-code: ^2.0.7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.14
- khanamiryan/qrcode-detector-decoder: 1.0.5.*
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-31 00:31:05 UTC
README
About
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.
Requirements
- 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)
Installing
Download it with composer:
composer require datalinx/php-upn-qr-generator
Usage
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.
Sample code
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:
Contributing
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.
Developer documentation
- QR code technical specification (see chapter 5.2)
Changelog
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.