定制 cloudenum/laravel-biteship 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cloudenum/laravel-biteship

最新稳定版本:v0.2.0

Composer 安装命令:

composer require cloudenum/laravel-biteship

包简介

Unofficial Laravel package for Biteship API.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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,
]);

Installation

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'),
];

Usage

The usage of this package will largely follows Biteship API Usage Flow.

Authentication

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>

Area

Retrieve Area With Single Search

API Doc

Example:

\Cloudenum\Biteship\Area::search("Lebak Bulus");

Retrieve Area With Double Search

API Doc

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 with Area::doubleSearchSecondRequest() method.

Rates

Retrieve Courier Rates

API Doc

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,
]);

Shipping Order

Create a Shipping Order

API Doc

Example:

$data = [
    'shipper_contact_name' => 'Amir',
    'shipper_contact_phone' => '088888888888',
    'shipper_contact_email' => 'biteship@test.com',
    '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);

Get Shipping Order By ID

API Doc

Example:

$biteshipOrder = \Cloudenum\Biteship\Order::find("ID");

Cancel a Shipping Order

API Doc

Example:

// The reason could be a message why it is cancelled.
$biteshipOrder->cancel($reason);

Shipment Tracking

Get Shipment Tracking By ID

API Doc

Note
Tracking ID is not Waybill ID issued by couriers

Example:

$tracking = \Cloudenum\Biteship\Tracking::find("TrackingId");

Get Shipment Tracking By Waybill ID

API Doc

Example:

$tracking = \Cloudenum\Biteship\Tracking::findPublicTracking("WaybillId", "jne");

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-26