Download the PHP package kejubayer/redx-api-integration without Composer

On this page you can find all versions of the php package kejubayer/redx-api-integration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package redx-api-integration

Laravel RedX API Integration Package

kejubayer/redx-api-integration is a Laravel package for RedX courier API integration in Bangladesh. It provides a simple RedX HTTP client, configurable API endpoints, a webhook route, and automatic storage of RedX webhook payloads in a database table.

Use this package to create RedX parcels, track parcels, cancel parcels, call configured RedX API endpoints, and receive RedX delivery status webhook updates in your Laravel application.

Features

Requirements

Installation

Install the package with Composer:

Publish the configuration file:

Publish the migration:

Run the migration:

Environment Variables

Add your RedX API credentials to .env:

Optional webhook secret protection:

RedX expects the token in this HTTP header:

So REDX_TOKEN_HEADER is the header name, and REDX_API_TOKEN is the full header value.

Configuration

After publishing, the config file is available at:

Default endpoint configuration:

If your RedX merchant account uses different endpoint paths, update the config or set these .env values:

Basic Usage

Use the facade:

Use dependency injection:

Available Methods

Quick method list:

Method Purpose
Redx::createParcel($payload) Create a RedX parcel
Redx::trackParcel($trackingId) Track parcel by tracking number
Redx::parcelDetails($trackingId) Get parcel details by tracking ID
Redx::updateParcel($trackingId, $propertyName, $newValue, $reason) Update a parcel property
Redx::updateParcelRaw($payload) Update a parcel with the full RedX payload
Redx::cancelParcel($trackingId, $reason) Cancel parcel by tracking ID
Redx::areas($query) Get RedX areas
Redx::areasByPostCode($postCode) Get areas by postal code
Redx::areasByDistrictName($districtName) Get areas by district name
Redx::createPickupStore($payload) Create pickup store
Redx::pickupStores($query) Get pickup stores
Redx::pickupStoreDetails($pickupStoreId) Get pickup store details
Redx::calculateCharge($query) Calculate parcel charge
Redx::getEndpoint($name, $replacements, $query) Call a configured GET endpoint
Redx::postEndpoint($name, $payload, $replacements) Call a configured POST endpoint
Redx::putEndpoint($name, $payload, $replacements) Call a configured PUT endpoint
Redx::patchEndpoint($name, $payload, $replacements) Call a configured PATCH endpoint
Redx::deleteEndpoint($name, $payload, $replacements) Call a configured DELETE endpoint
Redx::callEndpoint($method, $name, $payload, $replacements) Call any configured endpoint dynamically
Redx::endpoint($name, $replacements) Resolve a configured endpoint path
Redx::get($uri, $query) Raw GET request
Redx::post($uri, $payload) Raw POST request
Redx::put($uri, $payload) Raw PUT request
Redx::patch($uri, $payload) Raw PATCH request
Redx::delete($uri, $payload) Raw DELETE request
Redx::request() Get the configured Laravel HTTP client
Redx::getResponse($uri, $query) Raw GET request with Laravel response object
Redx::postResponse($uri, $payload) Raw POST request with Laravel response object
Redx::putResponse($uri, $payload) Raw PUT request with Laravel response object
Redx::patchResponse($uri, $payload) Raw PATCH request with Laravel response object
Redx::deleteResponse($uri, $payload) Raw DELETE request with Laravel response object

createParcel

Create a new RedX parcel.

Required RedX create parcel fields usually include:

Use merchant_invoice_id for your invoice number when creating a parcel. Webhook payloads may return that value as invoice_number.

parcelDetails

Get RedX parcel details by tracking ID.

trackParcel

Track a parcel by RedX tracking number.

updateParcel

Update a RedX parcel property.

Send the exact RedX update payload:

cancelParcel

Cancel a parcel by tracking ID. This is a shortcut for updateParcel($trackingId, 'status', 'cancelled', $reason).

areas

Get RedX delivery areas.

With query parameters:

Get areas by post code:

Get areas by district name:

createPickupStore

Create a RedX pickup store.

pickupStores

Get RedX pickup stores.

pickupStoreDetails

Get pickup store details.

calculateCharge

Calculate RedX parcel charge.

Easy Use For All Endpoints

You can add any RedX API endpoint to config/redx-api-integration.php and call it by name.

Example config:

Call a configured GET endpoint:

Call a configured POST endpoint:

Call a configured PUT endpoint:

Call a configured PATCH endpoint:

Call a configured DELETE endpoint:

Call any configured endpoint dynamically:

Resolve only the endpoint path:

get

Call any RedX GET endpoint.

post

Call any RedX POST endpoint.

put

Call any RedX PUT endpoint.

patch

Call any RedX PATCH endpoint.

delete

Call any RedX DELETE endpoint.

With a request body:

request

Get the configured Laravel HTTP pending request instance.

Webhook Route

The package registers this route by default:

You can change the route path:

You can disable the route:

RedX Webhook Payload Structure

Expected RedX webhook JSON payload:

Example payload:

Webhook Database Structure

Webhook requests are stored in the redx_webhook_requests table.

Column Type Description
id integer Primary key
tracking_number string, nullable RedX tracking number
redx_timestamp timestamp, nullable Timestamp sent by RedX
status string, nullable Parcel status
message_en string, nullable English status message
message_bn string, nullable Bangla status message
invoice_number string, nullable Merchant invoice number
delivery_type string, nullable RedX delivery type
payload json Full webhook payload
headers json, nullable Request headers
ip_address string, nullable Sender IP address
user_agent string, nullable Request user agent
signature string, nullable Signature header value, when available
processed_at timestamp, nullable Processing timestamp for your application
created_at timestamp Created timestamp
updated_at timestamp Updated timestamp

Webhook Model

The default model is:

Query stored webhooks:

Find webhook requests by tracking number:

Find delivered parcels:

Mark a webhook request as processed:

Use your own model:

Your custom model should extend the package model or provide the same fillable columns.

Webhook Event

After storing a webhook request, the package dispatches:

Listen for the event:

Create a listener:

Example listener:

Secure Webhooks

Set a shared secret in your .env:

RedX must send the same secret value in the configured header. If the secret does not match, the package returns 403 Forbidden.

Testing Webhook Locally

You can test the webhook route with curl:

With webhook secret:

Raw Response Usage

Normal package methods return PHP arrays directly. If you need the raw Laravel Illuminate\Http\Client\Response object, use the *Response methods or request().

Error Handling

Because normal methods return arrays, RedX validation errors are available directly:

License

The MIT License.


All versions of redx-api-integration with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/routing Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kejubayer/redx-api-integration contains the following files

Loading the files please wait ...