Skip to content

Developer notes

Technical reference for developers who customize Baltic Parcel Lockers (Omniva, DPD, Smartposti).

Item Value
Add-on id kv_baltic_lockers
Function prefix fn_kv_baltic_lockers_
Language variables kv_baltic_lockers.*
CSS scope .kv-baltic-lockers (admin), .kv-blk* (storefront)
PHP namespace Tygh\Addons\KvBalticLockers
Shipping service module kv_baltic_lockers, code montonio_pickup, class Tygh\Shippings\Services\KvBalticLockers

Montonio API surface (documentation sources)

Section titled “Montonio API surface (documentation sources)”

Everything below is taken from https://docs.montonio.com ; notes/API-NOTES.md in the source tree has the section of each item. Sandbox access needs a Montonio account, so the automated tests run against a mock built from the documented field lists (live check pending).

Use Call Doc page
Base URLs https://shipping.montonio.com/api/v2 (live), https://sandbox-shipping.montonio.com/api/v2 (test) /api/shipping-v2/overview.md
Authentication Authorization: Bearer <JWT>, HS256, claims accessKey, iat, exp (1 h), signed with the Secret Key /api/shipping-v2/reference.md, Authentication
Carriers and methods GET /shipping-methods /api/shipping-v2/guides/shipping-methods.md
Pickup points GET /shipping-methods/pickup-points?carrierCode=&countryCode= /api/shipping-v2/guides/shipping-methods.md
Create shipment POST /shipments (shippingMethod {type: pickupPoint, id, lockerSize?}, receiver, parcels[].weight in kg, merchantReference, products) /api/shipping-v2/guides/shipments.md
Read shipment GET /shipments/{id} /api/shipping-v2/reference.md
Label file POST /label-files, GET /label-files/{id} (status, labelFileUrl) /api/shipping-v2/guides/labels.md
Webhook POST /webhooks (url, enabledEvents); deliveries are {"payload": "<JWT>"} /api/shipping-v2/guides/webhooks.md
Class Role
Jwt HS256 encode / verify (HS256 only; alg: none refused; exp checked)
Client\BaseClient HTTP (cURL, TLS verification, timeouts), JSON, JWT bearer, error mapping, masked logging, label download without credentials
Client\Api The Montonio calls listed above
Client Client per company, the connection test
Points Pickup point cache (sync, search), method parameters, validation of the shopper’s choice, points stored with the order
Shipments Create shipment (row first, state R), read-back, label file steps, core shipment, discard
Parcel Text cleaning, kilograms, phone split into phoneCountryCode + phoneNumber
RateCalculator Customer price from the method’s own parameters; no HTTP
Webhook Verifies the payload JWT, event ids, webhook registration
Accounts, Secret Keys (test and live) sealed with AES-256-GCM; one account per store owner or per vendor
Queue, Jobs, JobException Job queue (back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock): create_label, track, webhook, sync_points, probe
Log, Config, Access Log with masking, settings, permissions
  • POST /shipments has no idempotency key and the docs offer no lookup by merchantReference. The row is written first with state R; a 4xx removes it, a timeout or 5xx keeps it with an explanation and the job fails permanently. An administrator checks the Montonio Partner System and uses Discard. A per-order lock (GET_LOCK) covers double clicks and a cron run racing a manual click.
  • The label file id is claimed under a lock before the POST /label-files; a second run only reads it.
  • A webhook only wakes the track job; the state always comes from GET /shipments/{id}. The queue key per eventId makes repeated deliveries a no-op. A delivered shipment never moves backwards.
  • The pickup point cache replaces a (carrier, country) list only when the call succeeded and returned points.
Table Purpose
?:kv_baltic_lockers_accounts Keys per company (secrets sealed), last connection check, webhook registration
?:kv_baltic_lockers_log Log
?:kv_baltic_lockers_jobs Queue
?:kv_baltic_lockers_shipments Shipments: Montonio id, tracking, label file id, PDF, state
?:kv_baltic_lockers_cache Pickup points per carrier and country
?:kv_baltic_lockers_order_points Pickup point chosen for an order

PHP: get_order_info (adds order.kv_blk_point), place_order and place_suborders (store the chosen point; Multi-Vendor sub-orders get their own), delete_order, change_order_status_post (queues the shipment at the chosen status), template_document_order_context_init (point text after the method name in documents), init_templater_post (upgrade synchronizer, only while pending). Controllers: checkout.pre (refuses place_order without a point), frontend kv_baltic_lockers.points|point_select|webhook|cron, backend kv_baltic_lockers.*, orders.post.

Templates: storefront checkout:shipping_method (post), index:scripts and index:styles (post), orders:totals_shipping (post); admin orders:tabs_extra (post), addons:manage, addons:tabs_content. The picker is full page cache safe: it is rendered only on the checkout (never cached) and talks to the server by AJAX POST.

The base URL can be overridden for tests in config.local.php (development only):

$config['kv_baltic_lockers_base_url'] = 'http://127.0.0.1:11830';

node tests/mock-server/server.js 11830 starts a stand-in of the Shipping API built from the documented shapes; node tests/e2e/e2e.mjs runs the HTTP end-to-end test against it; php tests/unit.php runs the unit tests.

Admin templates live in design/backend/templates/addons/kv_baltic_lockers/, storefront templates in the theme repository under templates/addons/kv_baltic_lockers/. Do not edit them in a store; they are replaced on update.

  • Shared points cache: the pickup point list is cached once per store (table kv_baltic_lockers_points), not per vendor: in Multi-Vendor every vendor account that is served by the same Montonio store shares the list. The cache is refreshed by the daily job; a point that Montonio removes is dropped on the next refresh.
  • Label download: the label PDF is fetched from the labelFileUrl of the Montonio label file. The Montonio documentation does not say whether that URL needs the account token. The add-on sends no token to it and downloads it as a plain URL; this has to be verified against a live Montonio account (live check pending).
  • Unknown outcome: a timeout, HTTP 408 or HTTP 409 on POST /shipments keeps the shipment row in state “requesting”; the admin checks the Partner System and discards it before creating again.