General description of the software solution, its functionalities, the method of integration with the ATK fiscalization system, and the technologies used.
This page mirrors SOFTWARE-DESCRIPTION.md in the repository
and fulfils the requirement for a general description of the software
solution, its functionalities, the integration method (connection of SEF
with the ATK system), and the technologies used (free format).
This software solution (referred to below as SEF — the fiscalization software integrated into a business' POS/ERP system) is a PHP-based client library and companion test console that implements the integration between a business' point of sale / ERP system and the ATK (Tatimore e Kosovës) central Fiscalization System.
Its purpose is to allow any POS/ERP vendor to:
Deployment model. Rather than distributing this library separately to every client, it will be operated as a single centralized fiscalization service, hosted at https://fiscalization.starsoft.app. Multiple client ERP/POS applications (from different vendors/technologies) will integrate with this one central service over its HTTP API, submitting their sale data in the API/JSON format described below (see section 3.3). The centralized service takes care of building, signing, and submitting the coupons to ATK on behalf of each onboarded business, and returns the resulting QR code data back to the calling ERP.
The repository is organized into the following main parts:
| Folder / file | Purpose |
|---|---|
models.proto, Atk/,
GPBMetadata/
|
Protocol Buffers schema and the generated PHP model classes for
PosCoupon, CitizenCoupon,
CouponItem, Payment,
TaxGroup, QrCoupon, and related enums
(CouponType, PaymentType).
|
fiskalizimi/ModelBuilder.php |
Example/reference builder that constructs sample
CitizenCoupon and PosCoupon
objects.
|
fiskalizimi/CouponFactory.php |
Converts plain associative-array/JSON data (e.g. from an ERP) into validated protobuf coupon objects. |
fiskalizimi/Signer.php |
Wraps OpenSSL ECDSA (SHA-256) digital signing of serialized coupon data. |
fiskalizimi/FiscalizationService.php |
Orchestrates build → serialize → sign → (optionally) submit to
ATK's /citizen/coupon and
/pos/coupon endpoints over HTTPS.
|
fiskalizimi/Program.php |
Reference/example entry point demonstrating the end-to-end flow. |
public/ |
A local, browser-based Test Console used by developers integrating with this library: a raw JSON coupon builder, a guided POS Manual Sale cash-register simulator, and a bilingual (English/Albanian) User Manual. |
onboarder-*.zip |
Cross-platform (Windows/macOS/Linux) companion utility used once
per POS/till to generate its PKI key pair, request a signed
certificate from the ATK Certificate Authority, and export the
private key/certificate used by the
Signer.
|
PosCoupon and CitizenCoupon protobuf
messages from structured sale data: business/POS/branch identifiers,
operator, line items (CouponItem: name, unit, price,
quantity, tax rate, total), payments (Payment: cash,
credit card, voucher, cheque, cryptocurrency, other), and tax groups
(TaxGroup: rate code, taxable base, tax amount).
A (0%, exempt), C (0%,
zero-rated), D (8%, reduced), E
(18%, standard), with automatic aggregation into
TaxGroup totals that must reconcile between the POS
Coupon and the Citizen Coupon.
<data>|<signature>) into the string that
is encoded as the QR code printed on the physical fiscal receipt.
/pos/coupon endpoint at the time of sale, and (for
testing) sending the signed Citizen Coupon to
/citizen/coupon, mimicking what the Citizen Mobile App
does when a customer scans the receipt's QR code.
public/index.html)
— paste or edit raw Citizen/POS coupon JSON, then Build & Sign
(locally only) or Build, Sign & Send (a real call to ATK), and
inspect the resulting Base64 payload, signature, QR string and HTTP
response.
public/pos-sale.html) — a guided cash-register-style
form: add items with a per-line tax rate, take one or more split
payments, and automatically compute subtotals, tax groups and
totals; then build/sign (and optionally send) both the POS Coupon
and its matching Citizen Coupon in one action, rendering a scannable
QR code image.
public/manual.html) — bilingual (English/Albanian)
step-by-step instructions and troubleshooting guidance for using the
tools above.
onboarder) — a
separate cross-platform executable that generates the POS' unique
ECDSA key pair, produces a Certificate Signing Request (CSR),
submits it to the ATK Certificate Authority, and retrieves/exports
the signed certificate and private key (PEM format) used by this
software's Signer class.
Integration between the business' software (SEF) and the ATK central Fiscalization System happens in two phases: a one-time onboarding phase and the recurring, per-sale fiscalization phase.
onboarder utility on the specific
POS machine, using -env=TEST or -env=PROD,
providing the business NUI, Fiscalization Number (obtained from EDI)
and a unique POS ID / Branch ID.
private-key.pem and
signed-certificate.pem.
PRIVATE_KEY environment variable (or a local
dummy-private-key.pem for local testing only).
sequenceDiagram
participant POS as SEF (POS/ERP system)
participant Lib as This software (fiskalizimi/*)
participant ATK as ATK Fiscalization Service
participant App as ATK Citizen Mobile App
POS->>Lib: Sale data (items, payments, tax groups, totals)
Lib->>Lib: Build PosCoupon + CitizenCoupon (Protobuf)
Lib->>Lib: Serialize -> Base64 -> SHA-256 hash -> ECDSA sign (private key)
Lib->>ATK: POST /pos/coupon (Base64 details + signature)
ATK-->>Lib: HTTP 200 / acknowledgement
Lib-->>POS: QR string = Base64(CitizenCoupon) + "|" + Base64(signature)
POS->>POS: Print receipt with embedded QR code
App->>App: Customer scans printed QR code
App->>ATK: POST /citizen/coupon (same QR payload)
ATK->>ATK: Verify signature & reconcile totals against stored POS Coupon
ATK-->>App: Verified / Failed verification
Key points of the integration:
guzzlehttp/guzzle) to ATK's fiscalization endpoints —
https://fiskalizimi.atk-ks.org/pos/coupon and
https://fiskalizimi.atk-ks.org/citizen/coupon.
CouponFactory/FiscalizationService (or to
the bundled public/api.php HTTP endpoint used by the
test console), without needing to understand Protobuf or
cryptography directly.
In production, this software will not be installed and operated separately by each client. Instead, a single instance will be deployed and centrally operated at https://fiscalization.starsoft.app, exposed as an API that all client ERP/POS applications can call, regardless of the ERP vendor or technology stack:
flowchart LR
ERP1[Client ERP / App 1] -->|API data - JSON| Central
ERP2[Client ERP / App 2] -->|API data - JSON| Central
ERP3[Client ERP / App N] -->|API data - JSON| Central
Central[["Centralized fiskalizimi service<br/>fiscalization.starsoft.app"]] -->|Signed POS Coupon| ATK[ATK Fiscalization Service]
Central -->|QR code string + result| ERP1
Central -->|QR code string + result| ERP2
Central -->|QR code string + result| ERP3
How responsibilities are split:
public/api.php (Citizen Coupon / POS Coupon payloads).
They do not need to implement Protobuf serialization, ECDSA signing,
or PKI key storage themselves.
This model lets any number of ERP/POS applications integrate with ATK's fiscalization system through one simple, uniform API, without each of them having to separately implement or maintain the Protobuf/PKI/signing logic described above.
ext-openssl
for cryptography).
composer.json, PSR-4 autoloading).
google/protobuf
Composer package) — schema defined in models.proto,
generated PHP classes in Atk/ and
GPBMetadata/.
openssl_sign
/ openssl_pkey_get_private).
guzzlehttp/guzzle), built on PSR-7
(psr/http-message), PSR-18
(psr/http-client) and PSR-17
(psr/http-factory).
onboarder-windows.zip,
onboarder-macos.zip, onboarder-linux.zip)
for key-pair generation and ATK certificate enrollment.
public/index.html,
public/pos-sale.html, public/manual.html,
app.js, pos-sale.js, i18n.js,
style.css).
qrcode JavaScript library (loaded via CDN) for
rendering a scannable QR image from the signed Citizen Coupon
string.
i18n.js) supporting English
(en) and Albanian (sq).
public/api.php) exposing the build/sign/send flow over
JSON for the browser-based test console.