Skip to content

Commit

Permalink
Merge branch 'develop' into multiple-calls-UT
Browse files Browse the repository at this point in the history
  • Loading branch information
wboereboom authored Jul 12, 2023
2 parents 93ffaa2 + d493fc3 commit 9932a69
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Payout: spec=PayoutService-v68
Management: spec=ManagementService-v1
LegalEntityManagement: spec=LegalEntityService-v3
Transfers: spec=TransferService-v3
Capital: spec=GrantService-v3

# Classic Platforms
marketpay/account: spec=AccountService-v6
Expand Down Expand Up @@ -55,7 +54,7 @@ $(modelGen): target/spec $(openapi-generator-jar)
# Service Generation; split up in to templates based on the size of the service. That is, some services have no subgroups and are thus generated in one single file, others are grouped in a directory.

Services:=BalancePlatform Checkout StoredValue Payments Payout Management LegalEntityManagement Transfers
SingleFileServices:=BalanceControl BinLookup DataProtection StoredValue POSTerminalManagement Recurring Capital
SingleFileServices:=BalanceControl BinLookup DataProtection StoredValue POSTerminalManagement Recurring

all: $(Services) $(SingleFileServices)

Expand Down Expand Up @@ -125,4 +124,4 @@ clean:
git clean -f -d $(models)


.PHONY: templates models $(services)
.PHONY: templates models $(services)
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"monolog/monolog": "^1.16 || ^2.0 || ^3.0"
},
"require-dev": {
"dms/phpunit-arraysubset-asserts": "0.4.0",
"dms/phpunit-arraysubset-asserts": "0.5.0",
"friendsofphp/php-cs-fixer": "*",
"phpunit/phpunit": "9.6.7",
"phpunit/phpunit": "9.6.10",
"php-coveralls/php-coveralls": "2.5.3",
"squizlabs/php_codesniffer": "3.7.2"
},
Expand Down
10 changes: 10 additions & 0 deletions src/Adyen/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ public function setHttpProxy($proxy)
$this->config->set('http-proxy', $proxy);
}

/**
* Set the path to a CA bundle file that enables verification using a custom certificate
*
* @param string $certFilePath
*/
public function setSslVerify($certFilePath)
{
$this->config->set('ssl-verify', $certFilePath);
}

/**
* Set environment to connect to test or live platform of Adyen
* For live please specify the unique identifier.
Expand Down
10 changes: 10 additions & 0 deletions src/Adyen/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public function getHttpProxy()
return !empty($this->data['http-proxy']) ? $this->data['http-proxy'] : null;
}

/**
* Get the path to a CA bundle file that enables verification using a custom certificate
*
* @return mixed|null
*/
public function getSslVerify()
{
return !empty($this->data['ssl-verify']) ? $this->data['ssl-verify'] : null;
}

/**
* @return mixed|string
*/
Expand Down
32 changes: 31 additions & 1 deletion src/Adyen/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ public function curlSetHttpProxy($ch, $httpProxy)
throw new AdyenException("Invalid proxy configuration " . $httpProxy);
}

$proxy = $urlParts["host"];
$proxy = "";
if (isset($urlParts["scheme"])) {
$proxy = $urlParts["scheme"] . "://";
}
$proxy .= $urlParts["host"];
if (isset($urlParts["port"])) {
$proxy .= ":" . $urlParts["port"];
}
Expand All @@ -90,6 +94,28 @@ public function curlSetHttpProxy($ch, $httpProxy)
}
}

/**
* Set the path to a custom CA bundle in the current curl configuration.
*
* @param resource $ch
* @param string $certFilePath
* @throws AdyenException
*/
public function curlSetSslVerify($ch, $certFilePath)
{
if (empty($certFilePath)) {
return;
}

if (!file_exists($certFilePath)) {
throw new AdyenException("SSL CA bundle not found: {$certFilePath}");
}

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, $certFilePath);
}

/**
* Request to Adyen with query string used for Directory Lookup
*
Expand All @@ -108,6 +134,7 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params)
$password = $config->getPassword();
$httpProxy = $config->getHttpProxy();
$environment = $config->getEnvironment();
$sslVerify = $config->getSslVerify();

// Log the request
$this->logRequest($logger, $requestUrl, $environment, $params);
Expand All @@ -119,6 +146,7 @@ public function requestPost(\Adyen\Service $service, $requestUrl, $params)
curl_setopt($ch, CURLOPT_POST, 1);

$this->curlSetHttpProxy($ch, $httpProxy);
$this->curlSetSslVerify($ch, $sslVerify);

// set authorisation
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
Expand Down Expand Up @@ -368,6 +396,7 @@ public function requestHttp(\Adyen\Service $service, $requestUrl, $params, $meth
$xApiKey = $config->getXApiKey();
$httpProxy = $config->getHttpProxy();
$environment = $config->getEnvironment();
$sslVerify = $config->getSslVerify();

$jsonRequest = json_encode($params);

Expand All @@ -394,6 +423,7 @@ public function requestHttp(\Adyen\Service $service, $requestUrl, $params, $meth
}

$this->curlSetHttpProxy($ch, $httpProxy);
$this->curlSetSslVerify($ch, $sslVerify);

// Create a custom User-Agent
$userAgent = $config->get('applicationName') . " " .
Expand Down

0 comments on commit 9932a69

Please sign in to comment.