kejubayer/pathao-api-integration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kejubayer/pathao-api-integration

Composer 安装命令:

composer require kejubayer/pathao-api-integration

包简介

Laravel Pathao Courier API integration package for creating orders, delivery price calculation, parcel tracking, merchant stores, and webhook status updates.

README 文档

README

A Laravel package for Pathao Courier API integration in Bangladesh. Create Pathao courier orders, calculate delivery price, get stores, cities, zones, and areas, track parcels, cancel orders, and receive parcel status updates through a webhook.

kejubayer/pathao-api-integration provides a Laravel service, facade, config file, route, migration, and model for common Pathao Courier merchant API workflows.

Features

  • Pathao Courier order creation from Laravel
  • Pathao delivery price calculation
  • Pathao merchant store list
  • City, zone, and area lookup
  • Parcel tracking by consignment ID
  • Order cancellation
  • Parcel status webhook route
  • Webhook event storage in database
  • Laravel facade and dependency injection support
  • Laravel package auto-discovery

Keywords

Pathao Laravel package, Pathao Courier API, Pathao API integration, Laravel courier API, Bangladesh courier API, Pathao parcel tracking, Pathao webhook, Pathao delivery charge, Pathao merchant API.

Requirements

  • PHP 7.4 or higher
  • Laravel 8, 9, 10, or 11
  • Guzzle 7

Laravel Pathao API Installation

Install the package with Composer:

composer require kejubayer/pathao-api-integration

Publish the configuration file:

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

Add your Pathao credentials to .env:

PATHAO_BASE_URL=https://api-hermes.pathao.com
PATHAO_CLIENT_ID=your-client-id
PATHAO_CLIENT_SECRET=your-client-secret
PATHAO_USERNAME=your-username (pathao merchant email)
PATHAO_PASSWORD=your-password (pathao merchant password)
PATHAO_WEBHOOK_ROUTE=pathao/webhook/parcel-status

Laravel package auto-discovery will register the service provider and facade automatically.

Run the migrations to create the parcel status webhook table:

php artisan migrate

Pathao API Configuration

The package configuration is stored in config/pathao.php.

Key Environment Variable Description
base_url PATHAO_BASE_URL Pathao API base URL. Defaults to https://api-hermes.pathao.com.
client_id PATHAO_CLIENT_ID Pathao API client ID.
client_secret PATHAO_CLIENT_SECRET Pathao API client secret.
username PATHAO_USERNAME Pathao merchant username.
password PATHAO_PASSWORD Pathao merchant password.
webhook_route PATHAO_WEBHOOK_ROUTE Webhook route path for parcel status callbacks. Defaults to pathao/webhook/parcel-status.

Pathao Courier API Usage

Import the facade:

use Pathao;

Get Access Token

$token = Pathao::getAccessToken();

Create Pathao Courier Order

$stores = Pathao::stores();
$storeId = $stores['data']['data'][0]['store_id'];

$order = Pathao::createOrder([
    'store_id' => $storeId,
    'merchant_order_id' => 'ORD-1001',
    'recipient_name' => 'Customer Name',
    'recipient_phone' => '017XXXXXXXX',
    'recipient_address' => 'House 1, Road 2, Dhaka',
    'delivery_type' => 48,
    'item_type' => 2,
    'special_instruction' => 'Handle with care',
    'item_quantity' => 1,
    'item_weight' => 0.5,
    'amount_to_collect' => 1200,
    'item_description' => 'Product description',
]);

Pathao requires store_id when creating an order. Use Pathao::stores() to get your available stores, then pass the selected store_id to Pathao::createOrder().

Pathao Delivery Price Calculation

$price = Pathao::priceCalculation([
    'store_id' => 12345,
    'item_type' => 2,
    'delivery_type' => 48,
    'item_weight' => 0.5,
    'recipient_city' => 1,
    'recipient_zone' => 2,
]);

Pathao Store List

$stores = Pathao::stores();

Pathao City List

$cities = Pathao::cities();

Pathao Zone List

$zones = Pathao::zones($cityId);

Pathao Area List

$areas = Pathao::areas($zoneId);

Track Pathao Parcel

$tracking = Pathao::trackOrder($consignmentId);

Cancel Pathao Order

$cancelled = Pathao::cancelOrder($consignmentId);

Pathao Parcel Status Webhook

The package registers a POST webhook route for Pathao parcel status updates:

POST /pathao/webhook/parcel-status

Use this URL in your Pathao webhook/callback settings:

https://your-domain.com/pathao/webhook/parcel-status

When Pathao sends a parcel status callback, the package stores the event in the pathao_parcel_statuses table.

Stored columns:

Column Description
consignment_id Consignment ID from the webhook payload, when available.
merchant_order_id Merchant order ID from the webhook payload, when available.
store_id Pathao store ID from the webhook payload.
event Pathao webhook event name, such as order.created.
delivery_fee Delivery fee from the webhook payload.
pathao_updated_at Pathao updated_at value from the webhook payload.
pathao_timestamp Pathao timestamp value from the webhook payload.
payload Full webhook request payload as JSON.
received_at Time the webhook was received.

Example webhook payload:

{
    "consignment_id": "12ABC345",
    "merchant_order_id": "ORD-1001",
    "updated_at": "2024-12-27 23:49:43",
    "timestamp": "2024-12-27T17:49:43+00:00",
    "store_id": 130820,
    "event": "order.created",
    "delivery_fee": 83.46
}

Read saved parcel statuses:

use Kejubayer\PathaoIntegration\Models\PathaoParcelStatus;

$statuses = PathaoParcelStatus::latest()->get();

To customize the webhook URL, change PATHAO_WEBHOOK_ROUTE:

PATHAO_WEBHOOK_ROUTE=api/pathao/parcel-status

Pathao API Data Reference

Pathao Create Order Data

Field Type Required Description
store_id integer Yes Pathao store ID from Pathao::stores().
merchant_order_id string No Your internal order ID.
recipient_name string Yes Customer name.
recipient_phone string Yes Customer phone number.
recipient_secondary_phone string No Additional customer phone number.
recipient_address string Yes Full delivery address.
recipient_city integer No City ID from Pathao::cities().
recipient_zone integer No Zone ID from Pathao::zones($cityId).
recipient_area integer No Area ID from Pathao::areas($zoneId).
delivery_type integer Yes Delivery type ID supported by Pathao.
item_type integer Yes Item type ID supported by Pathao.
special_instruction string No Delivery instruction.
item_quantity integer Yes Number of items.
item_weight number Yes Parcel weight.
amount_to_collect number Yes Cash collection amount. Use 0 for non-COD orders.
item_description string No Parcel or product description.

Pathao Price Calculation Data

Field Type Required Description
store_id integer Yes Pathao store ID.
item_type integer Yes Item type ID supported by Pathao.
delivery_type integer Yes Delivery type ID supported by Pathao.
item_weight number Yes Parcel weight.
recipient_city integer Yes Destination city ID.
recipient_zone integer Yes Destination zone ID.

Laravel Method Reference

Method Description
getAccessToken() Issues an access token using configured Pathao credentials.
createOrder(array $data) Creates a courier order.
priceCalculation(array $data) Calculates delivery price.
stores() Returns available merchant store list.
cities() Returns available city list.
zones($cityId) Returns zones for a city.
areas($zoneId) Returns areas for a zone.
trackOrder($consignmentId) Returns tracking information for a consignment.
cancelOrder($consignmentId) Cancels an order by consignment ID.

Pathao API Endpoints Used

Method HTTP Endpoint
getAccessToken() POST /aladdin/api/v1/issue-token
createOrder() POST /aladdin/api/v1/orders
priceCalculation() POST /aladdin/api/v1/merchant/price-plan
stores() GET /aladdin/api/v1/stores
cities() GET /aladdin/api/v1/city-list
zones() GET /aladdin/api/v1/cities/{cityId}/zone-list
areas() GET /aladdin/api/v1/zones/{zoneId}/area-list
trackOrder() GET /aladdin/api/v1/orders/{consignmentId}/info
cancelOrder() POST /aladdin/api/v1/orders/{consignmentId}/cancel

Dependency Injection

You can also inject the contract instead of using the facade:

use Kejubayer\PathaoIntegration\Contracts\PathaoInterface;

class OrderController
{
    public function store(PathaoInterface $pathao)
    {
        return $pathao->cities();
    }
}

License

This package is open-sourced software licensed under the MIT license.

kejubayer/pathao-api-integration 适用场景与选型建议

kejubayer/pathao-api-integration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「shipping api」 「Delivery API」 「pathao」 「pathao courier」 「pathao api」 「pathao laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 kejubayer/pathao-api-integration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kejubayer/pathao-api-integration 我们能提供哪些服务?
定制开发 / 二次开发

基于 kejubayer/pathao-api-integration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 41
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-12