<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Moammer Farshid Enan</title>
    <description>The latest articles on DEV Community by Moammer Farshid Enan (@enan).</description>
    <link>https://dev.to/enan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1234286%2F20833286-2352-4e95-8bee-1cd34cb9d841.jpeg</url>
      <title>DEV Community: Moammer Farshid Enan</title>
      <link>https://dev.to/enan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/enan"/>
    <language>en</language>
    <item>
      <title>Pathao Courier API Integration with Laravel</title>
      <dc:creator>Moammer Farshid Enan</dc:creator>
      <pubDate>Fri, 15 Dec 2023 19:23:50 +0000</pubDate>
      <link>https://dev.to/enan/pathao-courier-api-integration-with-laravel-195h</link>
      <guid>https://dev.to/enan/pathao-courier-api-integration-with-laravel-195h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QCswhW46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6tnfz3w3s7mt1om0a19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QCswhW46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p6tnfz3w3s7mt1om0a19.png" alt="Pathao Courier API Integration with Laravel by enan, Laravel Package for Pathao Courier API, Pathao Courier Package, Pathao Courier API" width="800" height="406"&gt;&lt;/a&gt;&lt;br&gt;
A complete package for Laravel to use &lt;a href="https://merchant.pathao.com/"&gt;Pathao Courier Merchant API&lt;/a&gt;. 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.&lt;/p&gt;

&lt;p&gt;With this package, you can get the followingঃ&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get the city list&lt;/li&gt;
&lt;li&gt;Get the zone list&lt;/li&gt;
&lt;li&gt;Get the area list&lt;/li&gt;
&lt;li&gt;Get the store list&lt;/li&gt;
&lt;li&gt;Create a new Store&lt;/li&gt;
&lt;li&gt;Get order details&lt;/li&gt;
&lt;li&gt;Get calculated price&lt;/li&gt;
&lt;li&gt;Get the token expiration days left and also the expected date of it&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;⚙️Installation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You can install the package via Composer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require enan/pathao-courier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can publish the migration file and config file with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan vendor:publish --tag="pathao-courier-config"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Though Laravel auto discover. If not add the following in config\pathao-courier.php&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can skip this if you want&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// add below line in the providers array
Enan\PathaoCourier\PathaoCourierServiceProvider::class,

// add below line in the alias array
'PathaoCourier' =&amp;gt; Enan\PathaoCourier\Facades\PathaoCourier::class,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following environment variables to your .env file. You can choose the table name before running the migration. The default is &lt;em&gt;pathao-courier&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you don’t want to use the values in &lt;code&gt;.env&lt;/code&gt; file you can set values on &lt;code&gt;config/pathao-courier&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PATHAO_DB_TABLE_NAME='pathao-courier'
PATHAO_CLIENT_ID=
PATHAO_CLIENT_SECRET=
PATHAO_SECRET_TOKEN=
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;🔑Where can I find the value?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Go to your &lt;a href="https://merchant.pathao.com/courier/developer-api"&gt;Pathao Developers Api&lt;/a&gt; and you’ll find Merchant API Credentials there. And PATHAO_SECRET_TOKEN= you'll be provided it after the successful authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;🎫 Setup&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Run the migration&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;br&gt;
You will be provided a secret token here. Please set the token in your &lt;code&gt;.env&lt;/code&gt; file with &lt;code&gt;PATHAO_SECRET_TOKEN=&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan set:pathao-courier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;🏗 Usage&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Add the Facade before using&lt;/p&gt;

&lt;p&gt;&lt;code&gt;use Enan\PathaoCourier\Facade\PathaoCourier;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And after this you can use this like&lt;br&gt;
&lt;code&gt;PathaoCourier::GET_CITIES();&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For the POST type response the required validation are mentioned before the function like &lt;code&gt;&amp;lt;required, string&amp;gt;&lt;/code&gt; So here the value should be &lt;code&gt;required&lt;/code&gt; and &lt;code&gt;string&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;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 &amp;lt;GET&amp;gt;
 */
PathaoCourier::GET_ACCESS_TOKEN_EXPIRY_DAYS_LEFT();

/** 
 * To Get the cities
 *
 * @type &amp;lt;GET&amp;gt;
 */
PathaoCourier::GET_CITIES();

/**
 * To Get the Zones
 * @type &amp;lt;GET&amp;gt;
 *
 * @param int $city_id
 */
PathaoCourier::GET_ZONES(int $city_id);

/**
 * To Get the Areas
 * @type &amp;lt;GET&amp;gt;
 *
 * @param int $zone_id
 */
PathaoCourier::GET_AREAS(int $zone_id);

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

/**
 * To Create Store
 * @type &amp;lt;POST&amp;gt;
 *
 * @param $name &amp;lt;required, string&amp;gt;
 * @param $contact_name &amp;lt;required, string&amp;gt;
 * @param $contact_number &amp;lt;required, numeric&amp;gt;
 * @param $address &amp;lt;required, string&amp;gt;
 * @param $city_id &amp;lt;required, numeric&amp;gt;
 * @param $zone_id &amp;lt;required, numeric&amp;gt;
 * @param $area_id &amp;lt;required, numeric&amp;gt;
 */
PathaoCourier::CREATE_STORE($request);

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

/**
 * To Get Price Calculation
 * @type &amp;lt;POST&amp;gt;
 *
 * @param $delivery_type &amp;lt;required, numeric&amp;gt;
 * @param $item_type &amp;lt;required, numeric&amp;gt;
 * @param $item_weight &amp;lt;required, numeric&amp;gt;
 * @param $recipient_city &amp;lt;required, numeric&amp;gt;
 * @param $recipient_zone &amp;lt;required, numeric&amp;gt;
 * @param $store_id &amp;lt;required, numeric&amp;gt;
 */
PathaoCourier::GET_PRICE_CALCULATION($request);


/**
 * To View Order
 * @type &amp;lt;GET&amp;gt;
 * @param string $consignment_id
 */
PathaoCourier::VIEW_ORDER(string $consignment_id);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The package is hosted on: &lt;a href="https://packagist.org/packages/enan/pathao-courier"&gt;Packagist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s all. If you have further queries you can reach out to me via&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/in/moammer-farshid/"&gt;LinkedIn&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.facebook.com/moammerfarshidenan"&gt;Facebook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Aside from this, you can visit the following&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://moammer-enan.com/"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/enuenan"&gt;Github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Thank You
&lt;/h2&gt;

</description>
      <category>pathaocourier</category>
      <category>laravelpathaocourier</category>
      <category>apiintegrationlaravel</category>
      <category>pathaocourierapi</category>
    </item>
  </channel>
</rss>
