Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/Nuvei/Api/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,50 @@ public function sslVerifyPeer()
return true;
}

/**
* @param int $timeout
*
* @return $this
*/
public function setTimeout($timeout)
{
$this->configData['timeout'] = (int)$timeout;
return $this;
}

/**
* @return int
*/
public function getTimeout()
{
if (!isset($this->configData['timeout'])) {
return 0;
}
return (int)$this->configData['timeout'];
}

/**
* @param int $timeout
*
* @return $this
*/
public function setConnectionTimeout($timeout)
{
$this->configData['connectionTimeout'] = (int)$timeout;
return $this;
}

/**
* @return int
*/
public function getConnectionTimeout()
{
if (!isset($this->configData['connectionTimeout'])) {
return 0;
}
return (int)$this->configData['connectionTimeout'];
}

/**
* @return boolean
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Nuvei/Api/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function requestJson(ServiceInterface $service, $requestUrl, $params)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}

// set timeouts
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $config->getConnectionTimeout());
curl_setopt($ch, CURLOPT_TIMEOUT, $config->getTimeout());
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
// set authorisation
Expand Down
4 changes: 3 additions & 1 deletion tests/TestCaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static function getClient()
'merchantSiteId' => $config['merchantSiteId'],
'merchantSecretKey' => $config['merchantSecretKey'],
'hashAlgorithm' => $config['hashAlgorithm'],
'timeout' => $config['timeout'],
'connectionTimeout' => $config['connectionTimeout'],
'debugMode' => $config['debugMode'],
]);

Expand Down Expand Up @@ -335,4 +337,4 @@ public static function generateMinimalWithdrawalOrder($amount = 0.01) : array
$service = new Processing(self::getClient());
return $service->placeWithdrawalOrder($params);
}
}
}
4 changes: 3 additions & 1 deletion tests/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ merchantId = '5078248497400694938'
merchantSiteId = '142163'
merchantSecretKey = 'F0EpuOTjZPIKw5SGcNGyISClL1zaVnArABS65EkfUIwVmzgNbEiiQeesGp4N79Rg'
hashAlgorithm = 'sha256'
debugMode = false
timeout = 15
connectionTimeout = 5
debugMode = false