Boxberry 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

Boxberry delivery service integration

Boxberry is a delivery network with focus on pickup points: over 15,000 locations across Russia. API is straightforward: token in header or parameter, JSON response, no OAuth. This simplifies integration but requires attention to error handling — Boxberry sometimes returns errors in 200-response body instead of HTTP statuses.

Basic client structure

class BoxberryClient
{
    private string $baseUrl = 'https://api.boxberry.ru/json.php';

    public function request(string $method, array $params = []): array
    {
        $response = Http::get($this->baseUrl, array_merge([
            'token'  => config('services.boxberry.token'),
            'method' => $method,
        ], $params));

        $data = $response->json();

        if (isset($data['err'])) {
            throw new BoxberryApiException("Boxberry API error [{$method}]: {$data['err']}");
        }

        return $data;
    }
}

Shipping rate calculation

Method DeliveryCosts calculates cost by city code or pickup point ID:

public function calculateDelivery(
    string $targetCity,
    float  $weightKg,
    array  $dimensions,
    float  $declaredValue = 0,
    bool   $toPickupPoint = true
): array {
    $method = $toPickupPoint ? 'DeliveryCosts' : 'DeliveryCostsD2D';

    $response = Http::get($this->baseUrl, [
        'token'      => config('services.boxberry.token'),
        'method'     => $method,
        'weight'     => (int)($weightKg * 1000),
        'target'     => $targetCity,
        'OrderSum'   => (int)$declaredValue,
        'height'     => $dimensions['height'],
        'width'      => $dimensions['width'],
        'depth'      => $dimensions['length'],
    ])->json();

    if (isset($response['err'])) {
        throw new BoxberryApiException($response['err']);
    }

    return [
        'price'      => (float)$response['price'],
        'min_days'   => (int)$response['delivery_period'],
    ];
}

Boxberry separates pickup point delivery and door-to-door courier. Second method available not everywhere.

Cities and pickup points

public function getCitiesWithPoints(): array
{
    return Cache::remember('boxberry_cities', now()->addDay(), function () {
        return $this->request('ListCitiesShort');
    });
}

public function getPickupPoints(?string $cityCode = null): array
{
    $points = $this->request('ListPoints', ['CityCode' => $cityCode]);

    return collect($points)->map(fn($p) => [
        'code'         => $p['Code'],
        'name'         => $p['Name'],
        'address'      => $p['Address'],
        'lat'          => (float)$p['GPS']['Latitude'],
        'lng'          => (float)$p['GPS']['Longitude'],
        'work_time'    => $p['WorkShedule'],
        'cash_allowed' => (bool)($p['HaveCash'] ?? false),
    ])->toArray();
}

Creating parcel

public function createParcel(Order $order): string
{
    $payload = [
        'order_id'       => (string)$order->id,
        'targetstart'    => $order->pickup_point_code,
        'price'          => $order->delivery_cost,
        'payment_sum'    => $order->is_prepaid ? 0 : $order->total,
        'delivery_sum'   => $order->delivery_cost,
        'vid'            => 1, // 1=pickup, 2=courier
        'kurdost'        => ['idx' => $order->zip, 'citi' => $order->city],
        'customer'       => [
            'fio'   => $order->recipient_name,
            'phone' => $order->recipient_phone,
            'email' => $order->recipient_email,
        ],
        'weights'        => [
            'weight' => (int)($order->total_weight_kg * 1000),
        ],
    ];

    $response = Http::post('https://api.boxberry.ru/json.php?token=' . config('services.boxberry.token') . '&method=ParselCreate',
        $payload
    )->json();

    if (isset($response['err'])) {
        throw new BoxberryApiException($response['err']);
    }

    return $response['track'];
}

Tracking

public function trackParcel(string $trackNumber): array
{
    $response = $this->request('ListStatuses', ['ImId' => $trackNumber]);

    return collect($response)->map(fn($s) => [
        'date'    => $s['Date'],
        'name'    => $s['Name'],
    ])->toArray();
}

Limitations

Boxberry works only with Russian addresses. Max weight 31 kg, max side 150 cm. Cash on delivery not available everywhere.

For testing use sandbox token (provided by manager).

Timeline

Rate calculation + pickup points + order creation — 4–6 working days.