2017 © Pedro Peláez
 

library pop-shipping

Pop Shipping Component for Pop PHP Framework

image

popphp/pop-shipping

Pop Shipping Component for Pop PHP Framework

  • Thursday, March 2, 2017
  • by nicksagona
  • Repository
  • 1 Watchers
  • 3 Stars
  • 582 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 1 % Grown

The README.md

pop-shipping

Join the chat at https://discord.gg/TZjgT74U7E, (*1)

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:, (*2)

  • FedEx
  • UPS

Also, it provides address validation through the Google Maps API., (*3)

Top, (*4)

Install

Install pop-shipping using Composer., (*5)

composer require popphp/pop-shipping

Or, require it in your composer.json file, (*6)

"require": {
    "popphp/pop-shipping" : "^3.0.0"
}

Top, (*7)

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());
}

Top, (*8)

The Versions

02/03 2017

dev-master

9999999-dev http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

02/03 2017

2.1.0p1

2.1.0.0-patch1 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

01/07 2016

2.1.0

2.1.0.0 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

10/05 2016

2.0.0p5

2.0.0.0-patch5 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

25/02 2016

2.0.0p4

2.0.0.0-patch4 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

25/02 2016

2.0.0p3

2.0.0.0-patch3 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

25/02 2016

2.0.0p2

2.0.0.0-patch2 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

19/02 2016

2.0.0p1

2.0.0.0-patch1 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates

20/07 2015

2.0.0

2.0.0.0 http://www.popphp.org/

Pop Shipping Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

The Development Requires

php shipping pop pop php shipping rates calculate shipping rates