PHPackages                             ivanmitrikeski/laravel-shipping - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. ivanmitrikeski/laravel-shipping

ActiveLaravel-package[HTTP &amp; Networking](/categories/http)

ivanmitrikeski/laravel-shipping
===============================

Shipping package for Laravel. Supported providers: CanadaPost, USPS, UPS, FedEx and Purolator.

v1.0.9(2mo ago)206.8k↑256.4%51MITPHPPHP ^8.2

Since Sep 25Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/ivanmitrikeski/laravel-shipping)[ Packagist](https://packagist.org/packages/ivanmitrikeski/laravel-shipping)[ RSS](/packages/ivanmitrikeski-laravel-shipping/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (11)Used By (1)

Shipping package for Laravel
============================

[](#shipping-package-for-laravel)

Supported shipping providers:

- UPS REST/OAuth API
- FedEx REST/OAuth API
- Canada Post
- USPS API v3
- Purolator

Package can be used outside the Laravel environment as well (by making individual shipping provider requests).

Supported API services:

Shipping ProviderRate APIShipment APIUPS REST✓✓FedEx REST✓✓Canada Post✓✓Purolator✓✓USPS API v3✓ (Shipping Options 3.0)-### Install package

[](#install-package)

```
composer require ivanmitrikeski/laravel-shipping
```

### Run migrations

[](#run-migrations)

```
php artisan migrate
```

### Setup .env variables

[](#setup-env-variables)

```
CANADA_POST_CUSTOMER_NUMBER=
CANADA_POST_USERNAME=
CANADA_POST_PASSWORD=

PUROLATOR_KEY=
PUROLATOR_PASSWORD=
PUROLATOR_BILLING_ACCOUNT=
PUROLATOR_REGISTERED_ACCOUNT=
PUROLATOR_USER_TOKEN=

UPS_CLIENT_ID=
UPS_CLIENT_SECRET=
UPS_USER_ID=
UPS_ACCOUNT_NUMBER=

USPS_CLIENT_ID=
USPS_CLIENT_SECRET=

FEDEX_CLIENT_ID=
FEDEX_CLIENT_SECRET=
FEDEX_ACCOUNT_NUMBER=

SHIPPING_SANDBOX=false

```

### Using sandbox credentials

[](#using-sandbox-credentials)

In order to use test credentials just add param "true" in the \*Credentials() object or set environment variable SHIPPING\_SANDBOX=false.

### Models

[](#models)

There are 4 Eloquent models available: ShippingService, ShippingBox, ShippingOption and ShippingOptionPrice.

ShippingBox and ShippingOptionPrice are used for service Flat. Creating ShippingBox and creating ShippingOptionPrice will allow users to set flat rate shipping prices.

### Shipping Quotes

[](#shipping-quotes)

#### Retrieve all shipping rates, for all enabled shipping providers.

[](#retrieve-all-shipping-rates-for-all-enabled-shipping-providers)

```
$exceptions = [];

$rates = app(\Mitrik\Shipping\Facades\Shipping::class)->rates(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '321 Lakeshore Rd W',
        '',
        'Mississauga',
        'L5H 1G0',
        'ON',
        'CA'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '100 City Centre Dr',
        '',
        'Mississauga',
        'L5B 2C9',
        'ON',
        'CA'
    ),
    new \Mitrik\Shipping\ServiceProviders\Box\BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ]),
    $exceptions
);
```

Fourth parameter `$exceptions` is optional. If provided function will push all exception to provided array. If not provided, an exception will be thrown each time there is an issue retrieving a quote.

##### Canada Post

[](#canada-post)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPost;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPostCredentials;

$credentials = new ServiceCanadaPostCredentials(env('CANADA_POST_CUSTOMER_NUMBER'), env('CANADA_POST_USERNAME'), env('CANADA_POST_PASSWORD'));
$canadaPost = new ServiceCanadaPost($credentials);

$rates = $canadaPost->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '321 Lakeshore Rd W',
        '',
        'Mississauga',
        'L5H 1G0',
        'ON',
        'CA'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '100 City Centre Dr',
        '',
        'Mississauga',
        'L5B 2C9',
        'ON',
        'CA'
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ])
);
```

#### Purolator

[](#purolator)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolator;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolatorCredentials;

$credentials = new ServicePurolatorCredentials(env('PUROLATOR_KEY'), env('PUROLATOR_PASSWORD'), env('PUROLATOR_BILLING_ACCOUNT'), env('PUROLATOR_REGISTERED_ACCOUNT'), env('PUROLATOR_USER_TOKEN'), env('PUROLATOR_SANDBOX'));
$purolator = new ServicePurolator($credentials);

$rates = $purolator->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '321 Lakeshore Rd W',
        '',
        'Mississauga',
        'L5H 1G0',
        'ON',
        'CA'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '100 City Centre Dr',
        '',
        'Mississauga',
        'L5B 2C9',
        'ON',
        'CA'
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ])
);
```

#### UPS

[](#ups)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPS;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPSCredentials;

$credentials = new ServiceUPSCredentials(env('UPS_ACCESS_KEY'), env('UPS_USER_ID'), env('UPS_PASSWORD'));
$serviceUPS = new ServiceUPS($credentials);

$rates = $serviceUPS->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '321 Lakeshore Rd W',
        '',
        'Mississauga',
        'L5H 1G0',
        'ON',
        'CA'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '100 City Centre Dr',
        '',
        'Mississauga',
        'L5B 2C9',
        'ON',
        'CA'
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ])
);
```

#### USPS

[](#usps)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceUSPS\ServiceUSPS;
use Mitrik\Shipping\ServiceProviders\ServiceUSPS\ServiceUSPSCredentials;

$credentials = new ServiceUSPSCredentials(env('USPS_CLIENT_ID'), env('USPS_CLIENT_SECRET'));
$usps = new ServiceUSPS($credentials);

$rates = $usps->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '1 Wall St',
        '',
        'New York',
        '10005',
        'NY',
        'US'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '1 Wall St',
        '',
        'New York',
        '10005',
        'NY',
        'US'
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ])
);
```

#### FedEx

[](#fedex)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedEx;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedExCredentials;

$credentials = new ServiceFedExCredentials(env('FEDEX_CLIENT_ID'), env('FEDEX_CLIENT_SECRET'), env('FEDEX_ACCOUNT_NUMBER'));
$fedEx = new ServiceFedEx($credentials);

$rates = $fedEx->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '1 Wall St',
        '',
        'New York',
        '10005',
        'NY',
        'US'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '1 Wall St',
        '',
        'New York',
        '10005',
        'NY',
        'US'
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ])
);
```

#### Flat

[](#flat)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceFlat\ServiceFlat;

$flat = new ServiceFlat();

$rates = $flat->rate(
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '321 Lakeshore Rd W',
        '',
        'Mississauga',
        'L5H 1G0',
        'ON',
        'CA'
    ),
    new Address(
        'Ivan',
        'Mitrikeski',
        '',
        '100 City Centre Dr',
        '',
        'Mississauga',
        'L5B 2C9',
        'ON',
        'CA'
    ),
    new BoxCollection([
        new BoxMetric(35, 26, 5, 1)
    ])
);
```

#### Creating shipping boxes

[](#creating-shipping-boxes)

```
$modelShippingBox = new ShippingBox();
$modelShippingBox->length = 35;
$modelShippingBox->width = 26;
$modelShippingBox->height = 5;
$modelShippingBox->max_weight = 5;
$modelShippingBox->save();
```

#### Creating shipping option for Flat service

[](#creating-shipping-option-for-flat-service)

```
$modelShippingService = ShippingService::whereName('Flat')->first();

$modelShippingOption = new ShippingOption();
$modelShippingOption->shipping_service_id = $modelShippingService->id;
$modelShippingOption->code = 'FREE.PICKUP';
$modelShippingOption->name = 'Free Pickup';
$modelShippingOption->is_enabled = true;
$modelShippingOption->is_internal = false;
$modelShippingOption->save();
```

#### Creating Flat service prices

[](#creating-flat-service-prices)

```
$modelShippingBox = ShippingBox::whereUuid('SOME_BOX_UUID')->first();
$modelShippingOption = ShippingOption::whereUuid('SOME_OPTION_UUID')->first();

$modelShippingOptionPrice = new ShippingOptionPrice();
$modelShippingOptionPrice->shipping_box_id = $modelShippingBox->id;
$modelShippingOptionPrice->shipping_option_id = $modelShippingOption->id;
$modelShippingOptionPrice->shipping_service_id = $modelShippingOption->shipping_service_id;
$modelShippingOptionPrice->price = 10.99;
$modelShippingOptionPrice->save();
```

### Creating Shipments

[](#creating-shipments)

##### Canada Post

[](#canada-post-1)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPost;
use Mitrik\Shipping\ServiceProviders\ServiceCanadaPost\ServiceCanadaPostCredentials;

$credentials = new ServiceCanadaPostCredentials(env('CANADA_POST_CUSTOMER_NUMBER'), env('CANADA_POST_USERNAME'), env('CANADA_POST_PASSWORD'));
$canadaPost = new ServiceCanadaPost($credentials);

$result = $canadaPost->ship(
    new ShipFrom(
        name: 'Ivan Mitrikeski',
        attentionName: 'Ivan Mitrikeski',
        address: new Address(
            'Ivan',
            'Mitrikeski',
            '',
            '321 Lakeshore Rd W',
            '',
            'Mississauga',
            'L5H 1G0',
            'ON',
            'CA'
        ),
        phone: new Phone('+1', '555', '1231234'),
        company: 'Test'
    ),
    new ShipTo(
        'John Smith',
        'John Smith',
        new Address(
            'John',
            'Smith',
            '',
            '100 City Centre Dr',
            '',
            'Mississauga',
            'L5B 2C9',
            'ON',
            'CA'
        ),
        new Phone('+1', '555', '1231234')
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ]),
    new ServiceProviderService('DOM.RP', ''),
    null,
    [
        'delivery-spec' => [
            'settlement-info' => [
                'contract-id' => '0042708517'
            ]
        ]
    ]
);
```

#### Purolator

[](#purolator-1)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolator;
use Mitrik\Shipping\ServiceProviders\ServicePurolator\ServicePurolatorCredentials;

$credentials = new ServicePurolatorCredentials(env('PUROLATOR_KEY'), env('PUROLATOR_PASSWORD'), env('PUROLATOR_BILLING_ACCOUNT'), env('PUROLATOR_REGISTERED_ACCOUNT'), env('PUROLATOR_USER_TOKEN'), env('PUROLATOR_SANDBOX'));
$purolator = new ServicePurolator($credentials);

$result = $purolator->ship(
    new ShipFrom(
        'Ivan Mitrikeski',
        'Ivan Mitrikeski',
        new Address(
            'Ivan',
            'Mitrikeski',
            '',
            '321 Lakeshore Rd W',
            '',
            'Mississauga',
            'L5H 1G0',
            'ON',
            'CA'
        ),
        new Phone('+1', '555', '1231234'),
        ''
    ),
    new ShipTo(
        'John Smith',
        'John Smith',
        new Address(
            'John',
            'Smith',
            '',
            '100 City Centre Dr',
            '',
            'Mississauga',
            'L5B 2C9',
            'ON',
            'CA'
        ),
        new Phone('+1', '555', '1231234')
    ),
    new BoxCollection([
        new BoxMetric(20, 10, 5, 1)
    ]),
    new ServiceProviderService('PurolatorExpress', '')
);
```

#### UPS

[](#ups-1)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPS;
use Mitrik\Shipping\ServiceProviders\ServiceUPS\ServiceUPSCredentials;

$credentials = new ServiceUPSCredentials(env('UPS_ACCESS_KEY'), env('UPS_USER_ID'), env('UPS_PASSWORD'));
$serviceUPS = new ServiceUPS($credentials);

$result = $serviceUPS->ship(
    new ShipFrom(
        'Ivan Mitrikeski',
        'Ivan Mitrikeski',
        new Address(
            'Ivan',
            'Mitrikeski',
            '',
            '1 Wall St',
            '',
            'New York',
            '10005',
            'NY',
            'US'
        ),
        new Phone('+1', '555', '1231234'),
        ''
    ),
    new ShipTo(
        'John Smith',
        'John Smith',
        new Address(
            'John',
            'Smith',
            '',
            '1 Wall St',
            '',
            'New York',
            '10005',
            'NY',
            'US'
        ),
        new Phone('+1', '555', '1231234')
    ),
    new BoxCollection([
        new BoxImperial(20, 10, 5, 1)
    ]),
    new ServiceProviderService('03', '')
);
```

#### FedEx

[](#fedex-1)

```
use Mitrik\Shipping\ServiceProviders\Address\Address;
use Mitrik\Shipping\ServiceProviders\Box\BoxCollection;
use Mitrik\Shipping\ServiceProviders\Box\BoxMetric;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedEx;
use Mitrik\Shipping\ServiceProviders\ServiceFedEx\ServiceFedExCredentials;

$credentials = new ServiceFedExCredentials(env('FEDEX_CLIENT_ID'), env('FEDEX_CLIENT_SECRET'), env('FEDEX_ACCOUNT_NUMBER'));
$fedEx = new ServiceFedEx($credentials);

$result = $fedEx->ship(
    new ShipFrom(
        'Ivan Mitrikeski',
        'Ivan Mitrikeski',
        new Address(
            'Ivan',
            'Mitrikeski',
            '',
            '1 Wall St',
            '',
            'New York',
            '10005',
            'NY',
            'US'
        ),
        new Phone('+1', '555', '1231234'),
        ''
    ),
    new ShipTo(
        'John Smith',
        'John Smith',
        new Address(
            'John',
            'Smith',
            '',
            '1 Wall St',
            '',
            'New York',
            '10005',
            'NY',
            'US'
        ),
        new Phone('+1', '555', '1231234')
    ),
    new BoxCollection([
        new BoxImperial(20, 10, 5, 1)
    ]),
    new ServiceProviderService('FEDEX_2_DAY', '')
);
```

Testing
=======

[](#testing)

Update phpunit.xml env variables before running tests.

```

```

```
composer test
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance87

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Recently: every ~140 days

Total

10

Last Release

63d ago

PHP version history (3 changes)v1.0.0PHP &gt;=8.1

v1.0.5PHP &gt;=8.2

v1.0.9PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c69a8c5f0d3506251fc2363e0f2cbeb68ce145a8f5d214bd16db8fc58f93090?d=identicon)[ivanmitrikeski](/maintainers/ivanmitrikeski)

---

Top Contributors

[![ivanmitrikeski](https://avatars.githubusercontent.com/u/20203950?v=4)](https://github.com/ivanmitrikeski "ivanmitrikeski (13 commits)")[![alexfraundorf-com](https://avatars.githubusercontent.com/u/3129371?v=4)](https://github.com/alexfraundorf-com "alexfraundorf-com (1 commits)")

---

Tags

canadapostfedexlaravelphppurolatorratingrestshippingupsuspslaravelrestRateshippingRatinguspsupsFedExpurolatorcanadapost

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivanmitrikeski-laravel-shipping/health.svg)

```
[![Health](https://phpackages.com/badges/ivanmitrikeski-laravel-shipping/health.svg)](https://phpackages.com/packages/ivanmitrikeski-laravel-shipping)
```

###  Alternatives

[gabrielbull/ups-api

PHP UPS API

4642.4M10](/packages/gabrielbull-ups-api)[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[gavroche/ups-api

PHP UPS API

45613.2k](/packages/gavroche-ups-api)[whatarmy/fedex-rest

New FedEx Rest API wrapper

2440.5k1](/packages/whatarmy-fedex-rest)[cybercog/youtrack-rest-php

YouTrack REST API PHP Client.

37149.2k3](/packages/cybercog-youtrack-rest-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
