Commenting out TLSv1 from cipher list that was causing problems. Updating readme. resolves #8.

pull/11/head
Jamie Isaacs 10 years ago
parent 6233359c57
commit d1281805ea

@ -1,6 +1,6 @@
## PHP Shipping API ## PHP Shipping API
![Test Coverage](http://img.shields.io/badge/coverage-85%25-green.svg) ![Test Coverage](http://img.shields.io/badge/coverage-86%25-green.svg)
[![Build Status](https://travis-ci.org/pdt256/shipping.svg?branch=master)](https://travis-ci.org/pdt256/shipping) [![Build Status](https://travis-ci.org/pdt256/shipping.svg?branch=master)](https://travis-ci.org/pdt256/shipping)
[![Downloads](https://img.shields.io/packagist/dt/pdt256/shipping.svg)](https://packagist.org/packages/pdt256/shipping) [![Downloads](https://img.shields.io/packagist/dt/pdt256/shipping.svg)](https://packagist.org/packages/pdt256/shipping)
[![License](https://img.shields.io/packagist/l/pdt256/shipping.svg)](https://github.com/pdt256/shipping/blob/master/LICENSE.txt) [![License](https://img.shields.io/packagist/l/pdt256/shipping.svg)](https://github.com/pdt256/shipping/blob/master/LICENSE.txt)
@ -40,9 +40,9 @@ $shipment
->setFromStateProvinceCode('IN') ->setFromStateProvinceCode('IN')
->setFromPostalCode('46205') ->setFromPostalCode('46205')
->setFromCountryCode('US') ->setFromCountryCode('US')
->setToIsResidential(true); ->setToIsResidential(true)
->setToPostalCode('20101') ->setToPostalCode('20101')
->setToCountryCode('US') ->setToCountryCode('US');
$package = new Package; $package = new Package;
$package $package
@ -70,7 +70,7 @@ use pdt256\Shipping\UPS;
use pdt256\Shipping\RateRequest; use pdt256\Shipping\RateRequest;
$ups = new UPS\Rate([ $ups = new UPS\Rate([
'prod' => FALSE, 'prod' => false,
'accessKey' => 'XXXX', 'accessKey' => 'XXXX',
'userId' => 'XXXX', 'userId' => 'XXXX',
'password' => 'XXXX', 'password' => 'XXXX',
@ -86,74 +86,50 @@ $ups = new UPS\Rate([
'requestAdapter' => new RateRequest\StubUPS(), 'requestAdapter' => new RateRequest\StubUPS(),
]); ]);
$upsRates = $ups->getRates(); $rates = $ups->getRates();
``` ```
Output array sorted by cost: (in cents) Output array sorted by cost: (in cents)
```php ```php
array(4) { array (
[0] => 0 =>
class pdt256\Shipping\Quote#56 (6) { pdt256\Shipping\Quote::__set_state(array(
protected $code => 'code' => '03',
string(2) "03" 'name' => 'UPS Ground',
protected $name => 'cost' => 1910,
string(10) "UPS Ground" 'transitTime' => NULL,
protected $cost => 'deliveryEstimate' => NULL,
int(1900) 'carrier' => 'ups',
protected $transitTime => )),
NULL 1 =>
protected $deliveryTime => pdt256\Shipping\Quote::__set_state(array(
NULL 'code' => '02',
protected $carrier => 'name' => 'UPS 2nd Day Air',
string(3) "ups" 'cost' => 4923,
} 'transitTime' => NULL,
[1] => 'deliveryEstimate' => NULL,
class pdt256\Shipping\Quote#58 (6) { 'carrier' => 'ups',
protected $code => )),
string(2) "02" 2 =>
protected $name => pdt256\Shipping\Quote::__set_state(array(
string(15) "UPS 2nd Day Air" 'code' => '13',
protected $cost => 'name' => 'UPS Next Day Air Saver',
int(4900) 'cost' => 8954,
protected $transitTime => 'transitTime' => NULL,
NULL 'deliveryEstimate' => NULL,
protected $deliveryTime => 'carrier' => 'ups',
NULL )),
protected $carrier => 3 =>
string(3) "ups" pdt256\Shipping\Quote::__set_state(array(
} 'code' => '01',
[2] => 'name' => 'UPS Next Day Air',
class pdt256\Shipping\Quote#57 (6) { 'cost' => 9328,
protected $code => 'transitTime' => NULL,
string(2) "13" 'deliveryEstimate' => NULL,
protected $name => 'carrier' => 'ups',
string(22) "UPS Next Day Air Saver" )),
protected $cost => )
int(8900)
protected $transitTime =>
NULL
protected $deliveryTime =>
NULL
protected $carrier =>
string(3) "ups"
}
[3] =>
class pdt256\Shipping\Quote#55 (6) {
protected $code =>
string(2) "01"
protected $name =>
string(16) "UPS Next Day Air"
protected $cost =>
int(9300)
protected $transitTime =>
NULL
protected $deliveryTime =>
NULL
protected $carrier =>
string(3) "ups"
}
}
``` ```
## USPS (Stub) Example ## USPS (Stub) Example
@ -163,7 +139,7 @@ use pdt256\Shipping\USPS;
use pdt256\Shipping\RateRequest; use pdt256\Shipping\RateRequest;
$usps = new USPS\Rate([ $usps = new USPS\Rate([
'prod' => FALSE, 'prod' => false,
'username' => 'XXXX', 'username' => 'XXXX',
'password' => 'XXXX', 'password' => 'XXXX',
'shipment' => $shipment, 'shipment' => $shipment,
@ -174,44 +150,32 @@ $usps = new USPS\Rate([
'requestAdapter' => new RateRequest\StubUSPS(), 'requestAdapter' => new RateRequest\StubUSPS(),
]); ]);
$uspsRates = $usps->getRates(); $rates = $usps->getRates();
``` ```
Output array sorted by cost: (in cents) Output array sorted by cost: (in cents)
```php ```php
array(2) { array (
[0] => 0 =>
class pdt256\Shipping\Quote#30 (6) { pdt256\Shipping\Quote::__set_state(array(
protected $code => 'code' => '4',
string(1) "4" 'name' => 'Parcel Post',
protected $name => 'cost' => 1001,
string(11) "Parcel Post" 'transitTime' => NULL,
protected $cost => 'deliveryEstimate' => NULL,
int(1001) 'carrier' => 'usps',
protected $transitTime => )),
NULL 1 =>
protected $deliveryTime => pdt256\Shipping\Quote::__set_state(array(
NULL 'code' => '1',
protected $carrier => 'name' => 'Priority Mail',
string(4) "usps" 'cost' => 1220,
} 'transitTime' => NULL,
[1] => 'deliveryEstimate' => NULL,
class pdt256\Shipping\Quote#26 (6) { 'carrier' => 'usps',
protected $code => )),
string(1) "1" )
protected $name =>
string(13) "Priority Mail"
protected $cost =>
int(1220)
protected $transitTime =>
NULL
protected $deliveryTime =>
NULL
protected $carrier =>
string(4) "usps"
}
}
``` ```
## Fedex (Stub) Example ## Fedex (Stub) Example
@ -238,95 +202,65 @@ $fedex = new Fedex\Rate([
'requestAdapter' => new RateRequest\StubFedex(), 'requestAdapter' => new RateRequest\StubFedex(),
]); ]);
$fedexRates = $fedex->getRates(); $rates = $fedex->getRates();
``` ```
Output array sorted by cost: (in cents) Output array sorted by cost: (in cents)
```php ```php
array(4) { array (
[0] => 0 =>
class pdt256\Shipping\Quote#65 (6) { pdt256\Shipping\Quote::__set_state(array(
protected $code => 'code' => 'GROUND_HOME_DELIVERY',
string(20) "GROUND_HOME_DELIVERY" 'name' => 'Ground Home Delivery',
protected $name => 'cost' => 1655,
string(20) "Ground Home Delivery" 'transitTime' => 'THREE_DAYS',
protected $cost => 'deliveryEstimate' => NULL,
int(1600) 'carrier' => 'fedex',
protected $transitTime => )),
string(10) "THREE_DAYS" 1 =>
protected $deliveryTime => pdt256\Shipping\Quote::__set_state(array(
NULL 'code' => 'FEDEX_EXPRESS_SAVER',
protected $carrier => 'name' => 'Fedex Express Saver',
string(5) "fedex" 'cost' => 2989,
} 'transitTime' => NULL,
[1] => 'deliveryEstimate' =>
class pdt256\Shipping\Quote#63 (6) { DateTime::__set_state(array(
protected $code => 'date' => '2014-09-30 20:00:00',
string(19) "FEDEX_EXPRESS_SAVER" 'timezone_type' => 3,
protected $name => 'timezone' => 'UTC',
string(19) "Fedex Express Saver" )),
protected $cost => 'carrier' => 'fedex',
int(2900) )),
protected $transitTime => 2 =>
NULL pdt256\Shipping\Quote::__set_state(array(
protected $deliveryTime => 'code' => 'FEDEX_2_DAY',
class Carbon\Carbon#23 (3) { 'name' => 'Fedex 2 Day',
public $date => 'cost' => 4072,
string(26) "2014-09-30 20:00:00.000000" 'transitTime' => NULL,
public $timezone_type => 'deliveryEstimate' =>
int(3) DateTime::__set_state(array(
public $timezone => 'date' => '2014-09-29 20:00:00',
string(16) "America/New_York" 'timezone_type' => 3,
} 'timezone' => 'UTC',
protected $carrier => )),
string(5) "fedex" 'carrier' => 'fedex',
} )),
[2] => 3 =>
class pdt256\Shipping\Quote#61 (6) { pdt256\Shipping\Quote::__set_state(array(
protected $code => 'code' => 'STANDARD_OVERNIGHT',
string(11) "FEDEX_2_DAY" 'name' => 'Standard Overnight',
protected $name => 'cost' => 7834,
string(11) "Fedex 2 Day" 'transitTime' => NULL,
protected $cost => 'deliveryEstimate' =>
int(4000) DateTime::__set_state(array(
protected $transitTime => 'date' => '2014-09-26 20:00:00',
NULL 'timezone_type' => 3,
protected $deliveryTime => 'timezone' => 'UTC',
class Carbon\Carbon#26 (3) { )),
public $date => 'carrier' => 'fedex',
string(26) "2014-09-29 20:00:00.000000" )),
public $timezone_type => )
int(3)
public $timezone =>
string(16) "America/New_York"
}
protected $carrier =>
string(5) "fedex"
}
[3] =>
class pdt256\Shipping\Quote#60 (6) {
protected $code =>
string(18) "STANDARD_OVERNIGHT"
protected $name =>
string(18) "Standard Overnight"
protected $cost =>
int(7800)
protected $transitTime =>
NULL
protected $deliveryTime =>
class Carbon\Carbon#58 (3) {
public $date =>
string(26) "2014-09-26 20:00:00.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(16) "America/New_York"
}
protected $carrier =>
string(5) "fedex"
}
}
``` ```
## Unit Tests: ## Unit Tests:

@ -12,7 +12,7 @@ class Get extends Adapter
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); //curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curlConnectTimeoutInMilliseconds); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curlConnectTimeoutInMilliseconds);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->curlDownloadTimeoutInSeconds); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curlDownloadTimeoutInSeconds);
$response = curl_exec($ch); $response = curl_exec($ch);

@ -13,7 +13,7 @@ class Post extends Adapter
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1'); //curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curlConnectTimeoutInMilliseconds); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->curlConnectTimeoutInMilliseconds);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->curlDownloadTimeoutInSeconds); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curlDownloadTimeoutInSeconds);
$response = curl_exec($ch); $response = curl_exec($ch);

@ -29,4 +29,99 @@ class ShipmentTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('90210', $shipment->getToPostalCode()); $this->assertEquals('90210', $shipment->getToPostalCode());
$this->assertEquals('US', $shipment->getToCountryCode()); $this->assertEquals('US', $shipment->getToCountryCode());
} }
private function getShipment()
{
$shipment = new Shipment;
$shipment
->setFromIsResidential(false)
->setFromStateProvinceCode('IN')
->setFromPostalCode('46205')
->setFromCountryCode('US')
->setToIsResidential(true)
->setToPostalCode('20101')
->setToCountryCode('US');
$package = new Package;
$package
->setLength(12)
->setWidth(4)
->setHeight(3)
->setWeight(3);
$shipment->addPackage($package);
return $shipment;
}
public function xtestUPSStubForReadme()
{
$shipment = $this->getShipment();
$ups = new UPS\Rate([
'prod' => false,
'accessKey' => 'XXXX',
'userId' => 'XXXX',
'password' => 'XXXX',
'shipperNumber' => 'XXXX',
'shipment' => $shipment,
'approvedCodes' => [
'03', // 1-5 business days
'02', // 2 business days
'01', // next business day 10:30am
'13', // next business day by 3pm
'14', // next business day by 8am
],
'requestAdapter' => new RateRequest\StubUPS(),
]);
$rates = $ups->getRates();
var_export($rates);
}
public function xtestUSPSStubForReadme()
{
$shipment = $this->getShipment();
$usps = new USPS\Rate([
'prod' => false,
'username' => 'XXXX',
'password' => 'XXXX',
'shipment' => $shipment,
'approvedCodes' => [
'1', // 1-3 business days
'4', // 2-8 business days
],
'requestAdapter' => new RateRequest\StubUSPS(),
]);
$rates = $usps->getRates();
var_export($rates);
}
public function xtestFedexStubForReadme()
{
$shipment = $this->getShipment();
$fedex = new Fedex\Rate([
'prod' => false,
'key' => 'XXXX',
'password' => 'XXXX',
'accountNumber' => 'XXXX',
'meterNumber' => 'XXXX',
'dropOffType' => 'BUSINESS_SERVICE_CENTER',
'shipment' => $shipment,
'approvedCodes' => [
'FEDEX_EXPRESS_SAVER', // 1-3 business days
'FEDEX_GROUND', // 1-5 business days
'GROUND_HOME_DELIVERY', // 1-5 business days
'FEDEX_2_DAY', // 2 business days
'STANDARD_OVERNIGHT', // overnight
],
'requestAdapter' => new RateRequest\StubFedex(),
]);
$rates = $fedex->getRates();
var_export($rates);
}
} }

Loading…
Cancel
Save