Example #1
0
 /**
  * Makes remote request to the carrier and returns a response
  *
  * @param string $purpose
  * @return mixed
  */
 protected function _doRatesRequest($purpose)
 {
     if (!Mage::getStoreConfig('shipping/shipusa/active')) {
         return Mage_Usa_Model_Shipping_Carrier_Fedex::_doRatesRequest($purpose);
     }
     $this->_handlingProductFee = 0;
     $ratesRequest = $this->_formRateRequest($purpose);
     $requestString = serialize($ratesRequest);
     $response = $this->_getCachedQuotes($requestString);
     $debugData = array('request' => $ratesRequest);
     if ($response === null) {
         try {
             $client = $this->_createRateSoapClient();
             $response = $client->getRates($ratesRequest);
             $this->_setCachedQuotes($requestString, serialize($response));
             $debugData['result'] = $response;
         } catch (Exception $e) {
             $debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
             Mage::logException($e);
             if ($this->getDebugFlag()) {
                 Mage::helper('wsalogger/log')->postCritical('usashipping', 'Fedex Soap Exception', $e->getMessage());
             }
         }
     } else {
         $response = unserialize($response);
         $debugData['result'] = $response;
     }
     $this->_debug($debugData);
     if ($this->getDebugFlag()) {
         Mage::helper('wsalogger/log')->postInfo('usashipping', 'Fedex Soap Request/Response', $debugData);
         Mage::helper('wsalogger/log')->postInfo('usashipping', 'Handing Fee', $this->_handlingProductFee);
     }
     return $response;
 }