With this package you can easily interact with Biteship API
Here is a simple example to retrieve shipping costs
// First you must define the items to ship
$items = [
[
'name' => 'Black L',
'description' => 'White Shirt',
'category' => 'fashion',
'value' => 165000,
'quantity' => 1,
'height' => 10,
'length' => 10,
'weight' => 200,
'width' => 10,
]
];
// Then specify the destination and the origin
// You could use Postal Code but Biteship recommends you to use
// their's Area ID, because it is more accurate.
$destination = 12950;
$origin = 12440;
$availableCouriers = \Cloudenum\Biteship\Courier::all();
$rates = \Cloudenum\Biteship\CourierPricing::Rates([
'origin_postal_code' => $origin,
'destination_postal_code' => $destination,
'couriers' => implode(',', $availableCouriers->pluck('courier_code')->unique()->toArray()),
'items' => $items,
]);
You can install the package via composer:
composer require cloudenum/laravel-biteship
You can publish the config file with:
php artisan vendor:publish --tag="biteship-config"
This is the contents of the published config file:
return [
'base_url' => env('BITESHIP_BASE_URL', 'https://api.biteship.com'),
'api_key' => env('BITESHIP_API_KEY'),
];
The usage of this package will largely follows Biteship API Usage Flow.
You must obtain an API key to use this package. Biteship has documentation on how you could get an API key.
After you get your API key add below environments to your .env
file
BITESHIP_API_KEY=<YourApiKey>
Example:
\Cloudenum\Biteship\Area::search("Lebak Bulus");
For the first request you could use the Area::search()
method and set the double
paramater to true
.
Then for the second request you could use Area::doubleSearchSecondRequest()
method.
Example:
$area = \Cloudenum\Biteship\Area::search("Lebak Bulus")->first();
\Cloudenum\Biteship\Area::doubleSearchSecondRequest($area->id);
Tip:
You could get Area by their's ID withArea::doubleSearchSecondRequest()
method.
Example:
$items = [
[
'name' => 'Black L',
'description' => 'White Shirt',
'category' => 'fashion',
'value' => 165000,
'quantity' => 1,
'height' => 10,
'length' => 10,
'weight' => 200,
'width' => 10,
]
];
$destination = 55510;
$origin = 12440;
$availableCouriers = \Cloudenum\Biteship\Courier::all();
$rates = \Cloudenum\Biteship\CourierPricing::Rates([
'origin_postal_code' => $origin,
'destination_postal_code' => $destination,
'couriers' => implode(',', $availableCouriers->pluck('courier_code')->unique()->toArray()),
'items' => $items,
]);
Example:
$data = [
'shipper_contact_name' => 'Amir',
'shipper_contact_phone' => '088888888888',
'shipper_contact_email' => '[email protected]',
'shipper_organization' => 'Biteship Org Test',
'origin_contact_name' => 'Amir',
'origin_contact_phone' => '088888888888',
'origin_address' => 'Plaza Senayan, Jalan Asia Afrika',
'origin_note' => 'Deket pintu masuk STC',
'origin_postal_code' => 12440,
'destination_contact_name' => 'John Doe',
'destination_contact_phone' => '088888888888',
'destination_address' => 'Lebak Bulus MRT',
'destination_postal_code' => 12950,
'destination_note' => 'Near the gas station',
'courier_company' => 'jne',
'courier_type' => 'reg',
'courier_insurance' => 500000,
'delivery_type' => 'now',
'order_note' => 'Please be careful',
'metadata' => [],
'items' => [
[
'name' => 'Black L',
'description' => 'White Shirt',
'category' => 'fashion',
'value' => 165000,
'quantity' => 1,
'height' => 10,
'length' => 10,
'weight' => 200,
'width' => 10,
]
]
];
$biteshipOrder = \Cloudenum\Biteship\Order::create($data);
Example:
$biteshipOrder = \Cloudenum\Biteship\Order::find("ID");
Example:
// The reason could be a message why it is cancelled.
$biteshipOrder->cancel($reason);
Note
Tracking ID is not Waybill ID issued by couriers
Example:
$tracking = \Cloudenum\Biteship\Tracking::find("TrackingId");
Example:
$tracking = \Cloudenum\Biteship\Tracking::findPublicTracking("WaybillId");
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.