Belpochta 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

Belpochta delivery service integration

Belpochta is Belarus national postal operator. For e-commerce working with Belarusian customers, integration ensures delivery nationwide. API less mature than Russian services, so implementation uses official tariff tables.

Tariff-based calculation

class BelpochtaTariffCalculator
{
    private array $domesticParcels = [
        0.1  => 3.20, 0.5  => 4.30, 1.0  => 5.10,
        2.0  => 6.40, 5.0  => 9.60, 10.0 => 13.50,
    ];
    private float $courierSurcharge = 3.50;

    public function calculate(float $weightKg, bool $toDoor = false): array
    {
        $basePrice = null;
        foreach ($this->domesticParcels as $maxWeight => $price) {
            if ($weightKg <= $maxWeight) {
                $basePrice = $price;
                break;
            }
        }

        $total = $basePrice;
        if ($toDoor) $total += $this->courierSurcharge;

        return [
            'base'       => $basePrice,
            'courier_fee'=> $toDoor ? $this->courierSurcharge : 0,
            'total'      => round($total, 2),
            'currency'   => 'BYN',
            'min_days'   => 3,
            'max_days'   => 14,
        ];
    }
}

Corporate API integration

For clients with contract:

class BelpochtaApiClient
{
    private string $baseUrl = 'https://api.belpochta.by/v1';

    public function calculateShipping(array $params): array
    {
        $response = Http::withHeaders([
            'Authorization' => 'Bearer ' . config('services.belpochta.api_key'),
        ])->post($this->baseUrl . '/calc', [
            'from_index'   => $params['from_index'],
            'to_index'     => $params['to_index'],
            'weight'       => (int)($params['weight_kg'] * 1000),
        ]);

        return $response->json();
    }

    public function createOrder(array $orderData): array
    {
        $response = Http::post($this->baseUrl . '/orders', $orderData);
        if ($response->failed()) {
            throw new BelpochtaException('Order creation failed');
        }
        return $response->json();
    }
}

Postal codes and city detection

Belarusian indexes are 6-digit, format 2XXXXX. Minsk ranges 220000220137:

public function validateBelarusPostalCode(string $code): bool
{
    return (bool)preg_match('/^2[0-9]{5}$/', $code);
}

public function getCityByIndex(string $postalCode): ?string
{
    return Cache::remember("belpochta_city_{$postalCode}", now()->addWeek(), function () {
        return Http::get('https://api.belpochta.by/v1/address/by-index', [
            'index' => $postalCode,
        ])->json('city');
    });
}

EMS Belpochta

For urgent shipments, EMS service available. Delivery: 1–3 working days to regional centers:

public function calculateEms(float $weightKg): array
{
    $emsTariffs = [
        0.5  => 8.50,  1.0  => 10.20,  2.0  => 13.40,
        5.0  => 19.60, 10.0 => 28.90,  20.0 => 42.50,
    ];

    $price = null;
    foreach ($emsTariffs as $maxWeight => $tariff) {
        if ($weightKg <= $maxWeight) { $price = $tariff; break; }
    }

    return [
        'cost'     => $price,
        'currency' => 'BYN',
        'min_days' => 1,
        'max_days' => 3,
    ];
}

Currency conversion

If store uses RUB but Belpochta uses BYN:

public function convertToDisplayCurrency(float $byn): float
{
    $rate = Cache::remember("exchange_BYN_RUB", now()->addHour(), function () {
        return Http::get('https://api.nbrb.by/exrates/rates/RUB')->json('Cur_OfficialRate');
    });
    return round($byn * $rate, 2);
}

Timeline

Basic calculator with tariff tables — 2–3 days. Full API integration (requires contract) — 5–7 days.