Download the PHP package sashalenz/uklon-delivery-api without Composer
On this page you can find all versions of the php package sashalenz/uklon-delivery-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sashalenz/uklon-delivery-api
More information about sashalenz/uklon-delivery-api
Files in sashalenz/uklon-delivery-api
Package uklon-delivery-api
Short Description Uklon Delivery Gateway API SDK for Laravel
License MIT
Homepage https://github.com/sashalenz/uklon-delivery-api
Informations about the package uklon-delivery-api
Uklon Delivery API
Laravel SDK for the Uklon Delivery Gateway API —
B2B intra-city courier delivery. Estimate fares, create and track orders, manage
webhooks, all through a small fluent facade with fully-typed
spatie/laravel-data DTOs.
Requirements
- PHP 8.2+
- Laravel 11 / 12 / 13
spatie/laravel-data^4.4
Installation
The service provider is auto-discovered. Optionally publish the config:
Configuration
Uklon issues OAuth credentials (app_uid, client_id, client_secret) per
company, separately for the staging and production gateways. Add them to
your .env:
| Key | Env | Default |
|---|---|---|
staging |
UKLON_DELIVERY_STAGING |
false |
url |
UKLON_DELIVERY_API_URL |
https://deliverygateway.uklon.com.ua/api/v1 |
staging_url |
UKLON_DELIVERY_API_STAGING_URL |
https://deliverygateway.staging.uklon.com.ua/api/v1 |
app_uid |
UKLON_DELIVERY_APP_UID |
— |
client_id |
UKLON_DELIVERY_CLIENT_ID |
— |
client_secret |
UKLON_DELIVERY_CLIENT_SECRET |
— |
webhook_secret |
UKLON_DELIVERY_WEBHOOK_SECRET |
— |
timeout |
UKLON_DELIVERY_TIMEOUT |
10 |
Authentication & token caching
You never call the auth endpoint yourself. Before each request the SDK obtains a
bearer token from POST /auth and caches it (via Laravel's cache) for its
expires_in lifetime, so repeated calls reuse the same token. On a 401 the
cached token is dropped automatically so the next call re-authenticates. This is
handled by TokenManager using your configured cache
driver.
Usage
1. Estimate a fare
Every order starts with a fare estimate. The returned fare_id is required to
create the order and expires (see expires_at).
2. Create an order
3. Track an order
4. List orders
Both lists are cursor-paginated and return an OrderListData (items + next_cursor).
5. Cancel an order
Reference data — cities
A city id is the city value for fare estimates. The list rarely changes, so
cache it:
API surface
| Call | Method | Endpoint |
|---|---|---|
fare()->estimate($request) |
POST | /fares/estimate |
order()->create($request) |
POST | /orders |
order()->get($id) |
GET | /orders/{id} |
order()->getActive() |
GET | /orders/active |
order()->getArchived($limit, $cursor) |
GET | /orders/archived |
order()->getCourierLocation($id) |
GET | /orders/{id}/driver/location |
order()->cancel($id, $request) |
PUT | /orders/{id}/cancel |
webhook()->setForOrder($request) |
POST | /webhooks/order |
webhook()->getForOrder() |
GET | /webhooks/order |
webhook()->deleteForOrder() |
DELETE | /webhooks/order |
webhook()->setForDriver($request) |
POST | /webhooks/driver |
webhook()->getForDriver() |
GET | /webhooks/driver |
webhook()->deleteForDriver() |
DELETE | /webhooks/driver |
city()->all() |
GET | /cities |
Webhooks
Uklon can push order-update and driver-location events to your app. You
register a subscription with a callback URL and a shared key (secret), one of
each per company.
Registering a subscription
Handling incoming events
Parse the request body into typed DTOs in your controller:
Verifying signatures
Every webhook delivery is signed with the key you registered, using
HMAC-SHA256 over the raw request body; the signature is sent in the
X-Signature header. A delivery whose signature does not match must be
ignored as malformed or forged.
The package ships a ready-to-use middleware registered under the uklon-webhook
alias. It reads the secret from uklon-delivery-api.webhook_secret
(UKLON_DELIVERY_WEBHOOK_SECRET) and returns 403 on a bad signature:
Storing secrets elsewhere (e.g. multi-tenant)? Pass a config key to the
middleware: ->middleware('uklon-webhook:services.uklon.order_secret').
Or verify manually with WebhookSignatureValidator:
Enums
| Enum | Values |
|---|---|
OrderStatus |
placed, waiting_for_processing, processing, accepted, arrived, running, returning, completed, suspended, canceled — plus isCourierAssigned(), isFinal() |
CancelReason |
package_not_fit, trunk_occupied, plans_changed, driver_refused_package, driver_low_rating, driver_behavior, driver_was_late, driver_not_arrived, driver_confused_address, driver_ignore, driver_too_far, driver_asked, another_vehicle |
Product |
car, courier |
DropoffStatus |
delivering, arrived, delivered, not_delivered, return_requested, returning, returned |
IdleState |
none, free, paid |
DisabilityType |
none, deaf, hard_hearing |
Caching
Any read can be memoised through the configured cache driver:
Error handling
All errors extend a single base exception:
UklonDeliveryApiUnavailableException extends UklonDeliveryException, so catch
the base type if you don't need to distinguish them.
Testing
License
The MIT License (MIT). See License File.
All versions of uklon-delivery-api with dependencies
illuminate/config Version ^11.0||^12.0||^13.0
illuminate/http Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
spatie/laravel-data Version ^4.4
spatie/laravel-package-tools Version ^1.16