Download the PHP package steadfast-courier/steadfast-laravel-package without Composer

On this page you can find all versions of the php package steadfast-courier/steadfast-laravel-package. 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 steadfast-laravel-package

SteadFast

SteadFast Courier for Laravel

A complete Laravel client for the SteadFast Courier Limited API.

Latest version Downloads Tests

Book parcels, track deliveries, handle returns and pickups, and reconcile payments from your Laravel application. Every endpoint in the official SteadFast API documentation is covered, and every method returns the API's JSON decoded into a plain PHP array.

Works the same in an API-only backend, a queue worker, or a Blade application.

Contents

Requirements

Supported
PHP 8.2 – 8.5
Laravel 12.x, 13.x

Laravel 11 and earlier are not supported. Laravel 11 reached end of security support on 12 March 2026, and Composer's block-insecure audit default refuses to install any 11.x release. Projects still on Laravel 11 or older should stay on ^1.1 of this package.

Installation

Publish the config file:

Configuration

Add your credentials to .env. You can find them in your Steadfast merchant dashboard, or request them from Steadfast support.

Everything else is optional. The defaults are shown here, so you only need to add the lines you actually want to change:

The published config/steadfast.php documents each option inline. A trailing slash on STEADFAST_BASE_URL is fine, and leaving it unset raises a clear InvalidRequestException rather than a confusing HTTP client error.

Quick start

If you prefer the registered alias, \SteadFastCourier::placeOrder(...) works identically.

Endpoint coverage

Method Endpoint Package method Description
POST /create_order placeOrder() Book a single parcel.
POST /create_order/bulk-order bulkCreateOrders() Book up to 500 parcels in one call.
GET /status_by_cid/{id} checkDeliveryStatusByConsignmentId() Current delivery status, by consignment ID.
GET /status_by_invoice/{invoice} 1 checkDeliveryStatusByInvoiceId() Current delivery status, by your own invoice number.
GET /status_by_trackingcode/{code} 1 checkDeliveryStatusByTrackingCode() Current delivery status, by tracking code.
GET /trackings_by_invoice/{invoice} getTrackingsByInvoice() Full event history for a consignment, not just its current status.
POST /create_return_request createReturnRequest() Ask for a parcel to be returned to you.
GET /get_return_requests getReturnRequests() List all of your return requests.
GET /get_return_request/{id} getReturnRequest() Read one return request.
POST /create_pickup_request createPickupRequest() Ask Steadfast to collect parcels from your address.
GET /get_balance getCurrentBalance() Your current merchant account balance.
GET /payments getPayments() List the payments Steadfast has made to you.
GET /payments/{payment_id} getPayment() Read one payment.
GET /police_stations getPoliceStations() Districts and their police stations, for pickup requests.
GET /fraud_check/{phone} fraudCheck() A recipient's delivery and cancellation history.

1 Not listed in the current Postman collection, but still served by the API and supported here since 1.x.

Each example below assumes this import:

Orders

Place an order

Unrecognised keys are passed through untouched, so a field Steadfast adds later works without waiting for a package release.

Create orders in bulk

Up to 500 orders per call.

A bulk call succeeds as a whole even when individual orders fail, so check each entry's status rather than assuming the batch went through.

These mistakes are caught before any request is sent, and raise InvalidRequestException:

Call Problem
bulkCreateOrders([]) nothing to send
bulkCreateOrders(['invoice' => '...']) a single order, where a list of orders is expected
more than 500 orders over the API limit, send them in chunks

Chunking is straightforward:

Delivery status and tracking

Check a delivery status

Three interchangeable lookups, all returning the same shape:

Work with statuses using the enum

Comparing raw strings is easy to get wrong: a typo becomes a branch that silently never runs. Use the DeliveryStatus enum instead.

fromResponse() reads any of the three shapes Steadfast uses: delivery_status from a status check, consignment.status from placeOrder(), and status from a webhook payload. It returns null when the payload carries no status this package recognises, so a status Steadfast adds in future degrades gracefully rather than throwing in production.

API value Enum case Meaning Bucket
in_review InReview Order placed, under review in progress
pending Pending Not yet delivered or cancelled in progress
hold Hold On hold in progress
delivered_approval_pending DeliveredApprovalPending Delivered, awaiting admin approval awaiting approval
partial_delivered_approval_pending PartialDeliveredApprovalPending Partially delivered, awaiting approval awaiting approval
cancelled_approval_pending CancelledApprovalPending Cancelled, awaiting approval awaiting approval
unknown_approval_pending UnknownApprovalPending Unknown state, needs support awaiting approval
delivered Delivered Delivered and balance updated final
partial_delivered PartialDelivered Partially delivered and balance updated final
cancelled Cancelled Cancelled and balance updated final
unknown Unknown Unknown status, contact support in progress

Every status falls into exactly one bucket: isFinal(), isAwaitingApproval() or isInProgress().

Read the full tracking history

Where a status check returns the current state, this returns the whole event trail:

Returns and pickups

Create a return request

Identify the consignment by one of consignment_id, invoice or tracking_code. Omitting all three raises InvalidRequestException before any request is sent.

List and read return requests

Request a pickup

Ask Steadfast to collect parcels from one of your saved addresses. Use getPoliceStations() to look up police_station_id.

Account and reference data

Current balance

Payments

Police stations

Districts with their police stations, needed for police_station_id on a pickup request:

Fraud check

A recipient's delivery and cancellation history across Steadfast. Worth calling before accepting a high-value COD order:

Multiple Steadfast accounts

If you are not using .env, or you run a SaaS where each tenant has their own Steadfast account, pass credentials per call with withConfig():

withConfig() returns a new client and never modifies the shared one, so credentials cannot leak between tenants later in the same request, queue worker or Octane worker:

Error handling

Steadfast reports its own validation failures as JSON, and that body carries the message you need, so it is returned to you unchanged rather than raised:

Three kinds of problem throw instead:

Exception When
InvalidRequestException Your input cannot succeed. Raised locally, before any network call.
SteadfastCourierException Steadfast answered, but not with JSON: an HTML gateway error, an empty body.
Illuminate\Http\Client\ConnectionException Steadfast could not be reached within the timeout.

InvalidRequestException extends SteadfastCourierException, so one catch covers both.

Earlier versions returned null for a non-JSON reply, which callers could not tell apart from an empty result. That case now throws, with the status code and a snippet of the body in the message.

Timeouts and retries

Requests give up after STEADFAST_TIMEOUT seconds (default 30) and stop waiting to connect after STEADFAST_CONNECT_TIMEOUT seconds (default 10). Without these, an unresponsive endpoint would block your web request or queue worker indefinitely.

Status lookups, tracking, balance, payments and reference data are retried up to STEADFAST_RETRY_TIMES times (default 2) when the connection fails.

Writes are never retried. A create_order call that timed out may still have been accepted, and the API has no idempotency key that would make a retry safe, so retrying could book the same parcel twice. If placeOrder(), bulkCreateOrders(), createReturnRequest() or createPickupRequest() throws a ConnectionException, confirm the state with a status lookup before sending again:

Webhooks

Steadfast pushes parcel status changes to a callback URL you register with them, along with a bearer token of your choosing for authentication.

Set the same token in your .env:

Register a route. Webhooks come from Steadfast's servers, not a browser, so keep it out of any CSRF-protected or session-authenticated group:

The status field carries the same values as a status check, so the DeliveryStatus enum applies here too:

Steadfast may deliver the same event more than once, so make your handler idempotent: key it on consignment_id and ignore an update whose updated_at is not newer than what you stored.

Upgrading from 1.x

Version 2.0 drops end-of-life framework versions and corrects two behaviours that could lose data or leak credentials. Expect a short checklist rather than a rewrite.

Requirements. PHP 8.2+ and Laravel 12+. See Requirements.

The package has been renamed from steadfast-courier/steadfast-courier-laravel-package to steadfast-courier/steadfast-laravel-package, following the repository rename. The old package is abandoned and will receive no further releases. Swap it in one command:

The config file and its keys have been renamed from steadfast-courier to steadfast. Re-publish the config and rename any keys you read directly:

Your published config/steadfast-courier.php is no longer read: move any customisations into config/steadfast.php and delete the old file. The STEADFAST_* environment variable names are unchanged, so .env needs no edits.

bulkCreateOrders() posts a different body. It now sends the order list as the request body, matching the current API documentation; it previously sent {"data": "<json string>"}. The response is wrapped, so read $response['data'] instead of iterating the response directly:

Non-JSON replies throw. A reply that is not JSON used to come back as null. It now raises SteadfastCourierException. See Error handling.

Invalid input throws early. An empty identifier, a batch over 500 orders, a single order passed where a list belongs, or a return request with no consignment reference now raise InvalidRequestException instead of producing a malformed request.

withConfig() no longer mutates the shared client. Chained calls such as SteadfastCourier::withConfig(...)->placeOrder(...) are unaffected. Previously the credentials you passed leaked into every later call in the same process, which in a multi-tenant application meant booking parcels on the wrong account.

webhook_bearer_token now exists in the config file. If you copied the webhook controller from an older README, re-read Webhooks: the previous example authenticated any request sending a bare Bearer header whenever the token was unset. Re-publish the config, or add the key by hand:

Contributing

Contributions are welcome. Working on the package itself needs PHP 8.3 or newer, since Pest requires it.

The test suite never touches the network: it fakes the HTTP client and fails on any unexpected request. Please add a test with your change, and make sure it fails without it.

Bug reports and feature requests belong in GitHub issues.

Credits and license

Built and maintained with thanks to AmadulHaque and all contributors.

The MIT License (MIT). See LICENSE.md.


All versions of steadfast-laravel-package with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.8|^8.0
illuminate/contracts Version ^12.0|^13.0
spatie/laravel-package-tools Version ^1.93
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 steadfast-courier/steadfast-laravel-package contains the following files

Loading the files please wait ...