1. Go to this page and download the library: Download nayemuf/pathao-courier library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nayemuf / pathao-courier example snippets
$stores = PathaoCourier::store()->list();
use Nayemuf\PathaoCourier\Facades\PathaoCourier;
$orderData = [
'store_id' => 149043, // Your store ID
'merchant_order_id' => 'ORD-12345', // Your internal order ID
'recipient_name' => 'John Doe',
'recipient_phone' => '01712345678', // 11 digits, starts with 01
'recipient_address' => 'House 123, Road 4, Sector 10, Uttara, Dhaka-1230',
'delivery_type' => 48, // 48 for normal, 12 for on-demand
'item_type' => 2, // 1 for document, 2 for parcel
'item_quantity' => 1,
'item_weight' => '0.5', // in kg (0.5 to 10)
'amount_to_collect' => 1000, // 0 for non-COD orders
'item_description' => 'Product description', // Optional
];
try {
$response = PathaoCourier::order()->create($orderData);
// Response contains: consignment_id, invoice_id, etc.
} catch (\Nayemuf\PathaoCourier\Exceptions\PathaoException $e) {
// Handle error
logger()->error('Pathao order creation failed', [
'message' => $e->getMessage(),
'errors' => $e->getErrors(),
]);
}
// Get order short info
$orderInfo = PathaoCourier::order()->getInfo($consignmentId);
// Get full order details
$orderDetails = PathaoCourier::order()->getDetails($consignmentId);
// Get all cities
$cities = PathaoCourier::area()->getCities();
// Get zones for a city
$zones = PathaoCourier::area()->getZones($cityId);
// Get areas for a zone
$areas = PathaoCourier::area()->getAreas($zoneId);
$priceData = [
'store_id' => 149043,
'item_type' => 2, // 1 for document, 2 for parcel
'delivery_type' => 48, // 48 for normal, 12 for on-demand
'item_weight' => 0.5, // in kg
'recipient_city' => 1, // City ID
'recipient_zone' => 298, // Zone ID
];
$price = PathaoCourier::price()->calculate($priceData);
// Returns: price, distance, etc.
// Get list of all stores
$stores = PathaoCourier::store()->list();
// Get single store info
$storeInfo = PathaoCourier::store()->getInfo($storeId);
// Create a new store
$storeData = [
'name' => 'My Store',
'contact_name' => 'John Doe',
'contact_number' => '01712345678',
'address' => 'Store Address',
'city_id' => 1,
'zone_id' => 298,
'area_id' => 1234,
];
$newStore = PathaoCourier::store()->create($storeData);