PEK in Bitrix: calculation, order creation, tracking

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Showing 1 of 1All 1626 services
PEK in Bitrix: calculation, order creation, tracking
Medium
~1-2 weeks
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1356
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    943
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    693
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    828
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    731
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    1073

PEK in Bitrix: calculation, order creation, tracking

PEK (First Expedition Company) is one of the key transport companies for cargo and consolidated delivery in Russia. The main specificity of integration: PEK works with cargo from 1 kg and above, the API is tailored to cargo place parameters (length, width, height, weight of each place separately), not to the standard retail format of Bitrix. If you have an online store with large-sized items — sofas, building materials, industrial equipment — PEK often becomes the main carrier.

From our practice: we implemented integration for a chain of building materials stores — calculation became 25% more accurate, and surcharges stopped. With 5+ years of Bitrix experience and over 30 delivery projects, we guarantee a reliable solution.

PEK API features

PEK provides a REST API with authentication via Bearer token. The token is obtained via POST /v2/sign-in with login and password from the personal account. The token does not have a strict TTL (in practice it lives 24–48 hours), but it is recommended to cache it and refresh on receiving a 401.

Key endpoints:

  • POST /v2/calculator — cost and time calculation
  • POST /v2/orders — order creation
  • GET /v2/orders/{id} — order status
  • GET /v2/departments — list of PEK terminals

Base URL: https://api.pek.ru. Documentation is available in the partner's personal account.

How to set up cost calculation?

class PekDeliveryHandler extends \Bitrix\Sale\Delivery\Services\Base
{
    protected function calculateConcrete(
        \Bitrix\Sale\Shipment $shipment
    ): \Bitrix\Sale\Delivery\CalculationResult {
        $result = new \Bitrix\Sale\Delivery\CalculationResult();

        $token   = $this->getApiToken();
        $payload = $this->buildCalcPayload($shipment);

        $response = $this->apiPost('/v2/calculator', $payload, $token);

        if (empty($response['price'])) {
            $result->addError(new \Bitrix\Main\Error('Calculation unavailable'));
            return $result;
        }

        $result->setDeliveryPrice((float)$response['price']);
        $result->setPeriodDescription($response['period_min'] . '–' . $response['period_max'] . ' days');

        return $result;
    }

    private function buildCalcPayload(\Bitrix\Sale\Shipment $shipment): array
    {
        $order = $shipment->getOrder();

        return [
            'senderCityId'    => (int)$this->getOption('SENDER_CITY_ID'),
            'receiverCityId'  => $this->getReceiverCityId($shipment),
            'cargo'           => $this->buildCargoPlaces($shipment),
            'service'         => $this->getOption('SERVICE_TYPE', 'door_door'),
            'declaredValue'   => round($order->getPrice(), 2),
        ];
    }

    private function buildCargoPlaces(\Bitrix\Sale\Shipment $shipment): array
    {
        // PEK requires parameters of each cargo place separately
        $weight = max($shipment->getWeight() / 1000, 1); // g -> kg, minimum 1 kg
        return [
            [
                'weight' => $weight,
                'length' => (int)$this->getOption('DEFAULT_LENGTH', 50),
                'width'  => (int)$this->getOption('DEFAULT_WIDTH', 50),
                'height' => (int)$this->getOption('DEFAULT_HEIGHT', 50),
            ],
        ];
    }
}

Important: PEK calculates based on volumetric weight. If actual weight is less than volumetric (L×W×H / 5000 for air, / 4000 for ground), volumetric is used. For large-sized items this is critical — pass real product dimensions. PEK documentation: volumetric weight = (L×W×H)/5000 for air and /4000 for ground.

How to get cityId and not make mistakes?

PEK uses its own numeric city identifiers. City search:

public function findCityId(string $cityName): ?int
{
    $response = $this->apiGet('/v2/city?name=' . urlencode($cityName), $this->getApiToken());
    return $response[0]['id'] ?? null;
}

Alternative: download the PEK city directory and store the mapping city_name → pek_city_id in an infoblock or custom table. At project start, we recommend this approach — the city search API returns ambiguous results for localities with the same name.

Order creation and terminals

private function createPekOrder(\Bitrix\Sale\Shipment $shipment): string
{
    $order = $shipment->getOrder();
    $props = $order->getPropertyCollection();

    $payload = [
        'senderCityId'   => (int)$this->getOption('SENDER_CITY_ID'),
        'receiverCityId' => $this->getReceiverCityId($shipment),
        'cargo'          => $this->buildCargoPlaces($shipment),
        'service'        => $this->getOption('SERVICE_TYPE', 'door_door'),
        'declaredValue'  => round($order->getPrice(), 2),
        'sender' => [
            'company' => $this->getOption('SENDER_COMPANY'),
            'contact' => $this->getOption('SENDER_CONTACT'),
            'phone'   => $this->getOption('SENDER_PHONE'),
            'address' => $this->getOption('SENDER_ADDRESS'),
        ],
        'receiver' => [
            'contact' => $props->getItemByOrderPropertyCode('FIO')?->getValue(),
            'phone'   => $props->getItemByOrderPropertyCode('PHONE')?->getValue(),
            'address' => $props->getItemByOrderPropertyCode('ADDRESS')?->getValue(),
        ],
    ];

    $response = $this->apiPost('/v2/orders', $payload, $this->getApiToken());
    return (string)($response['id'] ?? '');
}

For door_terminal or terminal_door types, you need to pass the PEK terminal ID. List of terminals: GET /v2/departments. Filter by cityId. On the site, implement a dropdown list of terminals with a map — a widget or custom implementation on Leaflet/Yandex Maps.

Why is it important to pass real dimensions?

Case from our practice: a building materials store, average order weight 50–200 kg, many sheet materials. Problem during implementation: Bitrix stores shipment weight as a single number, but PEK for orders with multiple items of different sizes requires a list of cargo places with dimensions for each. We had to implement a splitting logic: each product in the infoblock has properties DELIVERY_LENGTH, DELIVERY_WIDTH, DELIVERY_HEIGHT. When forming the shipment, each item unit becomes a separate cargo place.

This increased calculation accuracy: deviation from the real cost dropped from ±30% to ±5%, savings on surcharges accounted for up to 15% of the delivery cost. Such detail is a key advantage over the standard approach that uses average weight.

Status tracking

PEK Status Meaning
accepted Accepted for transportation
in_transit In transit
arrived Arrived at destination terminal
out_for_delivery Handed to courier
delivered Delivered
returned Returned

PEK does not have webhooks — only polling. A Bitrix agent requests statuses of active shipments every 4 hours via GET /v2/orders/{id} and updates the order status in the store. Our experience shows that polling is simpler and cheaper than webhooks for low loads (up to 500 shipments per day).

Typical integration mistakes

Mistake Consequence Solution
Passing average dimensions Surcharge up to 30% Specify product properties
Wrong cityId Incorrect calculation Download full directory
No token caching API limits Cache with invalidation on 401
Ignoring volumetric weight Overpricing Account for the coefficient

What is included in turnkey work

  • Development of a delivery handler on PHP 8.1+ with full cycle: calculation → creation → tracking.
  • Setting up PEK city matching (download and mapping).
  • Generation of cargo places based on product properties (if required).
  • Integration of a terminal map on the storefront.
  • Tracking agent and customer status notifications.
  • Documentation and consultation on modifications.

Get a consultation on integration — our engineers are Bitrix certified and have 5+ years of commercial experience. Contact us to evaluate your project.

Timeline

Module Time
Cost calculation + order creation 4–5 days
+ Terminal list + map +2–3 days
+ Splitting into cargo places by product +2 days
+ Status polling + notifications +2 days

We will evaluate your project in 1 day — contact us to discuss details.

Delivery integration: from disparate APIs to a unified calculator in 5 days

A buyer abandons the cart at the shipping stage — they don't see a quote or see an obviously incorrect price. Each such case loses conversion. Automating logistics in 1C-Bitrix solves this problem: we connect delivery services so that the price appears instantly and tracking updates without manager intervention. Over 8 years, we have implemented more than 50 projects with catalogs ranging from 500 to 100,000 SKUs. Average time to connect one carrier is 4 days.

How to accelerate the connection of delivery services to 1C-Bitrix?

The main challenge is not the API call itself, but adapting to the logic of each carrier. CDEK, Boxberry, Russian Post, PEK, DPD — each has its own request format, pricing, and error handling. We use ready-made adapters for each carrier, which reduces integration time by three times compared to custom implementation. Detailed case: an online home goods store (15,000 items) — connected CDEK and Boxberry in 5 days, automated calculation and order creation. Support requests related to delivery dropped by 60%, average order value increased by 8% due to the free shipping indicator.

Why is each carrier's API a separate challenge?

CDEK — volumetric weight and pickup point map

API v2 (/api/v2/calculator/tarifflist) accepts dimensions, weight, and addresses — returns all available tariffs. Pitfalls: volumetric weight is calculated using the formula (L × W × H) / 5000. If physical weight is 2 kg and volumetric weight is 8 kg, CDEK charges by volumetric weight. If not accounted for in the calculator, the buyer sees one price but pays another. The pickup point map is loaded via /deliverypoints. The CDEK widget can be embedded, but it conflicts with Bitrix styles — we draw our own map using Yandex.Maps. Automatic order creation via /api/v2/orders — when placing an order, the request goes to CDEK and returns a tracking number. Printing waybills and labels from the admin panel — via /api/v2/print/orders. Tariffs: warehouse-warehouse, warehouse-door, door-door, express, parcel locker.

Boxberry — extensive pickup point network in regions

The most extensive pickup point network in small towns. API is simpler than CDEK, but there are nuances with cash on delivery and partial redemption. Pickup point map with filters: fitting, card payment, weekend operation. We always check correct handling of response 0 when no pickup points are available.

Russian Post — stability at the cost of speed

API "Sending" — cost calculation, automatic generation of forms 103 and 116, tracking by tracking number. Tariffs: parcel, printed matter, EMS. International shipments. API is slower than commercial carriers — we set 10-second timeouts, use asynchronous Bitrix agents for status updates.

PEK — heavy loads and groupage

When you need to ship a sofa or equipment. Calculation of groupage cargo, insurance, crate. Delivery to terminal and door-to-door. PEK terminal indices are loaded into an infoblock for auto-completion.

DPD — express delivery with time slots

DPD across Russia and abroad. Delivery within a selected time interval, return of signed documents. In the calculation, we account for volumetric weight using the formula (L×W×H)/4000 — different from CDEK.

Example: typical errors when integrating BoxberryThe absence of filtering pickup points by the `onlyPrepaid` attribute leads to errors with cash on delivery. Ignoring the `partialReturn` parameter breaks partial redemption. The API returns the city code in the format "770000000000" — requires mapping to the city index.

How to combine different carriers in a single calculator?

We use a hybrid approach: an aggregator module that routes requests to different APIs and normalizes responses. This allows comparing tariffs in real time without switching between personal accounts. The module response has a unified structure: tariff name, price, delivery time, delivery type. Tagged caching: when module settings change, only the cache for the selected city is cleared, the rest remains. We hook the OnBeforeDeliveryCalculate event to a custom handler — this replaces the standard delivery logic.

Cost calculation: what pitfalls are encountered?

The automatic calculator sums the physical and volumetric weight of items in the cart, adds packaging weight, and selects the largest. Sounds simple, but:

  • Dimensions must be filled for each item. No dimensions — no calculation. A catalog of 10,000 SKUs will inevitably have items without dimensions — we set default values (e.g., 0.1×0.1×0.1 m) and warn the manager via a mail event.
  • Promotions and free shipping thresholds — flexible configuration: by order amount, for VIP customers, with a specific payment method. Implemented via custom cart properties.
  • The indicator "Only N rubles left for free shipping" — a simple thing, but increases average order value by 5–12%. Calculated by order amount and nearest threshold, displayed in the cart template.

How to automate tracking, pickup, and courier delivery?

Tracking. Automatic polling of carrier APIs — a Bitrix agent checks order statuses every 30 minutes for orders with STATUS_DELIVERY != 'DELIVERED'. Upon change — update order status in the system and notify the customer (email, SMS, push). Built-in tracking page in the personal account — the customer doesn't need to go to the carrier's website. Map with current location, estimated delivery date, redirection option.

Pickup. Own pickup points on the map: addresses, schedule, contacts. Search for the nearest by customer address. Real-time availability check, reservation until a specific time. QR code for quick pickup and SMS about readiness.

Courier delivery. Delivery zones with different costs. 2-hour slots, courier schedule management, order limit per slot. Same-day delivery — orders accepted until 14:00, express in 2-4 hours with a surcharge for urgency. Integration with navigation for route optimization.

Multi-warehouse. Multiple warehouses with addresses and service zones. Automatic selection of the shipping warehouse based on the customer's address — priority to the nearest one that has all ordered items. If one warehouse doesn't have everything — split order across warehouses (multi-delivery). Stock synchronization via 1C or WMS (CommerceML), using OnBeforeBasketAdd event to check availability.

Comparison of transport companies

Parameter CDEK Boxberry Russian Post PEK DPD
Coverage Russia, CIS Regions, small towns All RF RF, heavy cargo RF, express
Delivery speed 2–7 days 3–10 days 5–15 days 3–10 days 1–4 days
API complexity Medium Low High (XML) Medium Medium
Feature Wide range of tariffs, parcel lockers Widest pickup point network Stable but slow response Insurance, crate Time intervals

What stages does connecting delivery services consist of?

  1. Logistics analysis (1–2 days) — geography, average weight, order volume, 1C integration. We recommend a combination of carriers.
  2. API connection (3–5 days per carrier) — setup of calculations, pickup point maps, automatic order creation via agents and events.
  3. Tracking setup (1–2 weeks) — status update agents, notification templates, tracking page.
  4. Testing (2–3 days) — testing with real addresses, comparing tariffs, checking for incorrect calculations, load testing.
  5. Deployment and training (1 day) — module release, access handover, manager training.
  6. Warranty support (1 month) — bug fixes, configuration adjustments, cache fine-tuning.

Estimated implementation timelines

Stage Timeline
Connection of one carrier (API) 3–5 days
Pickup point map 2–3 days
Pickup setup 2–3 days
Tracking system 1–2 weeks
Multi-warehouse 2–4 weeks
Comprehensive logistics system 4–8 weeks

Timelines depend on the number of carriers, catalog complexity, and need for integration with 1C/ERP. Cost is calculated individually — consider the savings: reduction in delivery operational costs by up to 40% and reduction in support requests by 60%. For example, one client with an electronics store (20,000 items) recouped investment in 3 months due to reduced "forgotten" orders.

Ready to accelerate your online store's logistics? Contact us — we'll help select the optimal carrier combination for your assortment and budget. Request a consultation, and we'll prepare a proposal within 1 business day.