先进中介技术/laravel-shippy-pro-connector

Shippypro Connector for Laravel

dev-master 2023-06-28 12:50 UTC

This package is auto-updated.

Last update: 2024-09-28 15:34:17 UTC


README

Shippypro 连接器是一个简单的 PHP 库,允许您将 Shippypro 集成到项目中。您可以检查承运人费率和发货订单。

将以下行添加到 config/app.php 中的 providers 数组

'providers' => [
    ...
    \yax\ShippyProConnector\ShippyproServiceProvider::class
],

然后您需要发布配置。执行命令

    php artisan vendor:publish

之后,您需要在 config/shippypro.php 中配置您的 Shippypro API 密钥

    /* This example uses env file but you can paste in this place your API key */
    'api_key' => env('SHIPPYPRO_API', null),

这是一个示例集成

$sender = new ShippyproAddress('Jan Kowalski', '/', 'Prosta 20', '/', 'Wrocław', 'DS', '50-419', 'PL', '445544544', 'jankowalski@gmail.com');
$recivier = new ShippyproAddress('Jan Kowalski', '/', 'Prosta 20', '/', 'Wrocław', 'DS', '50-419', 'PL', '445544544', 'jankowalski@gmail.com');
$parcel = new ShippyproParcel('30', '20', '20', '10');
$shipment = new ShippyproShipment(30.00, 'Description');
$shipment->to_address($recivier);
$shipment->from_address($sender);
$shipment->addParcel($parcel);
$array = $shipment->getRates();
$rate = $array->searchByKey('carrier_id', 1081);
$shipment->setTransactionId(2349);
if ($rate) {
    $shipment->setRate($rate);
    $order = $shipment->purchase();
}