定制 devrkb21/pathao-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

devrkb21/pathao-laravel

Composer 安装命令:

composer require devrkb21/pathao-laravel

包简介

A complete Laravel package for Pathao Courier API integration with built-in validation, webhook handling, location caching, and Artisan commands.

README 文档

README

Latest Version on Packagist Total Downloads License

A complete Laravel package for Pathao Courier Merchant API integration. Setup once and forget about it — built-in validation, webhook handling, location caching, API logging, and powerful Artisan commands.

✨ Features

  • ✅ Client Credentials authentication with automatic token refresh
  • ✅ Sandbox & Production environment support
  • ✅ Cities, Zones, Areas — with bulk endpoints & local database caching
  • ✅ Store management (List & Create)
  • ✅ Order management (Create, View, Bulk Create, Price Calculation)
  • ✅ Merchant profile info retrieval
  • ✅ User success rate by phone number
  • ✅ Webhook signature validation with Laravel event dispatching
  • ✅ API request & webhook logging to database
  • ✅ Built-in request validation for all POST endpoints
  • ✅ Artisan commands for setup, sync, status, and diagnostics

⚙️ Installation

composer require devrkb21/pathao-laravel

Publish the config file:

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

Laravel auto-discovers the service provider. If needed, manually register:

// config/app.php — providers array
devrkb21\PathaoLaravel\PathaoLaravelServiceProvider::class,

// config/app.php — aliases array
'PathaoLaravel' => devrkb21\PathaoLaravel\Facades\PathaoLaravel::class,

Environment Variables

Add the following to your .env file:

PATHAO_CLIENT_ID=
PATHAO_CLIENT_SECRET=
PATHAO_SECRET_TOKEN=
PATHAO_WEBHOOK_INTEGRATION_SECRET=
PATHAO_SANDBOX=false
PATHAO_DB_TABLE_NAME=pathao-courier

Where to find credentials? Go to Pathao Developers API → Merchant API Credentials.

Setup

Run the migration:

php artisan migrate

Set up authentication (one-time process):

php artisan pathao:setup

You will be provided a secret_token. Set it in your .env as PATHAO_SECRET_TOKEN.

🏗 Usage

use devrkb21\PathaoLaravel\Facades\PathaoLaravel;

Location APIs

// Get all cities
PathaoLaravel::GET_CITIES();

// Get zones for a city
PathaoLaravel::GET_ZONES(int $city_id);

// Get areas for a zone
PathaoLaravel::GET_AREAS(int $zone_id);

// Bulk fetch all zones / areas
PathaoLaravel::GET_ZONES_BULK();
PathaoLaravel::GET_AREAS_BULK();

Store APIs

// List stores (with optional pagination)
PathaoLaravel::GET_STORES(int $page = 1);

// Create a new store
// Required: name, contact_name, contact_number, address, city_id, zone_id, area_id
PathaoLaravel::CREATE_STORE($request);

Order APIs

// Create an order
// Required: store_id, recipient_name, recipient_phone, recipient_address,
//           delivery_type (48=Normal, 12=On-Demand), item_type (1=Document, 2=Parcel),
//           item_quantity, item_weight, amount_to_collect
PathaoLaravel::CREATE_ORDER($request);

// Create multiple orders in bulk
PathaoLaravel::CREATE_ORDERS_BULK(array $orders);

// View order details
PathaoLaravel::VIEW_ORDER(string $consignment_id);

// Calculate delivery price
PathaoLaravel::GET_PRICE_CALCULATION($request);

Merchant & User APIs

// Get merchant profile info
PathaoLaravel::GET_MERCHANT_INFO();

// Get user success rate by phone
PathaoLaravel::GET_USER_SUCCESS_RATE($request);

// Check token expiry
PathaoLaravel::GET_ACCESS_TOKEN_EXPIRY_DAYS_LEFT();

🔧 Artisan Commands

Command Description
pathao:setup Set up authentication credentials and generate secret token
pathao:merchant-info Verify API connection and display merchant profile info
pathao:sync-locations Fetch and cache all cities, zones, and areas into local database
pathao:status Display connection config, token status, and cached location counts
pathao:clear-cache Clear cached location tables

🔔 Webhook Integration

The package automatically registers a webhook endpoint at:

POST /api/pathao/webhook

Webhook Verification: To verify your webhook URL on Pathao's merchant dashboard, the package automatically captures the required challenge token UUID and echoes it back in the X-Pathao-Merchant-Webhook-Integration-Secret header. If necessary, you can manually set this UUID in your .env file as PATHAO_WEBHOOK_INTEGRATION_SECRET.

Signature Validation: Incoming requests are validated against X-Pathao-Signature header using your PATHAO_SECRET_TOKEN.

Event Dispatching: On valid webhook, the package dispatches a PathaoWebhookReceived event. Listen for it in your application:

use devrkb21\PathaoLaravel\Events\PathaoWebhookReceived;

Event::listen(PathaoWebhookReceived::class, function ($event) {
    $payload = $event->payload;

    // Map webhook data to your order status updates
    // $payload['event'], $payload['consignment_id'], $payload['order_status'], etc.
});

Logging: All webhook calls (valid and invalid) are logged to the pathao_webhook_logs table. All API requests are logged to pathao_api_logs.

📦 Database Tables

After running migrations, the following tables are created:

Table Purpose
pathao-courier (configurable) Stores access tokens and secret keys
pathao_cities Cached cities directory
pathao_zones Cached zones directory
pathao_areas Cached areas directory
pathao_api_logs API request/response history
pathao_webhook_logs Webhook callback history

Credits

License

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

devrkb21/pathao-laravel 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-10