Pathao Courier – Laravel/PHP Package
Pathao Courier is a Bangladeshi courier system for reliable Delivery Business. This is a Laravel/PHP package for pathao courier. This package can be used in laravel or without laravel/php projects. We created this package while working for a project and thought to made it release for all so that it helps. In this blog, I explain how you can easily use Pathao courier API by using laravel/PHP.
Pathao Courier – Laravel/PHP Package source code available via github and released via Packagist as regular regular php composer package.
Requirements
- PHP >=7.4
- Laravel >= 6
Installation
<code class="language-php"> composer require codeboxr/pathao-courier </code>
vendor publish (config)
<code class="language-php"> php artisan vendor:publish --provider="Codeboxr\PathaoCourier\PathaoCourierServiceProvider" </code>
After publish config file setup your credential. you can see this in your config directory pathao.php file
<code class="language-php"> return [ "sandbox" => env("PATHAO_SANDBOX", false), // for sandbox mode use true "client_id" => env("PATHAO_CLIENT_ID", ""), "client_secret" => env("PATHAO_CLIENT_SECRET", ""), "username" => env("PATHAO_USERNAME", ""), "password" => env("PATHAO_PASSWORD", "") ]; </code>
Set .env configuration
<code class="language-php"> PATHAO_SANDBOX=true // for production mode use false PATHAO_CLIENT_ID="" PATHAO_CLIENT_SECRET="" PATHAO_USERNAME="" PATHAO_PASSWORD="" </code>
Usage
1. Get Pathao delivery city list
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier; return PathaoCourier::area()->city(); </code>
2. To get pathao zone list
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::area()->zone($cityId); // City ID </code>
3. To get pathao delivery area list
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::area()->area($zoneId); // Zone ID </code>
4. Create new store
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::store() ->create([ "name" => "", // Store Name "contact_name" => "", // Store contact person name "contact_number" => "", // Contact person number "address" => "", // Store address "secondary_contact" => "", // Contact person secondary number not mandatory "city_id" => "", // Find in city method "zone_id" => "", // Find in zone method "area_id" => "", // Find in Area method ]); </code>
5. Get Store List
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::store()->list(); </code>
6. Create new parcel
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::order() ->create([ "store_id" => "", // Find in store list, "merchant_order_id" => "", // Unique order id "recipient_name" => "", // Customer name "recipient_phone" => "", // Customer phone "recipient_address" => "", // Customer address "recipient_city" => "", // Find in city method "recipient_zone" => "", // Find in zone method "recipient_area" => "", // Find in Area method "delivery_type" => "", // 48 for normal delivery or 12 for on demand delivery "item_type" => "", // 1 for document,2 for parcel "special_instruction" => "", "item_quantity" => "", // item quantity "item_weight" => "", // parcel weight "amount_to_collect" => "", // amount to collect "item_description" => "" // product details ]); </code>
7. Get Order Details
<code class="language-php"> use Codeboxr\PathaoCourier\Facade\PathaoCourier return PathaoCourier::order()->orderDetails($consignmentId); // After successfully create order they given a consignment_id </code>
Contributing
Contributions to the Pathao courier package are welcome. Please note the following guidelines before submitting your pull request.
- Follow PSR-4 coding standards.
- Read Pathao API documentations first
License
Pathao package is licensed under the MIT License.
Copyright 2022 Codeboxr