DPD Delivery Service Integration

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

DPD delivery service integration

DPD is international logistics operator with network across Russia and CIS. API provided via SOAP services, somewhat archaic by modern REST standards, but functional. Official SDK for PHP hides SOAP complexity.

Connection and initialization

use DPD\DPDClient;

$client = new DPDClient(
    username: config('services.dpd.username'),
    password: config('services.dpd.password'),
    clientNumber: config('services.dpd.client_number'),
    test: !app()->isProduction()
);

Test environment works on https://test.dpd.ru. Credentials for testing requested separately from production.

Rate calculation

public function calculateDelivery(
    string $fromCityId,
    string $toCityId,
    float  $weightKg,
    array  $dimensions
): array {
    $response = $this->client->getDPDOrderCost2([
        'pickup'  => ['CityID' => $fromCityId, 'CountryCode' => 'RU'],
        'delivery' => ['CityID' => $toCityId, 'CountryCode' => 'RU'],
        'selfPickup'   => false,
        'selfDelivery' => false,
        'weight'       => $weightKg,
        'serviceCode'  => 'ALL',
    ]);

    return collect($response->return ?? [])
        ->filter(fn($r) => $r->result === 'OK')
        ->map(fn($r) => [
            'service_code' => $r->serviceCode,
            'service_name' => $r->serviceName,
            'cost'         => (float)$r->cost,
            'min_days'     => (int)$r->days,
        ])
        ->toArray();
}

Service codes: BZP (door-door), PCL (to terminal), MAX (large cargo), EXPRESS.

Finding cities

public function findCity(string $cityName): array
{
    $response = $this->client->getCitiesCashPay([
        'cityName' => $cityName,
    ]);

    return collect($response->return ?? [])
        ->map(fn($c) => [
            'id'   => $c->cityId,
            'name' => $c->cityName,
        ])->toArray();
}

Cache cities locally — requests are slow.

Terminals (pickup points)

public function getTerminals(?string $cityId = null): array
{
    $response = $this->client->getTerminalsSelfDelivery2(
        $cityId ? ['cityId' => $cityId] : []
    );

    return collect($response->return ?? [])
        ->map(fn($t) => [
            'id'       => $t->terminalCode,
            'name'     => $t->terminalName,
            'address'  => $t->address,
            'lat'      => (float)($t->geoCoordinates->latitude ?? 0),
            'lng'      => (float)($t->geoCoordinates->longitude ?? 0),
            'phone'    => $t->phone ?? null,
        ])->toArray();
}

Order creation

public function createOrder(Order $order): array
{
    $response = $this->client->createOrder([
        'header' => [
            'datePickup'     => now()->addDay()->format('Y-m-d') . 'T10:00:00',
            'senderAddress'  => [
                'name'    => config('services.dpd.sender_name'),
                'city'    => config('services.dpd.sender_city'),
            ],
            'senderPhone'    => config('services.dpd.contact_phone'),
        ],
        'order' => [[
            'orderNum'        => (string)$order->id,
            'serviceCode'     => $order->dpd_service_code,
            'serviceVariant'  => 'ДД',
            'cargoWeight'     => $order->total_weight_kg,
            'receiverAddress' => [
                'name'        => $order->recipient_name,
                'city'        => $order->shipping_city,
                'contactPhone'=> $order->recipient_phone,
            ],
        ]],
    ]);

    $result = $response->return[0] ?? null;

    if (!$result || $result->status !== 'OK') {
        throw new DpdOrderException('DPD order creation failed');
    }

    return [
        'order_num'     => $result->orderNum,
        'dpd_order_num' => $result->orderNumberInternal,
    ];
}

Tracking

public function trackParcel(string $dpdOrderNum): array
{
    $response = $this->client->getStatesByClient([
        'clientOrderNr' => $dpdOrderNum,
    ]);

    return collect($response->return ?? [])
        ->map(fn($s) => [
            'date'   => $s->transitionTime,
            'status' => $s->newState,
            'city'   => $s->terminalCityName ?? '',
        ])->toArray();
}

Label printing

public function printLabel(string $dpdOrderNum, string $format = 'PDF'): string
{
    $response = $this->client->createLabelFile([
        'OrderRanges' => ['clientOrderNr' => $dpdOrderNum],
        'fileFormat'  => $format,
        'pageSize'    => 'A5',
    ]);

    return base64_decode($response->return->fileContent);
}

Common issues

Responses sometimes return errors in body with status !== 'OK' instead of HTTP status. Need to check each response. City codes not KLADR/FIAS — own mapping needed.

Timeline

Basic integration — 5–7 days. SOAP complexity adds 1–2 days vs REST gateways.