From 8430dba0283cb5727721b5d5e51efa612dd9d593 Mon Sep 17 00:00:00 2001 From: Wilfried Wolf Date: Thu, 17 Sep 2020 11:21:43 +0200 Subject: [PATCH] implements config setting to allow proxy for outgoingg direct link calls --- .../Netresearch/OPS/Model/Api/Directlink.php | 23 +++++++++++++++---- .../Netresearch/OPS/Model/Config.php | 11 +++++++++ .../community/Netresearch/OPS/etc/config.xml | 1 + .../community/Netresearch/OPS/etc/system.xml | 9 ++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/code/community/Netresearch/OPS/Model/Api/Directlink.php b/app/code/community/Netresearch/OPS/Model/Api/Directlink.php index c9ef171..43e4dee 100644 --- a/app/code/community/Netresearch/OPS/Model/Api/Directlink.php +++ b/app/code/community/Netresearch/OPS/Model/Api/Directlink.php @@ -37,10 +37,11 @@ class Netresearch_OPS_Model_Api_DirectLink extends Mage_Core_Model_Abstract * * @param array $params * @param string $url + * @param string $proxy * * @return mixed */ - public function call($params, $url) + public function call($params, $url, $proxy = '') { try { $http = new Varien_Http_Adapter_Curl(); @@ -49,6 +50,9 @@ public function call($params, $url) 'verifypeer' => 1, 'verifyhost' => 2, ); + if ($proxy !== '') { + $config['proxy'] = $proxy; + } $http->setConfig($config); $http->write(Zend_Http_Client::POST, $url, '1.1', array(), http_build_query($params)); $response = $http->read(); @@ -84,7 +88,7 @@ public function performRequest($requestParams, $url, $storeId = 0) null, $storeId ); - $responseParams = $this->getResponseParams($params, $url); + $responseParams = $this->getResponseParams($params, $url, 0, $this->getConfig()->getDirectLinkProxy()); $helper->log( $helper->__( "Direct Link Request/Response in Ingenico ePayments (Ogone) \n\nRequest: %s\nResponse: %s\nMagento-URL: %s\nAPI-URL: %s", @@ -116,17 +120,18 @@ public function getEncodedParametersWithHash($params, $shaCode = null, $storeId) * @param array $params - request params * @param string $url - the url for the request * @param int $retryCount - current request count + * @param string $proxy - proxy for direct link calls * @return array | null - null if requests were not successful, array containing Ingenico ePayments (Ogone) payment data otherwise * @throws Mage_Core_Exception * */ - protected function getResponseParams($params, $url, $retryCount = 0) + protected function getResponseParams($params, $url, $retryCount = 0, $proxy = '') { $responseParams = null; $responseXml = null; if ($retryCount < self::MAX_RETRY_COUNT) { try { - $responseXml = $this->call($params, $url); + $responseXml = $this->call($params, $url, $proxy); $responseParams = $this->getParamArrFromXmlString($responseXml); } catch (Exception $e) { try { @@ -150,7 +155,7 @@ protected function getResponseParams($params, $url, $retryCount = 0) $responseXml ) ); - $responseParams = $this->getResponseParams($params, $url, ++$retryCount); + $responseParams = $this->getResponseParams($params, $url, ++$retryCount, $proxy); } } } else { @@ -237,4 +242,12 @@ public function checkResponse($responseParams) ); } } + + /** + * @return Netresearch_OPS_Model_Config + */ + protected function getConfig() + { + return Mage::getModel('ops/config'); + } } diff --git a/app/code/community/Netresearch/OPS/Model/Config.php b/app/code/community/Netresearch/OPS/Model/Config.php index 561e3b9..a45aa9f 100644 --- a/app/code/community/Netresearch/OPS/Model/Config.php +++ b/app/code/community/Netresearch/OPS/Model/Config.php @@ -700,6 +700,17 @@ public function getDirectLinkMaintenanceApiPath($storeId = null) return $this->determineOpsUrl('directlink_maintenance_api', $storeId); } + /** + * returns the proxy (if set in config) for the maintenance api calls + * + * @param null $storeId + * + * @return string - the proxy for the maintenance api calls + */ + public function getDirectLinkProxy($storeId = null) + { + return $this->getConfigData('directlink_proxy', $storeId); + } /** * getter for the iDeal issuers * diff --git a/app/code/community/Netresearch/OPS/etc/config.xml b/app/code/community/Netresearch/OPS/etc/config.xml index ebff592..513f404 100644 --- a/app/code/community/Netresearch/OPS/etc/config.xml +++ b/app/code/community/Netresearch/OPS/etc/config.xml @@ -334,6 +334,7 @@ https://secure.ogone.com/ncol/test/maintenancedirect.asp https://secure.ogone.com/ncol/test/orderdirect.asp https://secure.ogone.com/ncol/test/querydirect.asp + https://ogone.test.v-psp.com/Tokenization/HostedPage 1 1 diff --git a/app/code/community/Netresearch/OPS/etc/system.xml b/app/code/community/Netresearch/OPS/etc/system.xml index 65051cc..bf6f39a 100644 --- a/app/code/community/Netresearch/OPS/etc/system.xml +++ b/app/code/community/Netresearch/OPS/etc/system.xml @@ -175,6 +175,15 @@ 1 custom + + + text + + 75 + 1 + 1 + 1 + Users.]]>