From 9b7af077e1138db7e05645add37834faffca97d4 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Tue, 5 Mar 2024 11:22:02 +0200 Subject: [PATCH 1/2] add header for uk traffic --- MangoPay/Libraries/ApiOAuth.php | 3 +++ MangoPay/Libraries/Configuration.php | 5 +++++ MangoPay/Libraries/RestTool.php | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/MangoPay/Libraries/ApiOAuth.php b/MangoPay/Libraries/ApiOAuth.php index bbba9bda..977cf458 100644 --- a/MangoPay/Libraries/ApiOAuth.php +++ b/MangoPay/Libraries/ApiOAuth.php @@ -26,6 +26,9 @@ public function CreateToken() $rest->AddRequestHttpHeader('Host: ' . @$urlDetails['host']); $rest->AddRequestHttpHeader('Authorization: Basic ' . $authHlp->GetHttpHeaderBasicKey()); $rest->AddRequestHttpHeader('Content-Type: application/x-www-form-urlencoded'); + if($this->_root->Config->UKHeaderFlag){ + $rest->AddRequestHttpHeader('x-tenant-id: uk'); + } $response = $rest->Request($urlMethod, $requestType, $requestData); $token = $this->CastResponseToEntity($response, '\MangoPay\Libraries\OAuthToken'); $token->autentication_key = $authHlp->GetAutenticationKey(); diff --git a/MangoPay/Libraries/Configuration.php b/MangoPay/Libraries/Configuration.php index c262f7df..4e39d512 100644 --- a/MangoPay/Libraries/Configuration.php +++ b/MangoPay/Libraries/Configuration.php @@ -69,4 +69,9 @@ class Configuration * Set the user:password proxy */ public $UserPasswordProxy = null; + + /** + * Set to true for uk traffic + */ + public $UKHeaderFlag = true; } diff --git a/MangoPay/Libraries/RestTool.php b/MangoPay/Libraries/RestTool.php index 6b63cecf..349fd3c5 100644 --- a/MangoPay/Libraries/RestTool.php +++ b/MangoPay/Libraries/RestTool.php @@ -337,6 +337,11 @@ private function GetHttpHeaders($idempotencyKey = null) // Add User-Agent Header array_push($this->_requestHttpHeaders, 'User-Agent: MangoPay V2 SDK PHP ' . self::VERSION); + + if ($this->_root->Config->UKHeaderFlag) { + array_push($this->_requestHttpHeaders, 'x-tenant-id: uk'); + } + // Authentication http header if ($this->_authRequired) { $authHlp = new AuthenticationHelper($this->_root); From 9fad906c6528b144f99b0030d875966862fef273 Mon Sep 17 00:00:00 2001 From: Mihai Moiseanu Date: Thu, 7 Mar 2024 11:17:30 +0200 Subject: [PATCH 2/2] set the uk header flag to false by default --- MangoPay/Libraries/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MangoPay/Libraries/Configuration.php b/MangoPay/Libraries/Configuration.php index 4e39d512..26018e36 100644 --- a/MangoPay/Libraries/Configuration.php +++ b/MangoPay/Libraries/Configuration.php @@ -73,5 +73,5 @@ class Configuration /** * Set to true for uk traffic */ - public $UKHeaderFlag = true; + public $UKHeaderFlag = false; }