Пример #1
0
 /**
  * @expectedException \Exception
  */
 public function testGetRateInvalidShipment()
 {
     $shipment = new \stdClass();
     $shipment->Shipper = new \stdClass();
     $shipment->Shipper->Name = 'Test Shipper';
     $shipment->Shipper->ShipperNumber = '12345';
     $shipment->Shipper->Address = new \stdClass();
     $shipment->Shipper->Address->AddressLine1 = '123 Some St.';
     $shipment->Shipper->Address->City = 'Test';
     $shipment->Shipper->Address->PostalCode = '12345';
     $shipment->Shipper->Address->StateProvinceCode = 'WA';
     $shipment->ShipTo = new \stdClass();
     $shipment->ShipTo->CompanyName = 'Test ShipTo';
     $shipment->ShipTo->Address = new \stdClass();
     $shipment->ShipTo->Address->AddressLine1 = '1234 Some St.';
     $shipment->ShipTo->Address->City = 'Other City';
     $shipment->ShipTo->Address->PostalCode = '12345';
     $shipment->ShipTo->Address->StateProvinceCode = 'WA';
     $shipment->Service = new \stdClass();
     $shipment->Service->Code = '03';
     $package = new \stdClass();
     $package->PackagingType = new \stdClass();
     $package->PackagingType->Code = '02';
     $package->PackageWeight = new \stdClass();
     $package->PackageWeight->Weight = '10';
     $shipment->Package = array($package);
     // should throw exception cause invalid zip code
     $this->rate->getRate($shipment);
 }
Пример #2
0
 /**
  * Return calculated price for this shipping method
  * @param IsotopeProductCollection
  * @return float
  */
 protected function getLiveRateQuote(IsotopeProductCollection $objCollection)
 {
     $fltPrice = 0.0;
     //get a hash for the cache
     $strHash = static::makeHash($objCollection, array($this->ups_enabledService));
     if (!Cache::has($strHash)) {
         //Build shipment
         $Shipment = $this->buildShipmentFromCollection($objCollection);
         //Get Iso Config
         $Config = Isotope::getConfig();
         //UPS Rate Object
         $UPS = new Ups_Rate($Config->UpsAccessKey, $Config->UpsUsername, $Config->UpsPassword, $Config->UpsMode == 'test' ? true : false);
         try {
             $objResponse = $UPS->getRate($Shipment);
             $fltPrice = (double) $objResponse->RatedShipment[0]->TotalCharges->MonetaryValue;
         } catch (\Exception $e) {
             //@!TODO post error message
         }
         Cache::set($strHash, $fltPrice);
     }
     return Cache::get($strHash);
 }
Пример #3
0
 /**
  * @param ResponseInterface $response
  *
  * @return $this
  */
 public function setResponse(ResponseInterface $response)
 {
     $this->upsRate->setResponse($response);
     return $this;
 }