Skip to content

Commit

Permalink
Added setCAInfoLocation
Browse files Browse the repository at this point in the history
\Paynl\Config::setCAInfoLocation('path/to/cacert.pem')
  • Loading branch information
Andy Pieters committed Feb 18, 2016
1 parent 5d11a9b commit 18ed377
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions samples/config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php
\Paynl\Config::setApiToken('e41f83b246b706291ea9ad798ccfd9f0fee5e0ab');
\Paynl\Config::setServiceId('SL-3490-4320');

//\Paynl\Config::setCAInfoLocation('path/to/cacert.pem'); //optional: you can download it on https://curl.haxx.se/ca/cacert.pem
9 changes: 9 additions & 0 deletions src/Api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,17 @@ public function doRequest($endpoint, $version = null)

$curl = new Curl();

if(Config::getCAInfoLocation()){
// set a custom CAInfo file
$curl->setOpt(CURLOPT_CAINFO, Config::getCAInfoLocation());
}

$result = $curl->post($uri, $data);

if($curl->error){
throw new Error\Error($curl->errorMessage);
}

$output = static::processResult($result);

return $output;
Expand Down
21 changes: 21 additions & 0 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ class Config
// @var int The version of the Pay.nl API to use for requests.
private static $apiVersion = 5;

/**
* @var string path tho CAInfo location
*/
private static $CAInfoLocation = null;

/**
* @return string
*/
public static function getCAInfoLocation()
{
return self::$CAInfoLocation;
}

/**
* @param string $CAInfoLocation
*/
public static function setCAInfoLocation($CAInfoLocation)
{
self::$CAInfoLocation = $CAInfoLocation;
}

/**
* @return string The API token used for requests.
*/
Expand Down

0 comments on commit 18ed377

Please sign in to comment.