PHPackages                             sabitahmad/laravel-steadfast - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sabitahmad/laravel-steadfast

ActiveLibrary[API Development](/categories/api)

sabitahmad/laravel-steadfast
============================

Laravel package for SteadFast Courier API integration with order creation, tracking, returns, and optional bulk processing

v2.2.1(2mo ago)264MITPHPPHP ^8.1CI passing

Since Apr 4Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/sabitahmadumid/laravel-steadfast)[ Packagist](https://packagist.org/packages/sabitahmad/laravel-steadfast)[ Docs](https://github.com/sabitahmadumid/laravel-steadfast)[ GitHub Sponsors](https://github.com/SabitAhmad)[ RSS](/packages/sabitahmad-laravel-steadfast/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (13)Versions (6)Used By (0)

Laravel SteadFast Courier Package
=================================

[](#laravel-steadfast-courier-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/666561e9e31b9c3ab0f2984134279d855d9883e6f268fe827fbbe2f8663fb700/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736162697461686d61642f6c61726176656c2d7374656164666173742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sabitahmad/laravel-steadfast)[![Total Downloads](https://camo.githubusercontent.com/98f10361af91b7c361d1097a3fc8b9bafdcd87e1ae2d7e6154f20149b7e8bd8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736162697461686d61642f6c61726176656c2d7374656164666173742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sabitahmad/laravel-steadfast)

Laravel integration for the SteadFast Courier API with typed DTOs for orders, tracking, returns, balance checks, optional bulk processing, bulk lifecycle events, caching, and database-backed request logging.

Features
--------

[](#features)

- Create single and bulk orders
- Track shipments by consignment ID, invoice, or tracking code
- Create and fetch return requests
- Check account balance
- Typed request and response DTOs
- Queue-backed bulk processing
- Bulk lifecycle events
- Configurable caching for balance and status lookups
- Optional fraud checking through the SteadFast merchant panel
- Optional request logging and usage statistics
- Built-in artisan commands for testing, statistics, and cleanup

Installation
------------

[](#installation)

```
composer require sabitahmad/laravel-steadfast
php artisan steadfast:install
```

Add your credentials to `.env`:

```
STEADFAST_API_KEY=your_api_key_here
STEADFAST_SECRET_KEY=your_secret_key_here
```

Optional settings:

```
STEADFAST_BASE_URL=https://portal.packzy.com/api/v1
STEADFAST_TIMEOUT=30
STEADFAST_CONNECT_TIMEOUT=10

STEADFAST_BULK_QUEUE=true
STEADFAST_BULK_CHUNK_SIZE=500
STEADFAST_QUEUE_NAME=default
STEADFAST_QUEUE_CONNECTION=
STEADFAST_BULK_MAX_ATTEMPTS=3
STEADFAST_BULK_BACKOFF=60

STEADFAST_RETRY_TIMES=3
STEADFAST_RETRY_SLEEP=1000

STEADFAST_CACHE_ENABLED=false
STEADFAST_CACHE_TTL=300
STEADFAST_CACHE_PREFIX=steadfast
STEADFAST_CACHE_STORE=

STEADFAST_LOGGING=true
STEADFAST_LOG_REQUESTS=false
STEADFAST_LOG_RESPONSES=true
STEADFAST_CLEANUP_LOGS=true
STEADFAST_KEEP_LOGS_DAYS=30

STEADFAST_FRAUD_CHECKER_ENABLED=false
STEADFAST_FRAUD_CHECKER_EMAIL=your-merchant-email@example.com
STEADFAST_FRAUD_CHECKER_PASSWORD=your-merchant-password
```

Verify the setup:

```
php artisan steadfast:test
```

Usage
-----

[](#usage)

### Create an Order

[](#create-an-order)

```
use SabitAhmad\SteadFast\DTO\OrderRequest;
use SabitAhmad\SteadFast\SteadFast;

$steadfast = new SteadFast();

$order = new OrderRequest(
    invoice: 'INV-2025-001',
    recipient_name: 'John Doe',
    recipient_phone: '01712345678',
    recipient_address: 'House 1, Road 2, Dhanmondi, Dhaka-1209',
    cod_amount: 1500.00,
    note: 'Handle with care'
);

$response = $steadfast->createOrder($order);

echo $response->getTrackingCode();
```

You can also use optional order fields when needed:

```
$order = new OrderRequest(
    invoice: 'INV-2025-002',
    recipient_name: 'Jane Doe',
    recipient_phone: '01812345678',
    recipient_address: 'Banani, Dhaka',
    cod_amount: 2200,
    alternative_phone: '01912345678',
    recipient_email: 'jane@example.com',
    item_description: 'Skin care products',
    total_lot: 2,
    delivery_type: 0
);
```

### Use the Facade

[](#use-the-facade)

```
use SabitAhmad\SteadFast\Facades\SteadFast;

$balance = SteadFast::getBalance();
```

### Bulk Orders

[](#bulk-orders)

```
$orders = [
    new OrderRequest('INV-001', 'John Doe', '01712345678', 'Address 1', 1000),
    new OrderRequest('INV-002', 'Jane Smith', '01787654321', 'Address 2', 1500),
    OrderRequest::fromArray([
        'invoice' => 'INV-003',
        'recipient_name' => 'Bob Wilson',
        'recipient_phone' => '01611111111',
        'recipient_address' => 'Address 3',
        'cod_amount' => 2000,
        'delivery_type' => 1,
    ]),
];

$queued = $steadfast->bulkCreate($orders, true);
$processed = $steadfast->bulkCreate($orders, false);
```

Bulk responses include helper methods:

```
echo $processed->getSuccessRate();

if ($processed->hasErrors()) {
    $failedOrders = $processed->getFailedOrders();
}
```

### Track an Order

[](#track-an-order)

```
$status = $steadfast->checkStatusByTrackingCode('ABC123XYZ');

if ($status->isDelivered()) {
    echo 'Delivered';
}

echo $status->getStatusDescription();
```

You can also track by invoice or consignment ID:

```
$steadfast->checkStatusByInvoice('INV-001');
$steadfast->checkStatusByConsignmentId(12345);
```

### Return Requests

[](#return-requests)

```
use SabitAhmad\SteadFast\DTO\ReturnRequest;

$request = ReturnRequest::byInvoice('INV-001', 'Customer requested return');

$response = $steadfast->createReturnRequest($request);
$single = $steadfast->getReturnRequest(123);
$all = $steadfast->getReturnRequests();
```

You can also create return requests by consignment ID or tracking code:

```
ReturnRequest::byConsignmentId(12345, 'Damaged item');
ReturnRequest::byTrackingCode('ABC123', 'Wrong item delivered');
```

### Balance

[](#balance)

```
$balance = $steadfast->getBalance();

echo $balance->getFormattedBalance();
```

Response Helpers
----------------

[](#response-helpers)

The DTOs expose helper methods so your application code stays clean:

```
$orderResponse->getConsignmentId();
$orderResponse->getTrackingCode();
$orderResponse->getInvoice();

$status->isPending();
$status->isCancelled();
$status->isOnHold();

$returnResponse->isPending();
$returnResponse->isCompleted();
```

### Fraud Check

[](#fraud-check)

This feature logs into the SteadFast merchant panel and is slower than the normal API calls. Enable it only if you need it.

```
try {
    $fraud = $steadfast->checkFraud('01712345678');

    echo $fraud->success;
    echo $fraud->cancel;
    echo $fraud->getRiskLevel();
} catch (\SabitAhmad\SteadFast\Exceptions\SteadfastException $e) {
    report($e);
}
```

Accepted phone formats are normalized automatically, including `01712345678`, `8801712345678`, `+8801712345678`, and values with spaces or dashes.

Fraud responses also include helper methods:

```
$fraud->getSuccessRate();
$fraud->getCancelRate();
$fraud->isRisky();
$fraud->getRiskDescription();
```

Events
------

[](#events)

Bulk processing dispatches these events:

- `SabitAhmad\SteadFast\Events\BulkOrderStarted`
- `SabitAhmad\SteadFast\Events\BulkOrderCompleted`
- `SabitAhmad\SteadFast\Events\BulkOrderFailed`

Example listener registration:

```
use Illuminate\Support\Facades\Event;
use SabitAhmad\SteadFast\Events\BulkOrderCompleted;
use SabitAhmad\SteadFast\Events\BulkOrderFailed;
use SabitAhmad\SteadFast\Events\BulkOrderStarted;

Event::listen(BulkOrderStarted::class, function (BulkOrderStarted $event) {
    logger()->info('Bulk order processing started', [
        'order_count' => count($event->orders),
        'unique_id' => $event->uniqueId,
    ]);
});

Event::listen(BulkOrderCompleted::class, function (BulkOrderCompleted $event) {
    logger()->info('Bulk order processing completed', [
        'success_count' => $event->response->success_count,
        'error_count' => $event->response->error_count,
        'unique_id' => $event->uniqueId,
    ]);
});

Event::listen(BulkOrderFailed::class, function (BulkOrderFailed $event) {
    logger()->error('Bulk order processing failed', [
        'error' => $event->exception->getMessage(),
        'unique_id' => $event->uniqueId,
    ]);
});
```

Caching
-------

[](#caching)

Balance and status lookups can be cached:

```
STEADFAST_CACHE_ENABLED=true
STEADFAST_CACHE_TTL=300
STEADFAST_CACHE_PREFIX=steadfast
STEADFAST_CACHE_STORE=redis
```

Clear cached entries when needed:

```
$steadfast->clearCache('balance');
$steadfast->clearCache();
```

Error Handling
--------------

[](#error-handling)

```
use SabitAhmad\SteadFast\Exceptions\SteadfastException;

try {
    $steadfast->createOrder($order);
} catch (SteadfastException $e) {
    match ($e->getCode()) {
        401 => report('Invalid credentials'),
        422 => report($e->getContext()['validation_errors'] ?? []),
        429 => report('Rate limited'),
        503 => report('Service unavailable'),
        default => report($e->getMessage()),
    };
}
```

Logging and Statistics
----------------------

[](#logging-and-statistics)

If logging is enabled, requests are stored in the `steadfast_logs` table.

Useful scopes on the `SteadfastLog` model:

```
use SabitAhmad\SteadFast\Models\SteadfastLog;

$recentErrors = SteadfastLog::errors()->recent(24)->get();
$successful = SteadfastLog::successful()->recent(24)->get();
$bulkOperations = SteadfastLog::bulkOperations()->get();
$stats = SteadfastLog::getStats(24);
```

Artisan Commands
----------------

[](#artisan-commands)

Available commands:

```
php artisan steadfast:test
php artisan steadfast:stats
php artisan steadfast:stats --hours=168
php artisan steadfast:cleanup
php artisan steadfast:cleanup --force
```

What they do:

- `steadfast:test`: validates config and checks API connectivity
- `steadfast:stats`: shows request volume, success rate, bulk usage, and top endpoints
- `steadfast:cleanup`: removes old log records from `steadfast_logs`

API Coverage
------------

[](#api-coverage)

EndpointMethodPurpose`/create_order``POST`Create a single order`/create_order/bulk-order``POST`Create bulk orders`/status_by_cid/{id}``GET`Check status by consignment ID`/status_by_invoice/{invoice}``GET`Check status by invoice`/status_by_trackingcode/{code}``GET`Check status by tracking code`/get_balance``GET`Get account balance`/create_return_request``POST`Create a return request`/get_return_request/{id}``GET`Get one return request`/get_return_requests``GET`Get all return requests

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~123 days

Total

4

Last Release

78d ago

Major Versions

v1.0.0 → v2.0.02025-09-24

PHP version history (2 changes)v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/185702986?v=4)[Sabit Ahmad Umid](/maintainers/sabitahmadumid)[@sabitahmadumid](https://github.com/sabitahmadumid)

---

Top Contributors

[![sabitahmadumid](https://avatars.githubusercontent.com/u/185702986?v=4)](https://github.com/sabitahmadumid "sabitahmadumid (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelorder trackingsteadfast courierdelivery-apiSabitAhmadlaravel-steadfastcourier-apibulk-ordersreturn-requestsbangladesh-courier

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sabitahmad-laravel-steadfast/health.svg)

```
[![Health](https://phpackages.com/badges/sabitahmad-laravel-steadfast/health.svg)](https://phpackages.com/packages/sabitahmad-laravel-steadfast)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

9782.1M162](/packages/laravel-ai)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
