Integrating 1C-Bitrix with the Dostavista 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.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1175
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • 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
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Integration of 1C-Bitrix with Dostavista delivery service

Dostavista is a crowdsourcing courier delivery service for the "last mile". Couriers operate in real time: requests are accepted within minutes, delivery is completed within hours. The API is open with Russian documentation. Used for stores with fast delivery: food, flowers, pharmaceuticals, electronics.

How Dostavista API works

Dostavista provides a REST API. Authorization is by token in the X-Authorizationtoken header. Main methods:

  • POST /api/business/v1/orders — create a delivery request
  • GET /api/business/v1/orders/{id} — get request status
  • DELETE /api/business/v1/orders/{id} — cancel request
  • GET /api/business/v1/couriers/{id}/location — courier coordinates

The request contains route points (array points): point 0 — where to pick up (warehouse/store), points 1..N — customer delivery addresses. One Dostavista order can contain multiple delivery points — convenient for batch shipments.

Delivery module in Bitrix

A delivery service is connected via a class inheriting from \Bitrix\Sale\Delivery\Services\Base. Key methods:

  • calculateConcrete() — calculates delivery cost. Calls POST /api/business/v1/orders/calculate-price with from/to address and weight.
  • createDelivery() — creates an actual request when the order is confirmed by manager or automatically when status changes.
  • OnSaleStatusOrder handler — hook for order status change in b_sale_order.

Module parameters are stored in b_sale_delivery_service_params: API_TOKEN, SHOP_POINT_ADDRESS (warehouse address), AUTO_CREATE (create request automatically).

Delivery cost calculation

$response = $httpClient->post(
    'https://robot.dostavista.ru/api/business/v1/orders/calculate-price',
    [
        'matter'    => 'Product from store',
        'weight_kg' => $weightKg,
        'points'    => [
            ['address' => $shopAddress],
            [
                'address'  => $deliveryAddress,
                'contact_person' => ['phone' => $phone],
            ],
        ],
    ],
    ['X-Authorizationtoken' => $apiToken]
);
$price = $response['order']['payment_amount'];

The response contains payment_amount — amount to pay in rubles (or local currency). If the address is not determined or is outside the coverage area, the API returns an error — we handle it as "delivery unavailable".

Creating a request when placing an order

The request is created either automatically when the customer selects the delivery method and confirms the order, or manually by the manager from the admin panel. The second option is preferable for stores where inventory verification is needed before sending.

In b_sale_order_props we save DOSTAVISTA_ORDER_ID — the identifier of the request in the Dostavista system. It is needed for:

  • tracking the request status (polling or webhook)
  • canceling the request when the order is canceled in Bitrix
  • providing the customer with a link for courier tracking

Statuses and synchronization

Dostavista supports webhooks: when the request status changes, the system makes a POST request to the specified URL. Configured in the personal account. On the Bitrix side we create a handler that maps Dostavista statuses to order statuses:

Dostavista Status Bitrix Order Status
awaiting_executor Sent for delivery
active Courier in transit
completed Delivered
canceled Canceled
failed Delivery failed

If webhooks are unavailable (no white IP), we implement polling: Bitrix agent queries the status of active requests every 5–10 minutes via GET /api/business/v1/orders/{id}.

Courier tracking

Dostavista returns the courier.latitude/courier.longitude fields in the request during active delivery. For stores that need to show customers the courier's position on a map, we implement an AJAX endpoint on the Bitrix side — it proxies the request to the Dostavista API and returns coordinates.

Timeline

Scope Composition Timeline
Basic integration Cost calculation + request creation 3–4 days
+ Auto-creation + statuses Status hook + mapping + polling 5–6 days
+ Courier tracking AJAX endpoint + widget on site +2 days