From c77cb1f24c0e0d87f2a928c5e775dd02ed132dfa Mon Sep 17 00:00:00 2001 From: Turdaliev Nursultan Date: Wed, 10 Jan 2018 09:05:56 +0100 Subject: [PATCH 1/2] Removed unnecessary code snippets. --- src/Adyen/HttpClient/CurlClient.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index c6deab363..c130aa40b 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -120,15 +120,6 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params) curl_setopt($ch, CURLOPT_POST, count($params)); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); - // set a custom User-Agent - $userAgent = $config->get('applicationName') . " " . \Adyen\Client::USER_AGENT_SUFFIX . $client->getLibraryVersion(); - - //Set the content type to application/json and use the defined userAgent - $headers = array( - 'Content-Type: application/json', - 'User-Agent: ' . $userAgent - ); - // return the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); @@ -144,7 +135,6 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params) } elseif (!$result) { $errno = curl_errno($ch); $message = curl_error($ch); - $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $this->handleCurlError($requestUrl, $errno, $message, $logger); @@ -179,7 +169,7 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params) * @param $errno * @param $message * @param $logger - * @throws \Adyen\AdyenException + * @throws \Adyen\ConnectionException */ protected function handleCurlError($url, $errno, $message, $logger) { @@ -247,4 +237,4 @@ private function logRequest(\Psr\Log\LoggerInterface $logger, $requestUrl, $para } $logger->info('JSON Request to Adyen:' . json_encode($params)); } -} \ No newline at end of file +} From 7974fd989ee0f8120e37e99ef82a63d37e99a4f3 Mon Sep 17 00:00:00 2001 From: Nursultan Turdaliev Date: Wed, 10 Jan 2018 10:47:45 +0100 Subject: [PATCH 2/2] Added missing http header --- src/Adyen/HttpClient/CurlClient.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Adyen/HttpClient/CurlClient.php b/src/Adyen/HttpClient/CurlClient.php index c130aa40b..b64e7d248 100644 --- a/src/Adyen/HttpClient/CurlClient.php +++ b/src/Adyen/HttpClient/CurlClient.php @@ -120,6 +120,17 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params) curl_setopt($ch, CURLOPT_POST, count($params)); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); + // set a custom User-Agent + $userAgent = $config->get('applicationName') . " " . \Adyen\Client::USER_AGENT_SUFFIX . $client->getLibraryVersion(); + + //Set the content type to application/json and use the defined userAgent + $headers = array( + 'Content-Type: application/json', + 'User-Agent: ' . $userAgent + ); + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + // return the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);