diff --git a/src/Connection.php b/src/Connection.php index 12efd3c0..a242980e 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -11,12 +11,14 @@ class Connection protected ?\CurlHandle $curlHandle = null; protected int $timeoutConnect = 15; protected int $timeoutResponse = 30; + protected string $userAgent = 'phpFinTS'; - public function __construct(string $url, int $timeoutConnect = 15, int $timeoutResponse = 30) + public function __construct(string $url, int $timeoutConnect = 15, int $timeoutResponse = 30, string $userAgent = 'phpFinTS') { $this->url = $url; $this->timeoutConnect = $timeoutConnect; $this->timeoutResponse = $timeoutResponse; + $this->userAgent = $userAgent; } /** @@ -28,7 +30,7 @@ private function connect(): void curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYHOST, 2); - curl_setopt($this->curlHandle, CURLOPT_USERAGENT, 'phpFinTS'); + curl_setopt($this->curlHandle, CURLOPT_USERAGENT, $this->userAgent); curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curlHandle, CURLOPT_URL, $this->url); curl_setopt($this->curlHandle, CURLOPT_CONNECTTIMEOUT, $this->timeoutConnect); diff --git a/src/FinTs.php b/src/FinTs.php index a509328d..18c5a61a 100644 --- a/src/FinTs.php +++ b/src/FinTs.php @@ -1002,7 +1002,7 @@ private function requireTanMode(): TanMode */ protected function newConnection(): Connection { - return new Connection($this->options->url, $this->options->timeoutConnect, $this->options->timeoutResponse); + return new Connection($this->options->url, $this->options->timeoutConnect, $this->options->timeoutResponse, $this->options->userAgent); } /** diff --git a/src/Options/FinTsOptions.php b/src/Options/FinTsOptions.php index 378a1c30..8d56d36b 100644 --- a/src/Options/FinTsOptions.php +++ b/src/Options/FinTsOptions.php @@ -40,6 +40,13 @@ class FinTsOptions */ public $url; + /** + * The HTTP User-Agent header sent to the bank server. Some banks display this value in their + * registered devices or applications list. + * @var string + */ + public $userAgent = 'phpFinTS'; + /** @var int */ public $timeoutConnect = 15; /** @var int */