easydoklad / bysqr
PHP SDK for encoding and decoding PAY and INVOICE by square documents.
Requires
- php: ^8.2
- symfony/process: ^6.0|^7.0
Requires (Dev)
- pestphp/pest: ^3.7
- symfony/var-dumper: ^7.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
PHP SDK for the bysqr Rust encoder and decoder. The package ships
headless binaries for macOS, Linux and Windows on x86-64 and ARM64.
Requirements
- PHP 8.2 or newer
The package has no runtime Composer dependencies.
Encode PAY or INVOICE
All decimal values are strings so their precision is preserved.
use Bysqr\BankAccount; use Bysqr\Encoder; use Bysqr\Pay; use Bysqr\Payment; use Bysqr\PaymentOption; $pay = new Pay( payments: [ new Payment( paymentOptions: PaymentOption::PAYMENT_ORDER, currencyCode: 'EUR', bankAccounts: [new BankAccount('SK7700000000000000000000')], amount: '12.34', variableSymbol: '20260825', ), ], ); $svg = Encoder::make($pay)->toSvg(); $pngDataUrl = Encoder::make($pay)->toPng(size: 512); $jpegDataUrl = Encoder::make($pay)->toJpeg(size: 512, quality: 90);
Encoder accepts Pay, Invoice, or one independently encoded
InvoiceItems block. PAY and INVOICE branding can be customized with a
Theme containing a LogoLayout, LogoPosition, and LogoColor.
Decode scanned QR content
Image scanning deliberately stays in the consuming application. Pass the text read from the QR code to the decoder; no raw encoded payload API is exposed by the encoder.
use Bysqr\Decoder; $decoder = Decoder::make($textReadFromQrCode); $document = $decoder->toDocument(); // Pay, Invoice, or InvoiceItems $json = $decoder->toJson(); $xml = $decoder->toXml();
Encode and decode INVOICE ITEMS batches
InvoiceItemsList represents the complete ordered list. The batch encoder
splits it into as many branded QR images as required.
use Bysqr\InvoiceItemsDecoder; use Bysqr\InvoiceItemsEncoder; use Bysqr\InvoiceItemsList; $list = new InvoiceItemsList( invoiceId: 'INV-2026', invoiceLines: $invoiceLines, ); $svgImages = InvoiceItemsEncoder::make($list)->toSvg(); // The scanned texts may be supplied in any order. $decodedList = InvoiceItemsDecoder::make($scannedQrTexts)->toList();
An optional parent Invoice can be passed as the second argument to either
batch class to validate the invoice ID and line count.
Development
composer install
composer test
The release checksums of all bundled executables are recorded in
bin/SHA256SUMS.