From 0084a16627dc510c131c512d594aef828a138c3a Mon Sep 17 00:00:00 2001 From: Tim Rasche Date: Fri, 15 May 2026 15:43:34 +0200 Subject: [PATCH] Adds configurable User-Agent for HTTP requests Allows customization of the HTTP User-Agent header sent to the bank server by introducing a configurable option. Some banks display the User-Agent in registered device lists, so this enhances flexibility and compatibility. --- src/Connection.php | 6 ++++-- src/FinTs.php | 2 +- src/Options/FinTsOptions.php | 7 +++++++ 3 files changed, 12 insertions(+), 3 deletions(-) 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 */