Skip to content

Developer notes

Technical reference for developers who customize Sameday Courier & easybox Lockers.

Item Value
Add-on id kv_ro_couriers
Function prefix fn_kv_ro_couriers_
Language variables kv_ro_couriers.*
CSS scope .kv-ro-couriers
PHP namespace Tygh\Addons\KvRoCouriers
Preset shipping (generated by kv new --kind integration)
Class Role
Client\BaseClient HTTP (cURL, TLS verification, timeouts), JSON, OAuth2 client-credentials with an encrypted token cache, error mapping, masked logging
Client\Api The Sameday calls: authenticate, pickup points, services, lockers, estimate-cost, awb, label, status, delete
Awb Pure mapping of an order to the Sameday AWB / estimate form fields; AWB status to shipment status
Lockers, Points Cached easybox list (daily refresh) and the locker of an order (cart, order, suborder)
Shipments, RateCalculator, Installer AWB creation with a pending row first, tracking, price estimate, the two shipping services
Client Client per company, the connection test
Accounts, Secret Credentials (test and live) sealed with AES-256-GCM; one account per store owner or per vendor
Config, Access Settings, owner mode, who may see and manage what
Queue, Jobs, JobException Job queue: back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock; handlers in Jobs::handle(), recurring work in Jobs::schedule()
Log Event log with masking, filters, CSV, retention
Webhook Signature check and event ids; the controller kv_ro_couriers.webhook?c=<account> stores the event as a job
Table Purpose
?:kv_ro_couriers_accounts Credentials per company (secrets sealed), last connection check, token cache
?:kv_ro_couriers_log Log
?:kv_ro_couriers_jobs Queue
?:kv_ro_couriers_shipments Labels and tracking

PHP hooks: change_order_status_post (create the label at a chosen status), get_order_info, place_order, place_suborders, delete_order (the chosen locker), init_templater_post (self-healing upgrade, only while pending). Template hooks: checkout:shipping_method (the locker picker, checkout only), orders:totals_shipping (locker on the order page), orders:tabs_extra (admin tab), index:scripts / index:styles.

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

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

node tests/mock-server/server.js 11830 starts a local stand-in of the provider API; 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_ro_couriers/. Do not edit them in a store; they are replaced on update.

Sameday API reference (what is used and where it is documented)

Section titled “Sameday API reference (what is used and where it is documented)”

Sameday publishes its API through the official PHP SDK (https://github.com/sameday-courier/php-sdk, src/Sameday/Requests/*.php, src/Sameday/Responses/*.php, README.md) and the SDK reference under docs/reference/. The complete table with file names is in notes/API-NOTES.md.

Call Endpoint SDK source
Authenticate POST /api/authenticate, headers X-AUTH-USERNAME, X-AUTH-PASSWORD, form remember_me; answer token, expire_at; later calls send X-AUTH-TOKEN; one re-login on 401 / 403 SamedayAuthenticateRequest, SamedayAuthenticateResponse, SamedayClient
Pickup points / services / lockers GET /api/client/pickup-points, /api/client/services, /api/client/lockers with page, countPerPage SamedayGet*Request, SamedayRequestPaginationTrait
Estimate POST /api/awb/estimate-cost (form) -> amount, currency, time SamedayPostAwbEstimationRequest / Response
AWB POST /api/awb (form, nested fields); answer awbNumber, awbCost, parcels[] SamedayPostAwbRequest / Response
Label `GET /api/awb/download/{awb}/{A4 A6}`
Status GET /api/client/awb/{awb}/status -> expeditionSummary.delivered / canceled, expeditionStatus SamedayGetAwbStatusHistoryRequest / Response
Delete DELETE /api/awb/{awb} SamedayDeleteAwbRequest

Test and live hosts: https://sameday-api.demo.zitec.com and https://api.sameday.ro (SDK README, SamedayClient::API_HOST). Known gaps, not guessed: Sameday documents no JSON examples (the unit and e2e fixtures are built from the keys the SDK reads, see tests/fixtures/SOURCES.md); the meaning of supportedPayment, the service codes and the exact status codes are not in the SDK; no public tracking page is stored (the AWB number is shown); the demo environment needs credentials from Sameday, so no call to the real service was made.