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
11 changes: 10 additions & 1 deletion src/Api/ApiAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class ApiAction

private $clientName;

/** @var string */
private $clientId;

public function __construct(Token $Token, bool $productionMode)
{
$this->productionMode = $productionMode;
Expand Down Expand Up @@ -149,6 +152,12 @@ public function getClientName()
return $this->clientName;
}

public function setClientId($clientId)
{
$parts = explode('-', $clientId);
$this->clientId = $parts[0];
}

public function enableVerbose()
{
$this->Curl->enableVerbose();
Expand Down Expand Up @@ -177,7 +186,7 @@ protected function sendRequest($apiMethod, $requestMethod, $fields = [], $header
$headers[] = 'X-Client-Source: '.$this->clientName;
}

$headers[] = 'User-Agent: tpay.com PHP SDK Client/'.gethostname().'/'.$this->clientName;
$headers[] = 'User-Agent: tpay.com PHP SDK Client/'.gethostname().'/'.$this->clientName.'/'.$this->clientId;

Logger::log(
'Outgoing request',
Expand Down
7 changes: 7 additions & 0 deletions src/Api/TpayApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public function accounts()
$this->accounts = (new AccountsApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->accounts->setClientId($this->clientId);
if ($this->clientName) {
$this->accounts->setClientName($this->clientName);
}
Expand All @@ -117,6 +118,7 @@ public function authorization()
$this->authorization = (new AuthorizationApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->authorization->setClientId($this->clientId);
if ($this->clientName) {
$this->authorization->setClientName($this->clientName);
}
Expand All @@ -133,6 +135,7 @@ public function refunds()
$this->refunds = (new RefundsApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->refunds->setClientId($this->clientId);
if ($this->clientName) {
$this->refunds->setClientName($this->clientName);
}
Expand All @@ -149,6 +152,7 @@ public function reports()
$this->reports = (new ReportsApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->reports->setClientId($this->clientId);
if ($this->clientName) {
$this->reports->setClientName($this->clientName);
}
Expand All @@ -165,6 +169,7 @@ public function transactions()
$this->transactions = (new TransactionsApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->transactions->setClientId($this->clientId);
if ($this->clientName) {
$this->transactions->setClientName($this->clientName);
}
Expand All @@ -181,6 +186,7 @@ public function collect()
$this->collect = (new CollectApi($this->token, $this->productionMode))
->overrideApiUrl($this->apiUrl);

$this->collect->setClientId($this->clientId);
if ($this->clientName) {
$this->collect->setClientName($this->clientName);
}
Expand Down Expand Up @@ -209,6 +215,7 @@ private function authorize()

$authApi = (new AuthorizationApi(new Token(), $this->productionMode))->overrideApiUrl($this->apiUrl);

$authApi->setClientId($this->clientId);
if ($this->clientName) {
$authApi->setClientName($this->clientName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SdkVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

final class SdkVersion
{
const VERSION = '2.4.3';
const VERSION = '2.4.4';
}
Loading