当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Http_Client::setConfig方法代码示例

本文整理汇总了PHP中Varien_Http_Client::setConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Http_Client::setConfig方法的具体用法?PHP Varien_Http_Client::setConfig怎么用?PHP Varien_Http_Client::setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Http_Client的用法示例。


在下文中一共展示了Varien_Http_Client::setConfig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getTransactionDetails

 /**
  * This function returns full transaction details for a specified transaction ID.
  *
  * @link http://www.authorize.net/support/ReportingGuide_XML.pdf
  * @link http://developer.authorize.net/api/transaction_details/
  * @param string $transactionId
  * @return Varien_Object
  */
 protected function _getTransactionDetails($transactionId)
 {
     $requestBody = sprintf('<?xml version="1.0" encoding="utf-8"?>' . '<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">' . '<merchantAuthentication><name>%s</name><transactionKey>%s</transactionKey></merchantAuthentication>' . '<transId>%s</transId>' . '</getTransactionDetailsRequest>', $this->getConfigData('login'), $this->getConfigData('trans_key'), $transactionId);
     $client = new Varien_Http_Client();
     $uri = $this->getConfigData('cgi_url_td');
     $client->setUri($uri ? $uri : self::CGI_URL_TD);
     $client->setConfig(array('timeout' => 45));
     $client->setHeaders(array('Content-Type: text/xml'));
     $client->setMethod(Zend_Http_Client::POST);
     $client->setRawData($requestBody);
     $debugData = array('request' => $requestBody);
     try {
         $responseBody = $client->request()->getBody();
         $debugData['result'] = $responseBody;
         $this->_debug($debugData);
         libxml_use_internal_errors(true);
         $responseXmlDocument = new Varien_Simplexml_Element($responseBody);
         libxml_use_internal_errors(false);
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('paygate')->__('Payment updating error.'));
     }
     $response = new Varien_Object();
     $response->setResponseCode((string) $responseXmlDocument->transaction->responseCode)->setResponseReasonCode((string) $responseXmlDocument->transaction->responseReasonCode);
     return $response;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:33,代码来源:Authorizenet.php

示例2: _postRequest

 /**
  *  Send request to gateway
  *
  *  @param    Mage_Chronopay_Model_Gateway_Request
  *  @return	  mixed
  */
 protected function _postRequest(Mage_Chronopay_Model_Gateway_Request $request)
 {
     $result = Mage::getModel('chronopay/gateway_result');
     $client = new Varien_Http_Client();
     $url = $this->getConfigData('cgi_url');
     $client->setUri($url ? $url : self::CGI_URL);
     $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
     $client->setParameterPost($request->getData());
     $client->setMethod(Zend_Http_Client::POST);
     $debugData = array('request' => $request->getData());
     try {
         $response = $client->request();
         $body = $response->getRawBody();
         if (preg_match('/(T\\|(.+)\\|[\\r\\n]{0,}){0,1}(Y\\|(.+)?|\\|)|(N\\|(.+[\\r\\n]{0,}.+){0,})/', $body, $matches)) {
             $transactionId = $matches[2];
             $message = isset($matches[4]) ? trim($matches[4], '|') : '';
             if (isset($matches[5], $matches[6])) {
                 $result->setError($matches[6]);
                 Mage::throwException($matches[6]);
             }
             if ($message == 'Completed') {
                 $result->setTransaction($request->getTransaction());
             }
             if (strlen($transactionId)) {
                 $result->setTransaction($transactionId);
             }
             if (!$result->getTransaction()) {
                 Mage::throwException(Mage::helper('chronopay')->__('The transaction ID is invalid.'));
             }
         } else {
             Mage::throwException(Mage::helper('chronopay')->__('Invalid response format.'));
         }
     } catch (Exception $e) {
         $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
         $exceptionMsg = Mage::helper('chronopay')->__('Gateway request error: %s', $e->getMessage());
         $debugData['result'] = $result->getData();
         $this->_debug($debugData);
         Mage::throwException($exceptionMsg);
     }
     $debugData['result'] = $result->getData();
     $this->_debug($debugData);
     return $result;
 }
开发者ID:jweiss,项目名称:Magento-Example,代码行数:49,代码来源:Gateway.php

示例3: _postRequest

 protected function _postRequest(Varien_Object $request)
 {
     $debugData = array('request' => $request->getData());
     $result = Mage::getModel('paygate/authorizenet_result');
     $client = new Varien_Http_Client();
     $uri = $this->getConfigData('cgi_url');
     $client->setUri($uri ? $uri : self::CGI_URL);
     $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
     $client->setParameterPost($request->getData());
     $client->setMethod(Zend_Http_Client::POST);
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
         $debugData['result'] = $result->getData();
         $this->_debug($debugData);
         Mage::throwException($this->_wrapGatewayError($e->getMessage()));
     }
     $responseBody = $response->getBody();
     $r = explode(self::RESPONSE_DELIM_CHAR, $responseBody);
     if ($r) {
         $result->setResponseCode((int) str_replace('"', '', $r[0]))->setResponseSubcode((int) str_replace('"', '', $r[1]))->setResponseReasonCode((int) str_replace('"', '', $r[2]))->setResponseReasonText($r[3])->setApprovalCode($r[4])->setAvsResultCode($r[5])->setTransactionId($r[6])->setInvoiceNumber($r[7])->setDescription($r[8])->setAmount($r[9])->setMethod($r[10])->setTransactionType($r[11])->setCustomerId($r[12])->setMd5Hash($r[37])->setCardCodeResponseCode($r[38])->setCAVVResponseCode(isset($r[39]) ? $r[39] : null);
     } else {
         Mage::throwException(Mage::helper('paygate')->__('Error in payment gateway.'));
     }
     $debugData['result'] = $result->getData();
     $this->_debug($debugData);
     return $result;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:29,代码来源:Authorizenet.php

示例4: _postRequest

 protected function _postRequest(Varien_Object $request)
 {
     $result = AO::getModel('paygate/authorizenet_result');
     $client = new Varien_Http_Client();
     $uri = $this->getConfigData('cgi_url');
     $client->setUri($uri ? $uri : self::CGI_URL);
     $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
     $client->setParameterPost($request->getData());
     $client->setMethod(Zend_Http_Client::POST);
     if ($this->getConfigData('debug')) {
         foreach ($request->getData() as $key => $value) {
             $requestData[] = strtoupper($key) . '=' . $value;
         }
         $requestData = join('&', $requestData);
         $debug = AO::getModel('paygate/authorizenet_debug')->setRequestBody($requestData)->setRequestSerialized(serialize($request->getData()))->setRequestDump(print_r($request->getData(), 1))->save();
     }
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
         if (!empty($debug)) {
             $debug->setResultSerialized(serialize($result->getData()))->setResultDump(print_r($result->getData(), 1))->save();
         }
         AO::throwException(AO::helper('paygate')->__('Gateway request error: %s', $e->getMessage()));
     }
     $responseBody = $response->getBody();
     $r = explode(self::RESPONSE_DELIM_CHAR, $responseBody);
     if ($r) {
         $result->setResponseCode((int) str_replace('"', '', $r[0]))->setResponseSubcode((int) str_replace('"', '', $r[1]))->setResponseReasonCode((int) str_replace('"', '', $r[2]))->setResponseReasonText($r[3])->setApprovalCode($r[4])->setAvsResultCode($r[5])->setTransactionId($r[6])->setInvoiceNumber($r[7])->setDescription($r[8])->setAmount($r[9])->setMethod($r[10])->setTransactionType($r[11])->setCustomerId($r[12])->setMd5Hash($r[37])->setCardCodeResponseCode($r[39]);
     } else {
         AO::throwException(AO::helper('paygate')->__('Error in payment gateway'));
     }
     if (!empty($debug)) {
         $debug->setResponseBody($responseBody)->setResultSerialized(serialize($result->getData()))->setResultDump(print_r($result->getData(), 1))->save();
     }
     return $result;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:37,代码来源:Authorizenet.php

示例5: _getXMLTracking

 /**
  * Send request for tracking
  *
  * @param array $trackings
  * @return void
  */
 protected function _getXMLTracking($trackings)
 {
     $xmlStr = '<?xml version="1.0" encoding="UTF-8"?>' . '<req:KnownTrackingRequest' . ' xmlns:req="http://www.dhl.com"' . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . ' xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown.xsd" />';
     $xml = new SimpleXMLElement($xmlStr);
     $requestNode = $xml->addChild('Request', '', '');
     $serviceHeaderNode = $requestNode->addChild('ServiceHeader', '', '');
     $serviceHeaderNode->addChild('SiteID', (string) $this->getConfigData('id'));
     $serviceHeaderNode->addChild('Password', (string) $this->getConfigData('password'));
     $xml->addChild('LanguageCode', 'EN', '');
     foreach ($trackings as $tracking) {
         $xml->addChild('AWBNumber', $tracking, '');
     }
     /*
      * Checkpoint details selection flag
      * LAST_CHECK_POINT_ONLY
      * ALL_CHECK_POINTS
      */
     $xml->addChild('LevelOfDetails', 'ALL_CHECK_POINTS', '');
     /*
      * Value that indicates for getting the tracking details with the additional
      * piece details and its respective Piece Details, Piece checkpoints along with
      * Shipment Details if queried.
      *
      * S-Only Shipment Details
      * B-Both Shipment & Piece Details
      * P-Only Piece Details
      * Default is ‘S’
      */
     //$xml->addChild('PiecesEnabled', 'ALL_CHECK_POINTS');
     $request = $xml->asXML();
     $request = utf8_encode($request);
     $responseBody = $this->_getCachedQuotes($request);
     if ($responseBody === null) {
         $debugData = array('request' => $request);
         try {
             $client = new Varien_Http_Client();
             $client->setUri((string) $this->getConfigData('gateway_url'));
             $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
             $client->setRawData($request);
             $responseBody = $client->request(Varien_Http_Client::POST)->getBody();
             $debugData['result'] = $responseBody;
             $this->_setCachedQuotes($request, $responseBody);
         } catch (Exception $e) {
             $this->_errors[$e->getCode()] = $e->getMessage();
             $responseBody = '';
         }
         $this->_debug($debugData);
     }
     $this->_parseXmlTrackingResponse($trackings, $responseBody);
 }
开发者ID:okite11,项目名称:frames21,代码行数:56,代码来源:International.php

示例6: _postRequest

 /**
  * Post request to gateway and return responce
  *
  * @param Mage_Paygate_Model_Authorizenet_Request $request)
  * @return Mage_Paygate_Model_Authorizenet_Result
  */
 protected function _postRequest(Varien_Object $request)
 {
     $debugData = array('request' => $request->getData());
     $debugData['class'] = get_class($request);
     $result = Mage::getModel('paygate/authorizenet_result');
     $client = new Varien_Http_Client();
     $uri = $this->getConfigData('cgi_url');
     $client->setUri($uri ? $uri : self::CGI_URL);
     //Mage::log(' ---------- new post request ', null, 'capture.log');
     //Mage::log(' uri '.$client->getUri(), null, 'capture.log');
     $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
     foreach ($request->getData() as $key => $value) {
         $request->setData($key, str_replace(self::RESPONSE_DELIM_CHAR, '', $value));
     }
     $request->setXDelimChar(self::RESPONSE_DELIM_CHAR);
     $client->setParameterPost($request->getData());
     $client->setMethod(Zend_Http_Client::POST);
     //Mage::log($request->getData(), null, 'capture.log');
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $result->setResponseCode(-1)->setResponseReasonCode($e->getCode())->setResponseReasonText($e->getMessage());
         $debugData['result'] = $result->getData();
         $this->_debug($debugData);
         Mage::throwException($this->_wrapGatewayError($e->getMessage()));
     }
     $responseBody = $response->getBody();
     $debugData['responseBody'] = $responseBody;
     $r = explode(self::RESPONSE_DELIM_CHAR, $responseBody);
     $debugData['deliminator'] = self::RESPONSE_DELIM_CHAR;
     $debugData['results_exploded'] = $r;
     if ($r) {
         $result->setResponseCode((int) str_replace('"', '', $r[0]))->setResponseSubcode((int) str_replace('"', '', $r[1]))->setResponseReasonCode((int) str_replace('"', '', $r[2]))->setResponseReasonText($r[3])->setApprovalCode($r[4])->setAvsResultCode($r[5])->setTransactionId($r[6])->setInvoiceNumber($r[7])->setDescription($r[8])->setAmount($r[9])->setMethod($r[10])->setTransactionType($r[11])->setCustomerId($r[12])->setMd5Hash($r[37])->setCardCodeResponseCode($r[38])->setCAVVResponseCode(isset($r[39]) ? $r[39] : null)->setSplitTenderId($r[52])->setAccNumber($r[50])->setCardType($r[51])->setRequestedAmount($r[53])->setBalanceOnCard($r[54]);
     } else {
         Mage::throwException(Mage::helper('revolution')->__('Error in payment gateway.'));
     }
     $debugData['result'] = $result->getData();
     $this->_debug($debugData);
     return $result;
 }
开发者ID:Jonathonbyrd,项目名称:Optimized-Magento-1.9.x,代码行数:46,代码来源:Revolution.php

示例7: _postRequest

 protected function _postRequest($request)
 {
     $client = new Varien_Http_Client();
     $client->setUri($this->getUrl());
     $client->setConfig(array('maxredirects' => 2, 'timeout' => 60));
     $client->setParameterGet($request);
     $client->setMethod(Zend_Http_Client::GET);
     try {
         $response = $client->request();
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('pnsofortueberweisung')->__('Gateway request error: %s', $e->getMessage()));
     }
     $responseBody = $response->getBody();
     return $responseBody;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:15,代码来源:Paycode.php

示例8: _postRequest

 /**
  * Post the transaction request
  *
  * @param	Shift4_Shift4Payment_Model_ApiRequest $request
  * @return	Shift4_Shift4Payment_Model_ApiResponse
  */
 protected function _postRequest(Shift4_Shift4Payment_Model_ApiRequest $request)
 {
     $client = new Varien_Http_Client();
     $client->setUri($request->getData('url'));
     $client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
     $params = array_merge(array('STX' => 'YES'), $request->getData(), array('ETX' => 'YES'));
     $client->setParameterPost($params);
     $client->setMethod(Zend_Http_Client::POST);
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $response = Mage::getModel('shift4payment/ApiResponse');
         $response->setResponseCode(self::RESPONSE_ERROR);
         $response->setResponseMessage('There was a problem communicating with the payment gateway. Please try again.');
     }
     $request->setParams($params);
     return $this->_processResponse($request, $response->getBody());
 }
开发者ID:xiaoguizhidao,项目名称:tyler-live,代码行数:24,代码来源:PaymentMethod.php


注:本文中的Varien_Http_Client::setConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。