Developer notes
Technical reference for developers who customize Furgonetka Shipping & Labels.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_furgonetka |
| Function prefix | fn_kv_furgonetka_ |
| Language variables | kv_furgonetka.* |
| CSS scope | .kv-furgonetka (admin), .kv-fg* (storefront) |
| PHP namespace | Tygh\Addons\KvFurgonetka |
| Shipping services | kv_furgonetka module, codes courier and point; class Tygh\Shippings\Services\KvFurgonetka |
Structure
Section titled “Structure”| Class | Role |
|---|---|
Client\BaseClient |
HTTP (cURL, TLS verification, timeouts), JSON, OAuth2 authorization code with a single use refresh token renewed under a database lock, error mapping, masked logging |
Client\Api |
The Furgonetka calls (see the table below); every call names its section in notes/API-NOTES.md |
Client |
Client per company, the connection test |
Accounts, Secret |
Credentials (test and live application) and the sealed token document, AES-256-GCM; one account per store owner or per vendor |
Config, Access |
Settings, owner mode, who may see and manage what; Access::moneyDenied() is the server side denial for a vendor in owner mode |
Labels |
The package flow: add to basket, order, check, discard, cancel, label PDF. Row first, per-order lock, re-read inside the lock |
Shipments |
Rows, tracking state mapping, side effects (order status, core shipment) claimed with conditional UPDATEs |
RateCalculator |
Checkout quote: request body, cache, negative cache, PLN conversion, price rules |
Points, Carriers |
Pick-up point search and validation, the carrier list of the account |
Pl |
Postcode, phone, IBAN checksum, recipient name rules |
Queue, Jobs, JobException |
Job queue (back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock); jobs create_label, track_batch, keepalive |
Log |
Event log with masking (maskBody() masks request and response bodies key by key), filters, CSV, retention |
Furgonetka calls
Section titled “Furgonetka calls”Source of every item: the OpenAPI specification at https://furgonetka.pl/api/rest and the OAuth guide https://furgonetka.pl/api/oauth (sections in notes/API-NOTES.md).
| Purpose | Call |
|---|---|
| Authorize / tokens | GET /oauth/authorize, POST /oauth/token (Basic client id:secret, form body; refresh token is single use) |
| Carriers of the account | GET /account/services |
| Quote | POST /packages/calculate-price |
| Points | POST /points/map |
| Add to basket (client UUID) | PUT /create-package-command/{uuid}, GET /create-package-command/{uuid} |
| Order (client UUID, the money step) | PUT /order-commands/{uuid}, GET /order-commands/{uuid} |
| Package | GET /packages/{id}, DELETE /packages/{id} |
| Cancel ordered | PUT /cancel-command/{uuid}, GET /cancel-command/{uuid} |
| Label | `GET /packages/{id}/label?label[page_format]=a4 |
| Tracking | GET /packages/{id}/tracking |
Not used: the account webhook (account wide, payload not described in the specification), pick-ups, returns, protocols, the Giełda auctions and customs data (the add-on ships domestic parcels).
Row states (kv_furgonetka_shipments.status)
Section titled “Row states (kv_furgonetka_shipments.status)”I creating (add package command sent, outcome unknown), W in the Furgonetka basket (no money), Q ordering (order command sent, outcome unknown, money may have moved), R ordered, T on its way, D delivered, P problem, X cancelled. create_uuid, order_uuid and cancel_uuid are the command identifiers chosen by the shop and stored before the request.
Rules the code keeps (and tests/e2e/e2e.mjs checks): the add package and the order step are separate dispatches (create_label, buy_label, order_label), never a posted flag; every step runs under Idempotency::lock('label:<order>') and re-reads the row inside the lock; an unanswered request is read back with GET by its UUID and GET /packages/{id} before anything is sent again; I and Q rows are only changed by “Check again” (read only) or, for a row without a package id, by an explicit discard.
Database tables
Section titled “Database tables”| Table | Purpose |
|---|---|
?:kv_furgonetka_accounts |
Credentials per company (secrets sealed), last connection check, token document |
?:kv_furgonetka_log |
Log |
?:kv_furgonetka_jobs |
Queue |
?:kv_furgonetka_shipments |
Packages, tracking |
?:kv_furgonetka_services |
Carriers of the account (service ids) |
?:kv_furgonetka_points |
Pick-up points Furgonetka returned (the validation source for the checkout choice) |
?:kv_furgonetka_order_points |
The point chosen at the checkout, per order |
Hooks used
Section titled “Hooks used”PHP: change_order_status_post (optional automation, basket only), get_order_info and template_document_order_context_init (the point in documents), place_order, place_suborders, delete_order (the point per order). Controllers: checkout.pre (an order with a point method needs a point). Template hooks: checkout/shipping_method.post (point picker), orders/totals_shipping.post, index/styles.post, index/scripts.post; admin orders/tabs_extra.post.
What the specification leaves open (not verified, no sandbox account was available)
Section titled “What the specification leaves open (not verified, no sandbox account was available)”- Nothing in this add-on was run against a Furgonetka sandbox or live account: the tests use a mock built from the specification’s schemas (
tests/fixtures/SOURCES.md). PUT /order-commands/{uuid}: the schema listsuuidandrequest_collectionas required but describes onlypackages,label,only_order_pickupandskip_email_send. The add-on sendsuuid,request_collection(the setting “Ask for a courier pick-up when ordering”, default off),packagesandlabel.- The answer of
GETfor a command UUID that was never sent is not described; the add-on treats any error as “not readable” and leaves the row unclear. POST /packages/calculate-priceneedsstreetfor the receiver in the schema: at the checkout the street of the shipping address is sent when known, else the city (the quote does not depend on it).- The parcel
typeis required in a nested schema but is a package level field; the add-on sendstype: packageat the package level only. - The public tracking link is the one
GET /packages/{id}returns inparcels[].tracking_url; no fixed link pattern is documented. - The examples of
cancel_successandpackage_idin the specification are strings; the add-on accepts both strings and real booleans.
Test the HTTP layer without Furgonetka
Section titled “Test the HTTP layer without Furgonetka”The base URL can be overridden for tests in config.local.php (development only):
$config['kv_furgonetka_base_url'] = 'http://127.0.0.1:11871';node tests/mock-server/server.js 11871 starts the mock (failure injection knobs are listed in its header); node tests/e2e/e2e.mjs --store <url> --db <db> --dir <store dir> runs the HTTP end-to-end test (it refuses to run unless the store points at 127.0.0.1 or localhost); php tests/unit.php runs the unit tests (also with php83).