1C-Bitrix Integration with Kazpost Delivery Service

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
1C-Bitrix Integration with Kazpost Delivery Service
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

1C-Bitrix Integration with Kazpost Delivery Service

Situation: a client was losing up to 30% of orders due to non-functional delivery to Kazakhstan regions

An online store with a monthly turnover of 5 million tenge approached us. Private couriers delivered only to Almaty and Astana; to district centers, only Kazpost. The built-in Bitrix module failed: cost calculation returned errors, no tracking was available. Manual waybill creation took 2 hours per day, and index errors led to returns. We conducted an audit and decided to completely rewrite the delivery handler via the Kazpost REST API. Savings on manual order processing amounted to 15 hours per month. As a result, after implementation, the client automated 90% of orders, and processing time dropped from 30 minutes to 2 minutes per order. Additionally, we eliminated rounding errors that occurred due to incorrect currency conversion. Now buyers from any city in Kazakhstan can place delivery orders online, and the store receives up-to-date costs considering weight and declared value.

How the Kazpost Integration Works

Kazpost is the national postal operator with 3500+ branches. The API is available to partners after signing a contract. Base URL: https://api.kazpost.kz/api/v1. Authorization via X-Api-Key. Main methods:

  • POST /delivery/calculate — cost calculation
  • POST /shipment/create — create a shipment
  • GET /shipment/{barcode}/track — tracking
  • GET /offices — list of offices by index

Learn more about REST API — the architecture the service is built on.

Cost Calculation

class KazposhtaHandler extends \Bitrix\Sale\Delivery\Services\Base
{
    protected function calculateConcrete(
        \Bitrix\Sale\Shipment $shipment
    ): \Bitrix\Sale\Delivery\CalculationResult {
        $result  = new \Bitrix\Sale\Delivery\CalculationResult();
        $toIndex = $this->getPostIndex($shipment);

        if (!$toIndex) {
            $result->addError(new \Bitrix\Main\Error('Recipient postal index is missing'));
            return $result;
        }

        $response = $this->apiPost('/delivery/calculate', [
            'from_index'     => $this->getOption('SENDER_INDEX'),
            'to_index'       => $toIndex,
            'weight'         => max((int)$shipment->getWeight(), 100),
            'declared_value' => round($shipment->getOrder()->getPrice()),
            'mail_type'      => 'PARCEL',
            'mail_class'     => 'ORDINARY',
        ]);

        if (!empty($response['total_rate'])) {
            $result->setDeliveryPrice((float)$response['total_rate']);
            $min = $response['delivery_days_min'] ?? 3;
            $max = $response['delivery_days_max'] ?? 14;
            $result->setPeriodDescription("{$min}–{$max} days");
        }

        return $result;
    }

    private function getPostIndex(\Bitrix\Sale\Shipment $shipment): ?string
    {
        $props = $shipment->getOrder()->getPropertyCollection();
        $index = $props->getItemByOrderPropertyCode('ZIP')?->getValue();
        return preg_match('/^\d{6}$/', (string)$index) ? $index : null;
    }
}

The postal index is a required field. In the checkout form, we make it mandatory and validate the format (6 digits).

How to Set Up the Delivery Handler

  1. Install the Kazpost delivery module or create your own class extending \Bitrix\Sale\Delivery\Services\Base.
  2. Register the handler in the Bitrix admin panel: Settings → Delivery services → Add.
  3. Add order properties: ZIP (index), ADDRESS, FIO, PHONE. For tracking — a custom property UF_KAZPOST_BARCODE.
  4. Implement the calculateConcrete and createShipment methods as shown above.
  5. Set up an agent for periodic status polling.

Creating a Shipment

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

    $response = $this->apiPost('/shipment/create', [
        'sender' => [
            'index'   => $this->getOption('SENDER_INDEX'),
            'address' => $this->getOption('SENDER_ADDRESS'),
            'name'    => $this->getOption('SENDER_NAME'),
            'phone'   => $this->getOption('SENDER_PHONE'),
        ],
        'recipient' => [
            'index'   => $props->getItemByOrderPropertyCode('ZIP')?->getValue(),
            'address' => $props->getItemByOrderPropertyCode('ADDRESS')?->getValue(),
            'name'    => $props->getItemByOrderPropertyCode('FIO')?->getValue(),
            'phone'   => $props->getItemByOrderPropertyCode('PHONE')?->getValue(),
        ],
        'parcel' => [
            'weight'         => max((int)$shipment->getWeight(), 100),
            'declared_value' => round($order->getPrice()),
            'mail_type'      => 'PARCEL',
            'description'    => 'Goods',
        ],
        'payment_type' => 'PREPAID',
    ]);

    return $response['barcode'] ?? '';
}

We save the shipment barcode in UF_KAZPOST_BARCODE.

Why the Agent Is Mandatory for Tracking

The Kazpost API does not send webhooks — you must poll for statuses. We create a Bitrix agent running every 6 hours. It checks barcodes of orders in status "P" (paid) and when the status is "DELIVERED", it moves the order to "F" (delivered). It is important to set a timeout for API requests (we recommend 10–15 seconds) and log errors so that the agent does not hang if Kazpost fails. A retry mechanism for 500–503 errors helps avoid missing statuses.

function checkKazposhtaStatus(): string {
    $orders = \Bitrix\Sale\Order::getList([
        'filter' => ['=PROPERTY_VAL.UF_KAZPOST_BARCODE' => true, '=STATUS_ID' => 'P'],
        'select' => ['ID']
    ]);
    foreach ($orders as $order) {
        $barcode = $order->getPropertyCollection()->getItemByOrderPropertyCode('UF_KAZPOST_BARCODE')->getValue();
        $track = new KazposhtaHandler()->track($barcode);
        if ($track['status'] === 'DELIVERED') {
            $order->setField('STATUS_ID', 'F');
            $order->save();
        }
    }
    return 'checkKazposhtaStatus();';
}

When the API returns an error (e.g., 400 with body {"error": "Invalid index"}), the handler outputs the message: "The recipient's postal index is incorrect." All requests are logged in /bitrix/logs/kazpost.log for debugging.

Typical Integration Pitfalls

  • Invalid index format — must be 6 digits. Validate on the client side using an input mask and on the server via preg_match('/^\d{6}$/'). On error, display "Please check the recipient's postal index."
  • Missing required order properties (ZIP, ADDRESS, FIO, PHONE) — prevent empty data with mandatory fields in the checkout form. Before making an API request, check with isset() and !empty().
  • Agent not configured for tracking — statuses will not update. Ensure the agent is registered in the admin panel and runs on schedule (cron). Check logs in /bitrix/logs/ if updates are missing.
  • Incorrect API key — returns 401. Verify the key is in environment variables and its expiration date with your Kazpost partner (keys require periodic contract renewal).

Kazpost Delivery Specifics

  • Door-to-door delivery is available only in major cities (Almaty, Astana, Shymkent); elsewhere, delivery is to the post office.
  • EMS is faster and more reliable for urgent shipments to large cities.
  • Kazpost API supports cash on delivery (COD), with a commission of about 2% of the amount.
  • Tariffs are calculated in tenge — check your store's currency settings.

Timeline and Stages

Stage Duration
Development of handler for calculation and shipment creation 4–5 days
Connection of tracking and notifications +2 days
Implementation of COD +1 day
Testing on real orders 1–2 days
Total 7–10 days
Shipment Type mail_type mail_class Description
Standard parcel PARCEL ORDINARY Standard parcel
EMS EMS EMS Expedited delivery
Valuable parcel PARCEL VALUABLE With declared value

What's Included in the Work

  • Development of the delivery handler class (based on \Bitrix\Sale\Delivery\Services\Base)
  • Configuration of order properties: index, address, barcode
  • Creation of the tracking agent
  • Integration with fiscalization (54-FZ) — discussed separately
  • Testing on test and production environments
  • Handover of documentation and access

Integration cost is calculated individually after analyzing your store. We guarantee stable operation. Our experience includes numerous successful integrations of 1C-Bitrix with postal services.

Get a consultation on integration — contact us. We will assess your project in 1 day and prepare a proposal. Request a calculation via email or our feedback form.

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.