A Laravel package for integrating with Leopards Courier API services.
You can install the package via composer:
composer require ahid/leopards-courier- Validation Improvements: Eased validation for track_numbers and cn_numbers to be more flexible
- Track numbers now accept any string between 3-20 characters (previously required exactly 10 alphanumeric characters)
- CN numbers now accept any string between 3-20 characters (previously required specific format patterns)
- This change provides better compatibility with various tracking number formats
Publish the configuration file:
php artisan vendor:publish --provider="Ahid\LeopardsCourier\AhidLeopardsServiceProvider"Add your Leopards Courier API credentials to your .env file:
LEOPARDS_API_KEY=your_api_key
LEOPARDS_API_PASSWORD=your_api_password
LEOPARDS_API_ENVIRONMENT=staging # or production
use Ahid\LeopardsCourier\Facades\LeopardsCourier;
// Get all cities
$cities = LeopardsCourier::getAllCities();use Ahid\LeopardsCourier\Facades\LeopardsCourier;
// Book a packet
$bookingData = [
'booked_packet_weight' => 2000, // Weight in grams
'booked_packet_no_piece' => 1,
'booked_packet_collect_amount' => 2500,
'booked_packet_order_id' => 'ORD-12345',
'origin_city' => 'self', // or city ID
'destination_city' => 789, // City ID from getAllCities
'shipment_name_eng' => 'self',
'shipment_email' => 'self',
'shipment_phone' => 'self',
'shipment_address' => 'self',
'consignment_name_eng' => 'John Doe',
'consignment_email' => 'john@example.com',
'consignment_phone' => '03001234567',
'consignment_address' => '123 Main St, Lahore',
'special_instructions' => 'Handle with care'
];
$booking = LeopardsCourier::bookPacket($bookingData);getAllCities(): Get a list of all available cities with origin and destination statusbookPacket(array $data): Book a new shipment
The package throws LeopardsApiException when the API returns an error. You can catch this exception to handle API errors:
use Ahid\LeopardsCourier\Exceptions\LeopardsApiException;
try {
$cities = LeopardsCourier::getAllCities();
} catch (LeopardsApiException $e) {
// Handle API error
echo $e->getMessage();
}The MIT License (MIT). Please see License File for more information.