Search by

easydoklad / bysqr

ptrstovka

PHP SDK for encoding and decoding PAY and INVOICE by square documents.

Package info

github.com/easydoklad/bysqr-php

pkg:composer/easydoklad/bysqr

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.2 2025-07-31 16:47 UTC

This package is auto-updated.

Last update: 2026-08-28 09:06:57 UTC


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.