1. Go to this page and download the library: Download sashalenz/delivery-auto-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sashalenz / delivery-auto-api example snippets
// config/delivery-api.php
return [
'url' => env('DELIVERY_API_URL', 'https://www.delivery-auto.com/api/v4/Public/'),
// HMAC API keys — issued per company by Delivery-Auto, used for §6 (receipt) endpoints
'public_key' => env('DELIVERY_API_PUBLIC_KEY'),
'secret_key' => env('DELIVERY_API_SECRET_KEY'),
// OPTIONAL — only for §5 (cabinet) and §7 (logs) endpoints, which
use Sashalenz\DeliveryAuto\DeliveryAuto;
// Per-call factory
DeliveryAuto::receipt(
publicKey: $sender->public_key,
secretKey: $sender->secret_key,
)->postCreateReceipts($request);
// Or fluent — handy when you've already obtained a builder
DeliveryAuto::receipt()
->withCredentials($sender->public_key, $sender->secret_key)
->cache(300)
->getSenderList(new GetSenderListRequest);
use Sashalenz\DeliveryAuto\Delivery;
use Sashalenz\DeliveryAuto\ApiModels\Reference\RequestData\GetRegionListRequest;
use Sashalenz\DeliveryAuto\ApiModels\Tracking\RequestData\GetReceiptDetailsRequest;
use Sashalenz\DeliveryAuto\ApiModels\Calculation\RequestData\PostReceiptCalculateRequest;
use Sashalenz\DeliveryAuto\ApiModels\Calculation\RequestData\CategoryRequest;
use Sashalenz\DeliveryAuto\ApiModels\Receipt\RequestData\PostCreateReceiptsRequest;
use Sashalenz\DeliveryAuto\ApiModels\Receipt\RequestData\RegistrationReceiptRequest;
use Sashalenz\DeliveryAuto\Enums\Country;
use Sashalenz\DeliveryAuto\Enums\DeliveryScheme;
use Spatie\LaravelData\DataCollection;
// 1) Lookup — cached for an hour because regions rarely change
$regions = DeliveryAuto::reference()
->cache(3600)
->getRegionList(new GetRegionListRequest(country: Country::UA));
// 2) Calculate cost
$calc = DeliveryAuto::calculation()->postReceiptCalculate(new PostReceiptCalculateRequest(
areasSendId: '4fc948a7-3729-e311-8b0d-00155d037960',
areasResiveId: 'e3ac6f68-3529-e311-8b0d-00155d037960',
warehouseSendId: '1c828aa6-70c8-e211-9902-00155d037919',
warehouseResiveId: 'd908c5e1-b36b-e211-81e9-00155d012a15',
InsuranceValue: 1000000,
CashOnDeliveryValue: 5000,
dateSend: new DateTime('+2 days'),
deliveryScheme: DeliveryScheme::WarehouseDoor,
category: new DataCollection(CategoryRequest::class, [[
'categoryId' => '00000000-0000-0000-0000-000000000000',
'countPlace' => 1, 'helf' => 1, 'size' => 1,
]]),
));
echo $calc->allSumma; // total cost
// 3) Issue a TTN
$created = DeliveryAuto::receipt()->postCreateReceipts(new PostCreateReceiptsRequest(
receiptsList: new DataCollection(RegistrationReceiptRequest::class, [
new RegistrationReceiptRequest(
areasSendId: '4fc948a7-3729-e311-8b0d-00155d037960',
areasResiveId: 'e3ac6f68-3529-e311-8b0d-00155d037960',
dateSend: new DateTime('+2 days'),
category: new DataCollection(CategoryRequest::class, [[
'categoryId' => '00000000-0000-0000-0000-000000000000',
'countPlace' => 1, 'helf' => 1, 'size' => 1,
]]),
deliveryScheme: DeliveryScheme::WarehouseWarehouse,
warehouseSendId: '1c828aa6-70c8-e211-9902-00155d037919',
warehouseResiveId: 'd908c5e1-b36b-e211-81e9-00155d012a15',
receiverName: 'Іванков Іван Іванович',
receiverPhone: '0500000000',
),
]),
));
$ttnNumber = $created[0]->Number;
// 4) Track
$details = DeliveryAuto::tracking()->getReceiptDetails(
new GetReceiptDetailsRequest(number: $ttnNumber)
);
echo $details->Status->label(); // "Зарезервована" if just created
// Either pass credentials each time …
DeliveryAuto::cabinet()->postLogin(new PostLoginRequest(
UserName: '[email protected]', Password: 'secret'
));
// … or set DELIVERY_API_USERNAME / DELIVERY_API_PASSWORD env vars and call:
DeliveryAuto::cabinet()->loginFromConfig();
use Sashalenz\DeliveryAuto\SendingRegisterUrlBuilder;
use Sashalenz\DeliveryAuto\Enums\Culture;
$url = SendingRegisterUrlBuilder::url(
id: '00123456',
type: SendingRegisterUrlBuilder::FORM_TYPE_DETAILED,
culture: Culture::UkUA,
);
// https://www.delivery-auto.com/uk-UA/SharedForms/SendingRegister?id=00123456&type=0