enan / pathao-courier

Pathao Courier 的完整 Laravel 扩展包

v1.0.1 2024-09-12 04:11 UTC

This package is auto-updated.

Last update: 2024-09-12 04:15:59 UTC


README

Pathao Courier 的完整 Laravel 扩展包

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

为 Laravel 提供了完整的 PathaoCourier 商户 API 扩展包。一次性设置后即可使用。无需担心订单创建、创建店铺或获取计算价格值(通常是在 Pathao 运输端上进行的 POST 请求)的验证。
使用此扩展包,您可以获得以下功能

  • 获取城市列表
  • 获取区域列表
  • 获取地区列表
  • 获取店铺列表
  • 创建店铺
  • 获取订单详情
  • 获取计算价格
  • 获取剩余的令牌过期天数以及预期日期
  • 通过手机号码获取用户成功率 New

它提供了创建订单、创建店铺和获取计算价格的大量验证。因此,您无需担心这些验证。

⚙️ 安装

您可以通过 Composer 安装此扩展包

composer require enan/pathao-courier

您可以使用以下命令发布迁移文件和配置文件

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

尽管 Laravel 会自动发现。如果没有,请在 config\app.php 中添加以下内容。如果您不想这么做,可以跳过这部分。

// add below line in the providers array
Enan\PathaoCourier\PathaoCourierServiceProvider::class,


// add below line in the alias array
'PathaoCourier' => Enan\PathaoCourier\Facades\PathaoCourier::class,

将以下环境变量添加到您的 .env 文件中。在运行迁移之前,您可以选择迁移的表名。默认为 'pathao-courier'

PATHAO_DB_TABLE_NAME='pathao-courier'
PATHAO_CLIENT_ID=
PATHAO_CLIENT_SECRET=
PATHAO_SECRET_TOKEN=

🔑 哪里可以找到值?

转到您的 Pathao 开发者 API,您可以在那里找到 商户 API 凭据。对于 PATHAO_SECRET_TOKEN=,您将在成功认证后获得。

🎫 设置

运行迁移

php artisan migrate

您必须设置 Pathao 运输的令牌。要设置,请运行以下 artisan 命令
该命令将要求凭证。这是一个一次性过程,您无需再次设置。
如果您想更新当前令牌和密钥,可以再次运行该命令。
您将在此处获得一个密钥。请将密钥设置为您的 .env 文件中的 PATHAO_SECRET_TOKEN=

php artisan set:pathao-courier

🏗 使用

在使用之前添加 Facade

use Enan\PathaoCourier\Facade\PathaoCourier;

对于 POST 类型响应,所需验证在函数之前列出,如 <required, string>。因此,这里的值应为必填和字符串类型。

/**
 * To Get the days left of token expiration
 * You'll get the expected date of the expiration and total days left
 *
 * @type <GET>
 */
PathaoCourier::GET_ACCESS_TOKEN_EXPIRY_DAYS_LEFT();

/**
 * To Get the cities
 *
 * @type <GET>
 */
PathaoCourier::GET_CITIES();

/**
 * To Get the Zones
 * @type <GET>
 *
 * @param int $city_id
 */
PathaoCourier::GET_ZONES(int $city_id);

/**
 * To Get the Areas
 * @type <GET>
 *
 * @param int $zone_id
 */
PathaoCourier::GET_AREAS(int $zone_id);

/**
 * To Get the Stores
 * @type <GET>
 *
 * @param int $page
 * $page param is optional. If you want you can implement pagination here.
 */
PathaoCourier::GET_STORES(int $page);

/**
 * To Create Store
 * @type <POST>
 * Pass below mentioned parameter
 *
 * @param $name <required, string>
 * @param $contact_name <required, string>
 * @param $contact_number <required, numeric>
 * @param $address <required, string>
 * @param $city_id <required, numeric>
 * @param $zone_id <required, numeric>
 * @param $area_id <required, numeric>
 */
PathaoCourier::CREATE_STORE($request);

/**
 * To Create Order
 * @type <POST>
 * Pass below mentioned parameter
 *
 * @param $store_id <required, numeric>
 * @param $merchant_order_id    <nullable, string>
 * @param $sender_name  <required, numeric>
 * @param $sender_phone     <required, string/>
 * @param $recipient_name   <required, string>
 * @param $recipient_phone  <required, string>
 * @param $recipient_address    <required, string, Min:10>
 * @param $recipient_city   <required, numeric>
 * @param $recipient_zone   <required, numeric>
 * @param $recipient_area   <required, numeric>
 * @param $delivery_type    <required, numeric> is provided by the merchant and not changeable. 48 for Normal Delivery, 12 for On Demand Delivery"
 * @param $item_type    <required, numeric> is provided by the merchant and not changeable. 1 for Document, 2 for Parcel"
 * @param $special_instruction  <nullable, string>
 * @param $item_quantity    <required, numeric>
 * @param $item_weight  <required, numeric>
 * @param $amount_to_collect    <required, numeric>
 * @param $item_description     <nullable, string>
 */
PathaoCourier::CREATE_ORDER($request);

/**
 * To Get Price Calculation
 * @type <POST>
 * Pass below mentioned parameter
 *
 * @param $delivery_type <required, numeric>
 * @param $item_type <required, numeric>
 * @param $item_weight <required, numeric>
 * @param $recipient_city <required, numeric>
 * @param $recipient_zone <required, numeric>
 * @param $store_id <required, numeric>
 */
PathaoCourier::GET_PRICE_CALCULATION($request);


/**
 * To View Order
 * @type <GET>
 * @param string $consignment_id
 */
PathaoCourier::VIEW_ORDER(string $consignment_id);


/**
 * To Get User's success rate using phone number
 * @type <POST>
 * @param string $phone
 */
PathaoCourier::GET_USER_SUCCESS_RATE($request);

致谢

许可证

MIT 许可证(MIT)。请参阅 许可证文件 了解更多信息。

查看我