steadfast-courier/steadfast-courier-laravel-package

SteadFast Courier Limited 的完整 Laravel 包

1.1.3 2024-09-29 04:59 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:01:37 UTC


README

SteadFast Courier Limited 的完整 Laravel 包

这是一个用于 SteadFastCourier 系统的 Laravel/PHP 包。此包可用于 Laravel 项目。您可以使用此包进行无头/rest 实现以及 blade 或常规模式开发。我们在进行项目开发时创建了此包,并认为将其发布供所有人使用将有助于他人。此包作为常规 php composer 包 提供。

功能

  1. 下订单
  2. 批量订单创建
  3. 检查配送状态
  4. 检查当前余额

安装

您可以通过 composer 安装此包

composer require steadfast-courier/steadfast-courier-laravel-package

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

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

发布配置文件后,设置您的凭证。您可以在配置目录中的 steadfast-courier.php 文件中看到这些信息

 "base_url" => env('STEADFAST_BASE_URL', 'https://portal.steadfast.com.bd/api/v1'),
 "api_key" => env('STEADFAST_API_KEY', 'your-api-key'),
 "secret_key" => env('STEADFAST_SECRET_KEY', 'your-secret-key'),

设置 .env 配置

STEADFAST_BASE_URL= "https://portal.steadfast.com.bd/api/v1"
STEADFAST_API_KEY = "your-api-key"
STEADFAST_SECRET_KEY ="your-secret-key"

1. 下订单

use SteadFast\SteadFastCourierLaravelPackage\Facades\SteadfastCourier;

$orderData = 

[

    'invoice' => '123456',

    'recipient_name' => 'John Doe',

    'recipient_phone' => '01234567890',

    'recipient_address' => 'Fla# A1,House# 17/1, Road# 3/A, Dhanmondi,Dhaka-1209',

    'cod_amount' => 1000,

    'note' => 'Handle with care'

];

$response = SteadfastCourier::placeOrder($orderData);

响应

{

    "status": 200,

    "message": "Consignment has been created successfully.",

    "consignment": {

        "consignment_id": 1424107,

        "invoice": "Aa12-das4",

        "tracking_code": "15BAEB8A",

        "recipient_name": "John Doe",

        "recipient_phone": "01234567890",

        "recipient_address": "Fla# A1,House# 17/1, Road# 3/A, Dhanmondi,Dhaka-1209",

        "cod_amount": 1000,

        "status": "in_review",

        "note": "Deliver within 3PM",

        "created_at": "2021-03-21T07:05:31.000000Z",

        "updated_at": "2021-03-21T07:05:31.000000Z"

    }

}

2. 批量订单创建

use SteadFast\SteadFastCourierLaravelPackage\Facades\SteadfastCourier;

$ordersData =

[

    [

        'invoice' => '123456',

        'recipient_name' => 'John Doe',

        'recipient_phone' => '01234567890',

        'recipient_address' => '123 Main St',

        'cod_amount' => 1000,

        'note' => 'Handle with care'

    ],

    [

        'invoice' => '789012',

        'recipient_name' => 'Jane Smith',

        'recipient_phone' => '09876543210',

        'recipient_address' => '456 Elm St',

        'cod_amount' => 1500,

        'note' => 'Fragile'

    ]

];

$response = SteadfastCourier::bulkCreateOrders($ordersData);

响应

[

    {

        "invoice": "230822-1",

        "recipient_name": "John Doe",

        "recipient_address": "House 44, Road 2/A, Dhanmondi, Dhaka 1209",

        "recipient_phone": "0171111111",

        "cod_amount": "0.00",

        "note": null,

        "consignment_id": 11543968,

        "tracking_code": "B025A038",

        "status": "success"

    },

    {

        "invoice": "230822-1",

        "recipient_name": "John Doe",

        "recipient_address": "House 44, Road 2/A, Dhanmondi, Dhaka 1209",

        "recipient_phone": "0171111111",

        "cod_amount": "0.00",

        "note": null,

        "consignment_id": 11543969,

        "tracking_code": "B025A1DC",

        "status": "success"

    }
]

如果数据中存在任何错误,您将收到类似以下响应

响应

[

    {

    "invoice": "230822-1",

    "recipient_name": "John Doe",

    "recipient_address": "House 44, Road 2/A, Dhanmondi, Dhaka 1209",

    "recipient_phone": "0171111111",

    "cod_amount": "0.00",

    "note": null,

    "consignment_id": null,

    "tracking_code": null,

    "status": "error"

    },

]

3. 检查配送状态

use SteadFast\SteadFastCourierLaravelPackage\Facades\SteadfastCourier;

$consignmentId = 123456;

$invoice = "230822-1";

$trackingCode = "B025A3FA";

$response1 = SteadfastCourier::checkDeliveryStatusByConsignmentId($consignmentId);

$response2 = SteadfastCourier::checkDeliveryStatusByTrackingCode($trackingCode);

$response3 = SteadfastCourier::checkDeliveryStatusByInvoiceId($invoice);

响应:{

    "status": 200,

    "delivery_status": "in_review"

}

配送状态

以下是 SteadFast Courier API 返回的可能配送状态及其描述

  • pending:包裹尚未交付或取消。
  • delivered_approval_pending:包裹已交付,但等待管理员批准。
  • partial_delivered_approval_pending:包裹部分交付,但等待管理员批准。
  • cancelled_approval_pending:包裹已取消,但等待管理员批准。
  • unknown_approval_pending:未知待处理状态。需要联系支持团队。
  • delivered:包裹已交付并添加余额。
  • partial_delivered:包裹部分交付并添加余额。
  • cancelled:包裹已取消并更新余额。
  • hold:包裹被保留。
  • in_review:订单已下,等待审核。
  • unknown:未知状态。需要联系支持团队。

您可以使用这些状态来跟踪您的包裹进度并采取适当的行动。

4. 检查当前余额

use SteadFast\SteadFastCourierLaravelPackage\Facades\SteadfastCourier;

$response = SteadfastCourier::getCurrentBalance();

响应

{

    "status": 200,

    "current_balance": 0

}

支持有关此包的任何问题或疑问,请通过 GitHub 打开一个问题。

致谢

许可证

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