popphp / pop-shipping
This package is abandoned and no longer maintained.
No replacement package was suggested.
Pop Shipping Component for Pop PHP Framework
3.0.0
2025-07-07 16:04 UTC
Requires
- php: >=8.2.0
- popphp/pop-http: ^5.3.3
Requires (Dev)
- phpunit/phpunit: ^11.5.0
This package is auto-updated.
Last update: 2025-07-07 16:04:41 UTC
README
Overview
Pop Shipping is a helpful component to manage different shipping APIs from common shipping providers. With it, you can get shipping rates as well as track packages. Currently, the supported shipping providers are:
- FedEx
- UPS
Also, it provides address validation through the Google Maps API.
Install
Install pop-shipping
using Composer.
composer require popphp/pop-shipping
Or, require it in your composer.json file
"require": {
"popphp/pop-shipping" : "^3.0.0"
}
Create Auth Client
FedEx
$authClient = Pop\Shipping\Auth\Fedex::createAuthClient( 'CLIENT_ID', 'SECRET', 'ACCOUNT_ID' );
UPS
$authClient = Pop\Shipping\Auth\Fedex::createAuthClient( 'CLIENT_ID', 'SECRET', 'ACCOUNT_ID' );
Authenticate and store token
if ($authClient->hasTokenDataFile(__DIR__ . '/../data/access.json')) { $authClient->fetchAuthToken(__DIR__ . '/../data/access.json'); } else { $authClient->authenticate(__DIR__ . '/../data/access.json'); }
Create Shipping Adapter
FedEx
$adapter = Pop\Shipping\Adapter\Fedex::createAdapter($authClient);
UPS
$adapter = Pop\Shipping\Adapter\Ups::createAdapter($authClient);
Get Rates
$shipping = new Pop\Shipping\Shipping($adapter); $shipping->setShipTo([ 'first_name' => 'John', 'last_name' => 'Doe', 'address1' => '123 Main St', 'city' => 'Some Town', 'state' => 'FL', 'zip' => '12345', 'residential' => true, ]); $shipping->setShipFrom([ 'first_name' => 'Jane', 'last_name' => 'Doe', 'address1' => '456 Main St', 'city' => 'Main Town', 'state' => 'GA', 'zip' => '54321' ]); $shipping->addPackage(new Pop\Shipping\Package(34, 24, 12, 65, 1000)); print_r($shipping->getRates());
Get Tracking
$shipping->addTrackingNumbers([ '11111111111111', '11111111111112', '11111111111113' ]); print_r($shipping->getTracking());
Validate Address
$google = new Pop\Shipping\Adapter\Google('GOOGLE_API_KEY'); $google->setOriginalAddress([ 'address1' => '123 Bad St.', 'city' => 'Wrong Town', 'state' => 'FL', 'postal_code' => '12345' ]); if ($google->validate()) { echo 'Address has been confirmed.' } else { print_r($google->getSuggestedAddress()); }