2016-01-26 43 views
-1

通信使用Magento ver。 1.8.1.0無法與PayPal錯誤

我得到了無法與PayPal網關通信。在這兩種情況下,PayPal快速結賬或PayPal付款錯誤。

我已經啓用SSL驗證: - 無

你能解釋一下我這個錯誤。

感謝

回答

0

寶最近推出了一些安全更新的沙盒(生產將在六月更新)https://devblog.paypal.com/upcoming-security-changes-notice/

最重要的是,TLS 1.0和1.1不再沙箱接受,而且Magento Paypal模塊默認不使用1.2。我們可以期待一個官方補丁在短期內解決這個問題,但在此期間您可以通過以下call功能覆蓋Mage/Paypal/Model/Api/Nvp.php(在當地codepool或重寫)解決它:

public function call($methodName, array $request) 
{ 
    $request = $this->_addMethodToRequest($methodName, $request); 
    $eachCallRequest = $this->_prepareEachCallRequest($methodName); 
    if ($this->getUseCertAuthentication()) { 
     if ($key = array_search('SIGNATURE', $eachCallRequest)) { 
      unset($eachCallRequest[$key]); 
     } 
    } 
    $request = $this->_exportToRequest($eachCallRequest, $request); 
    $debugData = array('url' => $this->getApiEndpoint(), $methodName => $request); 

    try { 
     $http = new Varien_Http_Adapter_Curl(); 
     $http->addOption(CURLOPT_SSLVERSION,6);//CURL_SSLVERSION_TLSv1_2 
     $config = array(
      'timeout' => 60, 
      'verifypeer' => $this->_config->verifyPeer 
     ); 

     if ($this->getUseProxy()) { 
      $config['proxy'] = $this->getProxyHost(). ':' . $this->getProxyPort(); 
     } 
     if ($this->getUseCertAuthentication()) { 
      $config['ssl_cert'] = $this->getApiCertificate(); 
     } 
     $http->setConfig($config); 
     $http->write(
      Zend_Http_Client::POST, 
      $this->getApiEndpoint(), 
      '1.1', 
      $this->_headers, 
      $this->_buildQuery($request) 
     ); 
     $response = $http->read(); 
    } catch (Exception $e) { 
     $debugData['http_error'] = array('error' => $e->getMessage(), 'code' => $e->getCode()); 
     $this->_debug($debugData); 
     throw $e; 
    } 

    $response = preg_split('/^\r?$/m', $response, 2); 
    $response = trim($response[1]); 
    $response = $this->_deformatNVP($response); 

    $debugData['response'] = $response; 
    $this->_debug($debugData); 
    $response = $this->_postProcessResponse($response); 

    // handle transport error 
    if ($http->getErrno()) { 
     Mage::logException(new Exception(
      sprintf('PayPal NVP CURL connection error #%s: %s', $http->getErrno(), $http->getError()) 
     )); 
     $http->close(); 

     Mage::throwException(Mage::helper('paypal')->__('Unable to communicate with the PayPal gateway.')); 
    } 

    // cUrl resource must be closed after checking it for errors 
    $http->close(); 

    if (!$this->_validateResponse($methodName, $response)) { 
     Mage::logException(new Exception(
      Mage::helper('paypal')->__("PayPal response hasn't required fields.") 
     )); 
     Mage::throwException(Mage::helper('paypal')->__('There was an error processing your order. Please contact us or try again later.')); 
    } 

    $this->_callErrors = array(); 
    if ($this->_isCallSuccessful($response)) { 
     if ($this->_rawResponseNeeded) { 
      $this->setRawSuccessResponseData($response); 
     } 
     return $response; 
    } 
    $this->_handleCallErrors($response); 
    return $response; 
} 

的重要線路$http->addOption(CURLOPT_SSLVERSION,6);//CURL_SSLVERSION_TLSv1_2

+0

應用此代碼,但同樣的錯誤...你能解釋我這件事。謝謝 – ramesh

+0

你還需要OpenSSL版本1.0.1+。嘗試在命令行中運行'openssl version'來檢查。 –