PHPackages                             nayemuf/pathao-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. [API Development](/categories/api)
4. /
5. nayemuf/pathao-courier

ActiveLibrary[API Development](/categories/api)

nayemuf/pathao-courier
======================

Laravel package for Pathao Courier Merchant API integration with caching and rate limiting

v1.0.0(5mo ago)45MITPHPPHP ^8.2

Since Nov 27Pushed 5mo agoCompare

[ Source](https://github.com/nayemuf/pathao-courier)[ Packagist](https://packagist.org/packages/nayemuf/pathao-courier)[ RSS](/packages/nayemuf-pathao-courier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Pathao Courier Package
==============================

[](#laravel-pathao-courier-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/993db47a573d34d9f27b027b77225e567cd00334538d197503dc7ee8b608ebaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6179656d75662f70617468616f2d636f75726965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nayemuf/pathao-courier)[![Total Downloads](https://camo.githubusercontent.com/ca708ce06190ec5a13fe109cc62922682a9a4dae981f5f61ce959ff11ee7fe5b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6179656d75662f70617468616f2d636f75726965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nayemuf/pathao-courier)[![License](https://camo.githubusercontent.com/d46dcf102c35778eb8158032eb57c1ee4727bc087dbeb0652d1550b2e024c390/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e6179656d75662f70617468616f2d636f75726965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nayemuf/pathao-courier)[![Laravel](https://camo.githubusercontent.com/11ba5d99015522487fdaeafecd4de3c8f5e91bafd16811422ad0af48afd92dde/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)

A professional Laravel package for integrating with **Pathao Courier Merchant API**. This package provides a clean, well-structured interface for all Pathao API endpoints with built-in caching, rate limiting, and comprehensive error handling.

✨ Features
----------

[](#-features)

- ✅ **Complete API Coverage** - All 11 Pathao Merchant API endpoints implemented
- ✅ **OAuth 2.0 Authentication** - Automatic token management with intelligent caching
- ✅ **Rate Limiting** - Built-in protection against API abuse (configurable)
- ✅ **Input Validation** - Comprehensive validation before API calls
- ✅ **Error Handling** - Detailed exception messages with field-level errors
- ✅ **Laravel Best Practices** - Service Provider, Facades, and publishable config
- ✅ **Sandbox &amp; Production** - Full support for both environments
- ✅ **Type Safety** - Complete type hints and PHPDoc documentation
- ✅ **Zero Configuration** - Works out of the box with sensible defaults

📋 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 10.0
- Guzzle HTTP Client &gt;= 7.0

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require nayemuf/pathao-courier
```

The package will automatically register its service provider and facade.

⚙️ Configuration
----------------

[](#️-configuration)

### Step 1: Publish Configuration

[](#step-1-publish-configuration)

Publish the configuration file to your `config` directory:

```
php artisan vendor:publish --tag=pathao-config
```

This will create `config/pathao.php` in your Laravel application.

### Step 2: Environment Variables

[](#step-2-environment-variables)

Add the following to your `.env` file:

```
PATHAO_SANDBOX=true
PATHAO_CLIENT_ID=your_client_id
PATHAO_CLIENT_SECRET=your_client_secret
PATHAO_USERNAME=your_email@example.com
PATHAO_PASSWORD=your_password
PATHAO_STORE_ID=your_store_id

# Optional: Rate Limiting
PATHAO_RATE_LIMIT_ENABLED=true
PATHAO_RATE_LIMIT_PER_MINUTE=60
```

### 🧪 Sandbox Credentials (for Testing)

[](#-sandbox-credentials-for-testing)

Pathao provides sandbox credentials for testing:

```
PATHAO_SANDBOX=true
PATHAO_CLIENT_ID=7N1aMJQbWm
PATHAO_CLIENT_SECRET=wRcaibZkUdSNz2EI9ZyuXLlNrnAv0TdPUPXMnD39
PATHAO_USERNAME=test@pathao.com
PATHAO_PASSWORD=lovePathao
```

### 📍 Test Store IDs (Sandbox)

[](#-test-store-ids-sandbox)

You can use any of these store IDs for testing in the sandbox environment:

Store IDStore Name`149049`double discount`149048`Test Marchent`149047`Test Seller`149046`mo`149045`DCC Online`149044`Becho`149043`Sandbox Store`149042`Elvis Lowe`149040`Partha`149039`Partha Store**Note:** To get the full list of available stores, use:

```
$stores = PathaoCourier::store()->list();
```

🚀 Usage
-------

[](#-usage)

### Create an Order

[](#create-an-order)

```
use Nayemuf\PathaoCourier\Facades\PathaoCourier;

$orderData = [
    'store_id' => 149043, // Your store ID
    'merchant_order_id' => 'ORD-12345', // Your internal order ID
    'recipient_name' => 'John Doe',
    'recipient_phone' => '01712345678', // 11 digits, starts with 01
    'recipient_address' => 'House 123, Road 4, Sector 10, Uttara, Dhaka-1230',
    'delivery_type' => 48, // 48 for normal, 12 for on-demand
    'item_type' => 2, // 1 for document, 2 for parcel
    'item_quantity' => 1,
    'item_weight' => '0.5', // in kg (0.5 to 10)
    'amount_to_collect' => 1000, // 0 for non-COD orders
    'item_description' => 'Product description', // Optional
];

try {
    $response = PathaoCourier::order()->create($orderData);
    // Response contains: consignment_id, invoice_id, etc.
} catch (\Nayemuf\PathaoCourier\Exceptions\PathaoException $e) {
    // Handle error
    logger()->error('Pathao order creation failed', [
        'message' => $e->getMessage(),
        'errors' => $e->getErrors(),
    ]);
}
```

### Create Bulk Orders

[](#create-bulk-orders)

```
$orders = [
    [
        'store_id' => 149043,
        'merchant_order_id' => 'ORD-001',
        'recipient_name' => 'John Doe',
        'recipient_phone' => '01712345678',
        'recipient_address' => 'Address 1',
        'delivery_type' => 48,
        'item_type' => 2,
        'item_quantity' => 1,
        'item_weight' => '0.5',
        'amount_to_collect' => 1000,
    ],
    [
        'store_id' => 149043,
        'merchant_order_id' => 'ORD-002',
        'recipient_name' => 'Jane Doe',
        'recipient_phone' => '01712345679',
        'recipient_address' => 'Address 2',
        'delivery_type' => 48,
        'item_type' => 2,
        'item_quantity' => 1,
        'item_weight' => '1.0',
        'amount_to_collect' => 0,
    ],
];

$response = PathaoCourier::order()->createBulk($orders);
```

### Get Order Information

[](#get-order-information)

```
// Get order short info
$orderInfo = PathaoCourier::order()->getInfo($consignmentId);

// Get full order details
$orderDetails = PathaoCourier::order()->getDetails($consignmentId);
```

### Get Cities, Zones, and Areas

[](#get-cities-zones-and-areas)

```
// Get all cities
$cities = PathaoCourier::area()->getCities();

// Get zones for a city
$zones = PathaoCourier::area()->getZones($cityId);

// Get areas for a zone
$areas = PathaoCourier::area()->getAreas($zoneId);
```

### Calculate Delivery Price

[](#calculate-delivery-price)

```
$priceData = [
    'store_id' => 149043,
    'item_type' => 2, // 1 for document, 2 for parcel
    'delivery_type' => 48, // 48 for normal, 12 for on-demand
    'item_weight' => 0.5, // in kg
    'recipient_city' => 1, // City ID
    'recipient_zone' => 298, // Zone ID
];

$price = PathaoCourier::price()->calculate($priceData);
// Returns: price, distance, etc.
```

### Store Management

[](#store-management)

```
// Get list of all stores
$stores = PathaoCourier::store()->list();

// Get single store info
$storeInfo = PathaoCourier::store()->getInfo($storeId);

// Create a new store
$storeData = [
    'name' => 'My Store',
    'contact_name' => 'John Doe',
    'contact_number' => '01712345678',
    'address' => 'Store Address',
    'city_id' => 1,
    'zone_id' => 298,
    'area_id' => 1234,
];
$newStore = PathaoCourier::store()->create($storeData);
```

### Refresh Access Token

[](#refresh-access-token)

```
// Refresh access token using refresh token
$response = PathaoCourier::refreshToken($refreshToken);
// Returns: ['access_token' => '...', 'refresh_token' => '...', 'expires_in' => 432000]
```

📚 API Reference
---------------

[](#-api-reference)

### Authentication

[](#authentication)

- `PathaoCourier::refreshToken(string $refreshToken)` - Refresh access token using refresh token

### Order API

[](#order-api)

- `PathaoCourier::order()->create(array $orderData)` - Create a new order
- `PathaoCourier::order()->createBulk(array $orders)` - Create multiple orders at once
- `PathaoCourier::order()->getInfo(string $consignmentId)` - Get order short info
- `PathaoCourier::order()->getDetails(string $consignmentId)` - Get full order details

### Area API

[](#area-api)

- `PathaoCourier::area()->getCities()` - Get list of all cities
- `PathaoCourier::area()->getZones(int $cityId)` - Get zones for a specific city
- `PathaoCourier::area()->getAreas(int $zoneId)` - Get areas for a specific zone

### Store API

[](#store-api)

- `PathaoCourier::store()->create(array $storeData)` - Create a new store
- `PathaoCourier::store()->list()` - Get list of all stores
- `PathaoCourier::store()->getInfo(int $storeId)` - Get merchant store info

### Price API

[](#price-api)

- `PathaoCourier::price()->calculate(array $priceData)` - Calculate delivery price

⚠️ Error Handling
-----------------

[](#️-error-handling)

The package throws `Nayemuf\PathaoCourier\Exceptions\PathaoException` for all API errors:

```
use Nayemuf\PathaoCourier\Exceptions\PathaoException;

try {
    $response = PathaoCourier::order()->create($orderData);
} catch (PathaoException $e) {
    // Get error message
    $message = $e->getMessage();

    // Get field-level validation errors (if any)
    $errors = $e->getErrors(); // Array of validation errors

    // Get HTTP status code
    $code = $e->getCode();

    // Log or handle error
    logger()->error('Pathao API Error', [
        'message' => $message,
        'errors' => $errors,
        'code' => $code,
    ]);
}
```

🔒 Caching
---------

[](#-caching)

Access tokens are automatically cached using Laravel's cache system to reduce API calls. Tokens are cached for their full lifetime (5 days) minus 5 minutes for safety. The cache key is configurable in `config/pathao.php`.

🚦 Rate Limiting
---------------

[](#-rate-limiting)

The package includes built-in rate limiting to prevent API abuse. By default, it limits requests to 60 per minute. You can configure this in your `config/pathao.php`:

```
'rate_limit' => [
    'enabled' => true,
    'requests_per_minute' => 60,
],
```

✅ Validation Rules
------------------

[](#-validation-rules)

All input data is validated before sending to the API:

- **Recipient name**: 3-100 characters
- **Recipient phone**: Exactly 11 characters (must start with 01)
- **Recipient address**: 10-220 characters
- **Item weight**: 0.5-10 kg
- **Delivery type**: 48 (Normal) or 12 (On Demand)
- **Item type**: 1 (Document) or 2 (Parcel)
- **Item quantity**: Minimum 1

🧪 Testing
---------

[](#-testing)

Run the test suite:

```
composer test
```

Or run PHPUnit directly:

```
./vendor/bin/phpunit
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

### Guidelines

[](#guidelines)

Before contributing, please ensure you follow these guidelines:

1. **Follow PSR-4 Autoloading Standard** - All code must adhere to [PSR-4](https://www.php-fig.org/psr/psr-4/) autoloading standards
2. **Refer to Pathao Official Documentation First** - Always check the [Pathao API Documentation](https://developer.pathao.com/) before implementing new features or changes
3. **Maintain Code Quality** - Follow existing code style, add proper type hints, and include PHPDoc comments
4. **Write Tests** - Include tests for new features or bug fixes
5. **Update Documentation** - Update README, CHANGELOG, and inline documentation as needed

### Contribution Process

[](#contribution-process)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes following the guidelines above
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request with a clear description of your changes

📝 Changelog
-----------

[](#-changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

🔗 Links
-------

[](#-links)

- [Packagist](https://packagist.org/packages/nayemuf/pathao-courier)
- [GitHub Repository](https://github.com/nayemuf/pathao-courier)
- [Pathao API Documentation](https://developer.pathao.com/)

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

👤 Author
--------

[](#-author)

**Nayem Uddin**

- Email:
- GitHub: [@nayemuf](https://github.com/nayemuf)
- LinkedIn: [@nayemuf](https://linkedin.com/in/nayemuf/)

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Pathao for providing the Merchant API
- Laravel community for the amazing framework

🐛 Reporting Issues
------------------

[](#-reporting-issues)

For issues, questions, or feature requests, please open an issue on [GitHub](https://github.com/nayemuf/pathao-courier/issues).

💝 Support
---------

[](#-support)

If this package helps you, please consider giving it a ⭐ on [Packagist](https://packagist.org/packages/nayemuf/pathao-courier) or [GitHub](https://github.com/nayemuf/pathao-courier).

---

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance71

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

164d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2da5217a515cbf963e81d1f6112d67aa71a9fe43b181ad20235346081fb26d38?d=identicon)[nayemuf](/maintainers/nayemuf)

---

Top Contributors

[![nayemuf](https://avatars.githubusercontent.com/u/119859626?v=4)](https://github.com/nayemuf "nayemuf (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nayemuf-pathao-courier/health.svg)

```
[![Health](https://phpackages.com/badges/nayemuf-pathao-courier/health.svg)](https://phpackages.com/packages/nayemuf-pathao-courier)
```

###  Alternatives

[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)

PHPackages © 2026

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