A complete package for Laravel to use Pathao Courier Merchant API. Setup once and forget about it. You don’t even have to worry about the validation of creating orders, creating a store, or getting calculated price value which are generally a POST request on the Pathao courier end.
With this package, you can get the followingঃ
- Get the city list
- Get the zone list
- Get the area list
- Get the store list
- Create a new Store
- Get order details
- Get calculated price
- Get the token expiration days left and also the expected date of it
⚙️Installation
You can install the package via Composer:
composer require enan/pathao-courier
You can publish the migration file and config file with:
php artisan vendor:publish --tag="pathao-courier-config"
Though Laravel auto discover. If not add the following in config\pathao-courier.php
You can skip this if you want
// add below line in the providers array
Enan\PathaoCourier\PathaoCourierServiceProvider::class,
// add below line in the alias array
'PathaoCourier' => Enan\PathaoCourier\Facades\PathaoCourier::class,
Add the following environment variables to your .env file. You can choose the table name before running the migration. The default is pathao-courier
If you don’t want to use the values in
.env
file you can set values onconfig/pathao-courier
file
PATHAO_DB_TABLE_NAME='pathao-courier'
PATHAO_CLIENT_ID=
PATHAO_CLIENT_SECRET=
PATHAO_SECRET_TOKEN=
🔑Where can I find the value?
Go to your Pathao Developers Api and you’ll find Merchant API Credentials there. And PATHAO_SECRET_TOKEN= you'll be provided it after the successful authentication.
🎫 Setup
Run the migration
php artisan migrate
You have to set the token of the Pathao courier. To set the token run below artisan command. The command will ask for the credentials. This is a one-time process. You don’t have to set up this again. If you want to update the current token and secret you can rerun the command.
You will be provided a secret token here. Please set the token in your .env
file with PATHAO_SECRET_TOKEN=
php artisan set:pathao-courier
🏗 Usage
Add the Facade before using
use Enan\PathaoCourier\Facade\PathaoCourier;
And after this you can use this like
PathaoCourier::GET_CITIES();
For the POST type response the required validation are mentioned before the function like
<required, string>
So here the value should berequired
andstring
use Enan\PathaoCourier\Facade\PathaoCourier;
/**
* 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>
*
* @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>
*
* @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>
*
* @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);
The package is hosted on: Packagist
That’s all. If you have further queries you can reach out to me via
Aside from this, you can visit the following
Top comments (0)