PHPackages                             texhub/laklak-b2b - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. texhub/laklak-b2b

ActiveLibrary[API Development](/categories/api)

texhub/laklak-b2b
=================

LakLak B2B delivery API SDK for any PHP framework with first-class Laravel support: cities, parcel terminals, pickup points, shipments, label printing and delivery webhooks.

v1.0.2(1mo ago)01MITPHPPHP ^8.2

Since Jun 1Pushed 1mo agoCompare

[ Source](https://github.com/TexhubPro/laklak-b2b)[ Packagist](https://packagist.org/packages/texhub/laklak-b2b)[ Docs](https://texhub.pro)[ RSS](/packages/texhub-laklak-b2b/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

TexHub · LakLak B2B
===================

[](#texhub--laklak-b2b)

**English** · [Русский](README.ru.md)

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/d91d3d1139cf0d8faaa80eeeeac7d3c59c9319e56960ef81c948e4160be4c4c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737376262342e737667)](composer.json)[![Laravel](https://camo.githubusercontent.com/3e9242504354dbb5afd360f9a1ec114126b2caddb73d9e789d9102c3285d2b05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3131253230253743253230313225323025374325323031332d6666326432302e737667)](#laravel)

A clean, framework-agnostic PHP SDK for the **LakLak B2B delivery API** — cities, parcel terminals &amp; pickup points, shipments, label printing and delivery **webhooks** — with first-class **Laravel** support.

> **What's new in v1.0.1**
>
> - Parcel terminals &amp; pickup points now include `visible_id` (e.g. `PT-102`, `PP-042`) and a `cluster` object (`id`, `name`) — read them with `$item['visible_id']` / `$response->get('cluster.name')`.
> - New delivery status `expired` (and `on_the_way`) in `DeliveryStatus`; `isFinal()` now covers `delivered` and `expired`.
> - The *delivery address changed* webhook now carries the full `drop_off_location` — read it via `$event->dropOffLocation()`.

---

Features
--------

[](#features)

- **Addresses** — cities, parcel terminals, pickup points (with search)
- **Shipments** — create, update payment status &amp; weight, label print URL
- **Webhooks** — verify `X-Webhook-Key` + timestamp, parse delivery status &amp; address changes
- **Test / Production** switch · `X-API-Key` auth · typed enums &amp; responses
- Fully unit-tested

---

Installation
------------

[](#installation)

```
composer require texhub/laklak-b2b
```

Requirements: **PHP ≥ 8.2** with `curl`, `json`, `hash`.

---

Quick start
-----------

[](#quick-start)

```
use TexHub\LaklakB2b\LakLak;
use TexHub\LaklakB2b\Enums\Environment;

$laklak = LakLak::make('YOUR_API_KEY', Environment::Test); // Environment::Production when live

// Addresses
$cities = $laklak->addresses()->cities('Dush');
$terminals = $laklak->addresses()->parcelTerminals(cityId: 39720);
$pickups = $laklak->addresses()->pickupPoints(cityId: 39720);

foreach ($cities->data() as $city) {
    echo $city['id'] . ' ' . $city['name'] . PHP_EOL;
}
```

---

Shipments
---------

[](#shipments)

```
use TexHub\LaklakB2b\Requests\ShipmentRequest;
use TexHub\LaklakB2b\Enums\DeliveryType;
use TexHub\LaklakB2b\Enums\PaymentStatus;

$shipment = $laklak->shipments()->create(
    ShipmentRequest::make(
        externalOrderId: 'ORD-100032',
        customerPhone: '+992900123456',
        deliveryType: DeliveryType::ParcelTerminal,
        dropOffLocationId: 2,
        paymentStatus: PaymentStatus::Unpaid,
    )->customerName('Anu Lily')
);

echo $shipment->get('tracking_number');   // B2B-CODE-100001
echo $shipment->get('label_print_url');   // QR label to print & attach

// Update payment status (+ weight when paid):
$updated = $laklak->shipments()->updatePaymentStatus('ORD-100032', PaymentStatus::Paid, '2.5 KG');
echo $updated->get('parcel_terminal_password');

// Print labels for several shipments:
$laklak->shipments()->labelPrintUrl(['B2B-CODE-100001', 'B2B-CODE-100002']);
```

> When `payment_status` is `paid`, a package `weight` is required (validated by the SDK).

---

Webhooks (LakLak → you)
-----------------------

[](#webhooks-laklak--you)

LakLak calls your URL with headers `X-Webhook-Key` (the secret you gave them) and `X-Webhook-Timestamp`.

```
use TexHub\LaklakB2b\Enums\DeliveryStatus;

// Verify, then parse:
$laklak->webhooks()->assertValid(
    $_SERVER['HTTP_X_WEBHOOK_KEY'] ?? null,
    $_SERVER['HTTP_X_WEBHOOK_TIMESTAMP'] ?? null,
);

$event = $laklak->webhooks()->parse(file_get_contents('php://input'));

if ($event->isDeliveryStatusChanged()) {
    $event->trackingNumber();
    $event->externalOrderId();
    $event->deliveryStatus();            // DeliveryStatus enum: pending|picked_up|on_the_way|ready_to_pick|delivered|expired
    $event->deliveryStatus()->isFinal(); // true for delivered/expired
    $event->parcelTerminalPassword();
}

if ($event->isDeliveryAddressChanged()) {
    $event->deliveryType();              // DeliveryType enum
    $event->dropOffLocationId();
    $event->dropOffLocation();           // full location array: id, visible_id, type, cluster, …
}

http_response_code(200); // acknowledge
```

---

Error handling
--------------

[](#error-handling)

```
use TexHub\LaklakB2b\Exceptions\ApiException;

try {
    $laklak->shipments()->create($request);
} catch (ApiException $e) {
    $e->httpStatus;
    $e->isValidationError();   // 422
    $e->errors;                // ['field' => ['message', ...]]
    $e->isUnauthorized();      // 401/403
}
```

---

 Laravel
-------------------------------------------

[](#-laravel)

Auto-discovered. Publish config:

```
php artisan vendor:publish --tag=laklak-b2b-config
```

`.env`:

```
LAKLAK_ENVIRONMENT=test
LAKLAK_API_KEY=your_api_key
LAKLAK_WEBHOOK_SECRET=your_webhook_secret
```

Facade:

```
use TexHub\LaklakB2b\Laravel\LakLak;

$cities = LakLak::addresses()->cities();
LakLak::shipments()->create($request);
```

> Exclude your webhook route from CSRF (`VerifyCsrfToken::$except`).

---

Testing
-------

[](#testing)

```
use TexHub\LaklakB2b\LakLak;
use TexHub\LaklakB2b\Config;
use TexHub\LaklakB2b\Tests\Support\FakeTransport;

$t = (new FakeTransport())->push(['success' => true, 'data' => []]);
$laklak = new LakLak(new Config('KEY'), $t);
$laklak->addresses()->cities(); // assert on $t->last()
```

```
composer install && composer test
```

---

Architecture
------------

[](#architecture)

```
src/
├── LakLak.php               # entry — addresses()/shipments()/webhooks()
├── Config.php               # immutable configuration
├── Enums/                   # Environment, DeliveryType, PaymentStatus, DeliveryStatus
├── Http/                    # Transport, CurlTransport, HttpClient, RawResponse
├── Requests/ShipmentRequest # fluent shipment builder
├── Resources/               # Addresses, Shipments
├── Webhook/                 # WebhookHandler (verify + parse), WebhookEvent
├── Responses/               # Response (ArrayAccess), ListResponse (paginated)
├── Exceptions/              # ApiException, TransportException, …
└── Laravel/                 # ServiceProvider + Facade

```

---

License
-------

[](#license)

MIT © TexHub Pro — built by Mahmudi Shodmehr.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance93

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Total

3

Last Release

34d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/217647751?v=4)[TexHub Pro](/maintainers/TexhubPro)[@TexhubPro](https://github.com/TexhubPro)

---

Top Contributors

[![TexhubPro](https://avatars.githubusercontent.com/u/217647751?v=4)](https://github.com/TexhubPro "TexhubPro (3 commits)")

---

Tags

b2bdeliverylaklaklaravellogisticsphpsdktajikistanphplaravelwebhooksb2bshippingdeliverylogisticsTajikistantexhublaklak

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/texhub-laklak-b2b/health.svg)

```
[![Health](https://phpackages.com/badges/texhub-laklak-b2b/health.svg)](https://phpackages.com/packages/texhub-laklak-b2b)
```

###  Alternatives

[octw/aramex

A Library to integrate with Aramex APIs

2927.7k](/packages/octw-aramex)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
