laravel-sendbox maintained by koderia-creative-lab
Laravel Sendbox
A Laravel client for the Sendbox shipping and logistics API supporting delivery quotes, shipment creation, tracking, and shipment billing.
Installation
composer require koderia-creative-lab/laravel-sendbox
Publish configuration:
php artisan vendor:publish --tag="sendbox-config"
Configuration
Add the following environment variables to .env:
SENDBOX_API_TOKEN=your_api_token
SENDBOX_API_SECRET=your_api_secret
SENDBOX_URL=https://live.sendbox.co/v1
SENDBOX_TIMEOUT=30
SENDBOX_LOGGING=true
Usage
Get a Shipping Quote
use Koderia\Sendbox\Facades\Sendbox;
$response = Sendbox::getShippingQuote([
'origin_city' => 'Lagos',
'origin_state' => 'Lagos',
'origin_country' => 'NG',
'destination_city' => 'Abuja',
'destination_state' => 'FCT',
'destination_country' => 'NG',
'weight' => 1.5,
'currency' => 'NGN',
]);
if ($response->isSuccessful()) {
$amount = $response->getAmount();
$rates = $response->getRates();
}
Create, Track & Bill a Shipment
$shipment = Sendbox::createShipment($payload);
$tracking = Sendbox::trackShipment($shipment->getTrackingCode());
$billed = Sendbox::billShipment($shipment->getTrackingCode());
Testing
vendor/bin/phpunit