PHPackages                             centrex/laravel-courier - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. centrex/laravel-courier

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

centrex/laravel-courier
=======================

This is my package courier

v0.2.0(1mo ago)037MITPHPPHP ^8.3CI passing

Since Apr 22Pushed 1mo agoCompare

[ Source](https://github.com/centrex/laravel-courier)[ Packagist](https://packagist.org/packages/centrex/laravel-courier)[ Docs](https://github.com/centrex/courier)[ RSS](/packages/centrex-laravel-courier/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (16)Versions (3)Used By (0)

Laravel Courier
===============

[](#laravel-courier)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1bfba5e300bc7db26006fbacd0c0bee262144e3fbd211248406287d5d8f1ddf7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656e747265782f636f75726965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/courier)[![GitHub Tests Action Status](https://camo.githubusercontent.com/23804daa48f8cfb4bfa435feec5b7e389b746306583c7a5e5652fa61f7891833/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f636f75726965722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/centrex/courier/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/57dcc7fe883badf0a0f89effc0e49f0459b88d0fffcf05ae97e60297c27a7a8f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f636f75726965722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/centrex/courier/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ebb5133ca90c479e7cd4b8de28aa901ad020d3cadb2dff38b82cd9a506bfe9dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63656e747265782f636f75726965723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/courier)

Laravel package for Bangladeshi courier integrations. It provides:

- package API routes for parcel tracking
- a simple facade / root service for common tracking calls
- dedicated service classes for courier-specific operations

Currently included couriers:

- `Pathao`
- `Redx`
- `Steadfast`
- `Rokomari`
- `Sundarban`

Features
--------

[](#features)

- Track parcels through package routes
- Use courier integrations directly from Laravel services
- Grouped config per courier
- Token-based auth support for couriers that require it
- Built-in tests for the package routes

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

[](#installation)

Install via Composer:

```
composer require centrex/courier
```

Publish the config:

```
php artisan vendor:publish --tag="courier-config"
```

Configuration
-------------

[](#configuration)

Published config:

```
return [
    'api_prefix' => 'api',
    'route_prefix' => '',

    'pathao' => [
        'tracking_url' => 'https://merchant.pathao.com/api/v1/user/tracking',
        'sandbox' => env('PATHAO_SANDBOX', true),
        'base_urls' => [
            'sandbox' => env('PATHAO_SANDBOX_BASE_URL', 'https://courier-api-sandbox.pathao.com/'),
            'live' => env('PATHAO_LIVE_BASE_URL', 'https://courier-api.pathao.com/'),
        ],
        'client_id' => env('PATHAO_CLIENT_ID', ''),
        'client_secret' => env('PATHAO_CLIENT_SECRET', ''),
        'username' => env('PATHAO_USERNAME', ''),
        'password' => env('PATHAO_PASSWORD', ''),
        'token_cache_ttl' => (int) env('PATHAO_TOKEN_CACHE_TTL', 7200),
        'auth' => [
            'endpoint' => 'aladdin/api/v1/issue-token',
            'method' => 'post',
            'body_type' => 'json',
            'response_token_key' => 'access_token',
            'header' => 'Authorization',
            'prefix' => 'Bearer',
        ],
    ],

    'redx' => [
        'sandbox' => env('REDX_SANDBOX', false),
        'base_urls' => [
            'sandbox' => env('REDX_SANDBOX_BASE_URL', 'https://sandbox.redx.com.bd/v1.0.0-beta'),
            'live' => env('REDX_LIVE_BASE_URL', 'https://openapi.redx.com.bd/v1.0.0-beta'),
        ],
        'api_access_token' => env('REDX_API_ACCESS_TOKEN', ''),
    ],

    'rokomari' => [
        'tracking_url' => 'https://www.rokomari.com/ordertrack',
    ],

    'steadfast' => [
        'tracking_url' => 'https://steadfast.com.bd/track/consignment',
    ],

    'sundarban' => [
        'tracking_url' => 'https://tracking.sundarbancourierltd.com/Home/getDatabyCN',
    ],
];
```

Example `.env` values:

```
PATHAO_SANDBOX=true
PATHAO_CLIENT_ID=
PATHAO_CLIENT_SECRET=
PATHAO_USERNAME=
PATHAO_PASSWORD=
PATHAO_TOKEN_CACHE_TTL=7200

REDX_SANDBOX=false
REDX_API_ACCESS_TOKEN=
```

Package Routes
--------------

[](#package-routes)

By default the package exposes these endpoints:

EndpointMethodDescription`/api/redx/{tracking_number}``GET`Track Redx parcel`/api/steadfast/{tracking_number}``GET`Track Steadfast parcel`/api/pathao``POST`Track Pathao parcel`/api/rokomari``POST`Track Rokomari parcel`/api/sundarban``POST`Track Sundarban parcelNamed routes:

Route NamePurpose`courier.redx.track`Redx tracking`courier.steadfast.track`Steadfast tracking`courier.pathao.track`Pathao tracking`courier.rokomari.track`Rokomari tracking`courier.sundarban.track`Sundarban tracking### Route Prefix Example

[](#route-prefix-example)

If you want `/api/courier/...` instead of `/api/...`:

```
return [
    'api_prefix' => 'api',
    'route_prefix' => 'courier',
];
```

That produces:

- `/api/courier/redx/{tracking_number}`
- `/api/courier/steadfast/{tracking_number}`
- `/api/courier/pathao`
- `/api/courier/rokomari`
- `/api/courier/sundarban`

Basic Usage
-----------

[](#basic-usage)

### Resolve the main service from the container

[](#resolve-the-main-service-from-the-container)

```
use Centrex\Courier\Courier;

$courier = app(Courier::class);

$redx = $courier->redx('RX123456789');
$steadfast = $courier->steadfast('ST123456789');
$pathao = $courier->pathao('PTH123456', '01700000000');
$rokomari = $courier->rokomari('ORDER123', '01700000000');
$sundarban = $courier->sundarban('CN123456');
```

### Use the facade

[](#use-the-facade)

```
use Centrex\Courier\Facades\Courier;

$tracking = Courier::redx('RX123456789');
```

API Examples
------------

[](#api-examples)

### Redx

[](#redx)

```
curl --request GET http://localhost:8000/api/redx/RX123456789
```

### Steadfast

[](#steadfast)

```
curl --request GET http://localhost:8000/api/steadfast/ST123456789
```

### Pathao

[](#pathao)

```
curl --request POST http://localhost:8000/api/pathao \
  --header "Content-Type: application/json" \
  --data '{
    "tracking_number": "PTH123456",
    "phone": "01700000000"
  }'
```

### Rokomari

[](#rokomari)

```
curl --request POST http://localhost:8000/api/rokomari \
  --header "Content-Type: application/json" \
  --data '{
    "tracking_number": "ORDER123",
    "phone": "01700000000"
  }'
```

### Sundarban

[](#sundarban)

```
curl --request POST http://localhost:8000/api/sundarban \
  --header "Content-Type: application/json" \
  --data '{
    "tracking_number": "CN123456"
  }'
```

Advanced Service Usage
----------------------

[](#advanced-service-usage)

For courier-specific features, resolve the dedicated service class directly.

### PathaoService

[](#pathaoservice)

```
use Centrex\Courier\Services\PathaoService;

$pathao = app(PathaoService::class);

$cities = $pathao->cities();
$zones = $pathao->zones(1);
$areas = $pathao->areas(10);
$stores = $pathao->storeInfo();
$order = $pathao->orderInfo('CONSIGNMENT_ID');
```

Create a store:

```
use Centrex\Courier\Services\PathaoService;

$pathao = app(PathaoService::class);

$store = $pathao->createStore([
    'name' => 'Main Store',
    'contact_name' => 'John Doe',
    'contact_number' => '01700000000',
    'address' => 'Dhaka, Bangladesh',
    'city_id' => 1,
    'zone_id' => 10,
    'area_id' => 100,
]);
```

Create an order:

```
use Centrex\Courier\Services\PathaoService;

$pathao = app(PathaoService::class);

$order = $pathao->createOrder([
    'store_id' => 1,
    'recipient_name' => 'Customer Name',
    'recipient_phone' => '01700000000',
    'recipient_address' => 'Customer Address',
    'delivery_type' => 48,
    'item_type' => 2,
    'item_quantity' => 1,
    'item_weight' => 0.5,
    'amount_to_collect' => 1200,
]);
```

Calculate price:

```
use Centrex\Courier\Services\PathaoService;

$pathao = app(PathaoService::class);

$price = $pathao->priceCalculator([
    'store_id' => 1,
    'item_type' => 2,
    'delivery_type' => 48,
    'item_weight' => 0.5,
    'recipient_city' => 1,
    'recipient_zone' => 10,
]);
```

### RedxService

[](#redxservice)

```
use Centrex\Courier\Services\RedxService;

$redx = app(RedxService::class);

$tracking = $redx->track('RX123456789');
$parcelInfo = $redx->parcelInfo('RX123456789');
```

### RokomariService

[](#rokomariservice)

```
use Centrex\Courier\Services\RokomariService;

$rokomari = app(RokomariService::class);

$html = $rokomari->track('ORDER123', '01700000000');
```

### SteadfastService

[](#steadfastservice)

```
use Centrex\Courier\Services\SteadfastService;

$steadfast = app(SteadfastService::class);

$tracking = $steadfast->track('ST123456789');
```

### SundarbanService

[](#sundarbanservice)

```
use Centrex\Courier\Services\SundarbanService;

$sundarban = app(SundarbanService::class);

$tracking = $sundarban->track('CN123456');
```

Controller Example
------------------

[](#controller-example)

Example controller usage inside your Laravel app:

```
