Dipu Dey 17th Oct 2022

Redx is a Bangladeshi courier/logistic company for reliable Delivery Business. This is a Laravel/PHP package for Redx. 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 Redx API by using laravel/PHP.

Redx – 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/redx-courier
</code>

vendor publish (config)

<code class="language-php">
php artisan vendor:publish --provider="Codeboxr\RedxCourier\RedxCourierServiceProvider"
</code>

After publish config file setup your credential. you can see this in your config directory redx.php file

<code class="language-php">
return [
     "sandbox"      => env("REDX_SANDBOX", false),
     "access_token" => env("REDX_ACCESS_TOKEN", ""),
];
</code>

Set .env configuration

<code class="language-php">
REDX_SANDBOX=true // for production mode use false
REDX_ACCESS_TOKEN=""
</code>

Usage

1. Get redx delivery area list
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::area()->list();
</code>
2. Create new store
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::store()
       ->create([
             "name"    => "", //store name
             "phone"   => "", //store contact person 
             "area_id" => "",
             "address" => "",
         ]);
</code>
3. Get Store List
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::store()->list();
</code>
4. Store Details
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::store()->storeDetails($storeId);
</code>
5. Create new parcel
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::order()
                        ->create([
                            "customer_name"          => "", 
                            "customer_phone"         => "",
                            "delivery_area"          => "", // delivery area name
                            "delivery_area_id"       => "", // area id
                            "customer_address"       => "", 
                            "merchant_invoice_id"    => "",
                            "cash_collection_amount" => "",
                            "parcel_weight"          => "", //parcel weight in gram
                            "instruction"            => "",
                            "value"                  => "", //compensation amount
                            "pickup_store_id"        => "", // store id
                            "parcel_details_json"    => ""
                        ]);
</code>
6. Get Order Details
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::order()->orderDetails($trackingId); // After successfully create order they given a tracking_id
</code>
7. Order tracking
<code class="language-php">
use Codeboxr\RedxCourier\Facade\RedxCourier

return RedxCourier::order()->tracking($trackingId); // After successfully create order they given a tracking_id
</code>

Contributing

Contributions to the Redx package are welcome. Please note the following guidelines before submitting your pull request.

  • Follow PSR-4 coding standards.
  • Read Redx API documentations first

License

Redx package is licensed under the MIT License.
Copyright 2022 Codeboxr