Skip to content

Commit 685bbf5

Browse files
authored
Merge pull request #322 from bobbrodie/9.1.x
SP-126 Added X-BitPay-Platform-Info header
2 parents 4d677af + ed2b78d commit 685bbf5

File tree

8 files changed

+397
-158
lines changed

8 files changed

+397
-158
lines changed

docs/classes/BitPaySDK-Client.html

Lines changed: 80 additions & 62 deletions
Large diffs are not rendered by default.

docs/classes/BitPaySDK-PosClient.html

Lines changed: 143 additions & 71 deletions
Large diffs are not rendered by default.

docs/classes/BitPaySDK-Util-RESTcli-RESTcli.html

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ <h4 id="toc-properties">
232232
&nbsp;: string </span>
233233
</dt>
234234

235+
<dt class="phpdocumentor-table-of-contents__entry -property -protected">
236+
<a class="" href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_platformInfo">$platformInfo</a>
237+
<span>
238+
&nbsp;: string </span>
239+
</dt>
240+
<dd>Value for the X-BitPay-Platform-Info header.</dd>
241+
235242
<dt class="phpdocumentor-table-of-contents__entry -property -protected">
236243
<a class="" href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_proxy">$proxy</a>
237244
<span>
@@ -337,7 +344,7 @@ <h4 class="phpdocumentor-element__name" id="property_baseUrl">
337344
<aside class="phpdocumentor-element-found-in">
338345
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
339346
:
340-
<span class="phpdocumentor-element-found-in__line">37</span>
347+
<span class="phpdocumentor-element-found-in__line">38</span>
341348

342349
</aside>
343350

@@ -409,7 +416,7 @@ <h4 class="phpdocumentor-element__name" id="property_ecKey">
409416
<aside class="phpdocumentor-element-found-in">
410417
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
411418
:
412-
<span class="phpdocumentor-element-found-in__line">41</span>
419+
<span class="phpdocumentor-element-found-in__line">43</span>
413420

414421
</aside>
415422

@@ -445,7 +452,7 @@ <h4 class="phpdocumentor-element__name" id="property_identity">
445452
<aside class="phpdocumentor-element-found-in">
446453
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
447454
:
448-
<span class="phpdocumentor-element-found-in__line">45</span>
455+
<span class="phpdocumentor-element-found-in__line">48</span>
449456

450457
</aside>
451458

@@ -463,6 +470,43 @@ <h4 class="phpdocumentor-element__name" id="property_identity">
463470

464471

465472

473+
</article>
474+
<article
475+
class="
476+
phpdocumentor-element
477+
-property
478+
-protected
479+
"
480+
>
481+
<h4 class="phpdocumentor-element__name" id="property_platformInfo">
482+
$platformInfo
483+
<a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_platformInfo" class="headerlink"><i class="fas fa-link"></i></a>
484+
485+
<span class="phpdocumentor-element__modifiers">
486+
</span>
487+
</h4>
488+
<aside class="phpdocumentor-element-found-in">
489+
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
490+
:
491+
<span class="phpdocumentor-element-found-in__line">54</span>
492+
493+
</aside>
494+
495+
<p class="phpdocumentor-summary">Value for the X-BitPay-Platform-Info header.</p>
496+
497+
498+
<code class="phpdocumentor-code phpdocumentor-signature ">
499+
<span class="phpdocumentor-signature__visibility">protected</span>
500+
<span class="phpdocumentor-signature__type">string</span>
501+
<span class="phpdocumentor-signature__name">$platformInfo</span>
502+
</code>
503+
504+
505+
506+
507+
508+
509+
466510
</article>
467511
<article
468512
class="
@@ -481,7 +525,7 @@ <h4 class="phpdocumentor-element__name" id="property_proxy">
481525
<aside class="phpdocumentor-element-found-in">
482526
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
483527
:
484-
<span class="phpdocumentor-element-found-in__line">50</span>
528+
<span class="phpdocumentor-element-found-in__line">59</span>
485529

486530
</aside>
487531

@@ -522,15 +566,15 @@ <h4 class="phpdocumentor-element__name" id="method___construct">
522566
<aside class="phpdocumentor-element-found-in">
523567
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
524568
:
525-
<span class="phpdocumentor-element-found-in__line">59</span>
569+
<span class="phpdocumentor-element-found-in__line">69</span>
526570

527571
</aside>
528572

529573
<p class="phpdocumentor-summary">RESTcli constructor.</p>
530574

531575
<code class="phpdocumentor-code phpdocumentor-signature ">
532576
<span class="phpdocumentor-signature__visibility">public</span>
533-
<span class="phpdocumentor-signature__name">__construct</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$environment</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type"><abbr title="\BitPayKeyUtils\KeyHelper\PrivateKey">PrivateKey</abbr>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$ecKey</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">string|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$proxy</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
577+
<span class="phpdocumentor-signature__name">__construct</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">string&nbsp;</span><span class="phpdocumentor-signature__argument__name">$environment</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type"><abbr title="\BitPayKeyUtils\KeyHelper\PrivateKey">PrivateKey</abbr>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$ecKey</span></span><span class="phpdocumentor-signature__argument"><span>[</span><span>, </span><span class="phpdocumentor-signature__argument__return-type">string|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$proxy</span><span> = </span><span class="phpdocumentor-signature__argument__default-value">null</span><span> ]</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">string|null&nbsp;</span><span class="phpdocumentor-signature__argument__name">$platformInfo</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
534578

535579
<div class="phpdocumentor-label-line">
536580
</div>
@@ -558,6 +602,13 @@ <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
558602
= <span class="phpdocumentor-signature__argument__default-value">null</span> </dt>
559603
<dd class="phpdocumentor-argument-list__definition">
560604

605+
</dd>
606+
<dt class="phpdocumentor-argument-list__entry">
607+
<span class="phpdocumentor-signature__argument__name">$platformInfo</span>
608+
: <span class="phpdocumentor-signature__argument__return-type">string|null</span>
609+
</dt>
610+
<dd class="phpdocumentor-argument-list__definition">
611+
561612
</dd>
562613
</dl>
563614

@@ -596,7 +647,7 @@ <h4 class="phpdocumentor-element__name" id="method_delete">
596647
<aside class="phpdocumentor-element-found-in">
597648
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
598649
:
599-
<span class="phpdocumentor-element-found-in__line">227</span>
650+
<span class="phpdocumentor-element-found-in__line">250</span>
600651

601652
</aside>
602653

@@ -675,7 +726,7 @@ <h4 class="phpdocumentor-element__name" id="method_get">
675726
<aside class="phpdocumentor-element-found-in">
676727
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
677728
:
678-
<span class="phpdocumentor-element-found-in__line">168</span>
729+
<span class="phpdocumentor-element-found-in__line">187</span>
679730

680731
</aside>
681732

@@ -765,7 +816,7 @@ <h4 class="phpdocumentor-element__name" id="method_getJsonDataFromResponse">
765816
<aside class="phpdocumentor-element-found-in">
766817
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
767818
:
768-
<span class="phpdocumentor-element-found-in__line">341</span>
819+
<span class="phpdocumentor-element-found-in__line">372</span>
769820

770821
</aside>
771822

@@ -829,7 +880,7 @@ <h4 class="phpdocumentor-element__name" id="method_init">
829880
<aside class="phpdocumentor-element-found-in">
830881
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
831882
:
832-
<span class="phpdocumentor-element-found-in__line">72</span>
883+
<span class="phpdocumentor-element-found-in__line">83</span>
833884

834885
</aside>
835886

@@ -879,7 +930,7 @@ <h4 class="phpdocumentor-element__name" id="method_post">
879930
<aside class="phpdocumentor-element-found-in">
880931
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
881932
:
882-
<span class="phpdocumentor-element-found-in__line">108</span>
933+
<span class="phpdocumentor-element-found-in__line">123</span>
883934

884935
</aside>
885936

@@ -969,7 +1020,7 @@ <h4 class="phpdocumentor-element__name" id="method_update">
9691020
<aside class="phpdocumentor-element-found-in">
9701021
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
9711022
:
972-
<span class="phpdocumentor-element-found-in__line">288</span>
1023+
<span class="phpdocumentor-element-found-in__line">315</span>
9731024

9741025
</aside>
9751026

@@ -1048,7 +1099,7 @@ <h4 class="phpdocumentor-element__name" id="method_hasError">
10481099
<aside class="phpdocumentor-element-found-in">
10491100
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
10501101
:
1051-
<span class="phpdocumentor-element-found-in__line">378</span>
1102+
<span class="phpdocumentor-element-found-in__line">409</span>
10521103

10531104
</aside>
10541105

@@ -1096,7 +1147,7 @@ <h4 class="phpdocumentor-element__name" id="method_parseException">
10961147
<aside class="phpdocumentor-element-found-in">
10971148
<abbr class="phpdocumentor-element-found-in__file" title="src/BitPaySDK/Util/RESTcli/RESTcli.php"><a href="files/src-bitpaysdk-util-restcli-restcli.html"><abbr title="src/BitPaySDK/Util/RESTcli/RESTcli.php">RESTcli.php</abbr></a></abbr>
10981149
:
1099-
<span class="phpdocumentor-element-found-in__line">394</span>
1150+
<span class="phpdocumentor-element-found-in__line">425</span>
11001151

11011152
</aside>
11021153

@@ -1266,6 +1317,7 @@ <h5 class="phpdocumentor-tag-list__heading" id="tags">
12661317
<li class=""><a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_client">$client</a></li>
12671318
<li class=""><a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_ecKey">$ecKey</a></li>
12681319
<li class=""><a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_identity">$identity</a></li>
1320+
<li class=""><a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_platformInfo">$platformInfo</a></li>
12691321
<li class=""><a href="classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_proxy">$proxy</a></li>
12701322
</ul>
12711323
</li>

docs/js/searchIndex.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9250,6 +9250,11 @@ Search.appendIndex(
92509250
"name": "env",
92519251
"summary": "",
92529252
"url": "classes/BitPaySDK-PosClient.html#property_env"
9253+
}, {
9254+
"fqsen": "\\BitPaySDK\\PosClient\u003A\u003A\u0024platformInfo",
9255+
"name": "platformInfo",
9256+
"summary": "Value\u0020for\u0020the\u0020X\u002DBitPay\u002DPlatform\u002DInfo\u0020header",
9257+
"url": "classes/BitPaySDK-PosClient.html#property_platformInfo"
92539258
}, {
92549259
"fqsen": "\\BitPaySDK\\PosClient\u003A\u003A\u0024token",
92559260
"name": "token",
@@ -9390,6 +9395,11 @@ Search.appendIndex(
93909395
"name": "identity",
93919396
"summary": "",
93929397
"url": "classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_identity"
9398+
}, {
9399+
"fqsen": "\\BitPaySDK\\Util\\RESTcli\\RESTcli\u003A\u003A\u0024platformInfo",
9400+
"name": "platformInfo",
9401+
"summary": "Value\u0020for\u0020the\u0020X\u002DBitPay\u002DPlatform\u002DInfo\u0020header.",
9402+
"url": "classes/BitPaySDK-Util-RESTcli-RESTcli.html#property_platformInfo"
93939403
}, {
93949404
"fqsen": "\\BitPaySDK\\Util\\RESTcli\\RESTcli\u003A\u003A\u0024proxy",
93959405
"name": "proxy",

src/BitPaySDK/Client.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function __construct(RESTcli $restCli, Tokens $tokenCache)
7171
* @param string|null $privateKeySecret Private Key encryption password.
7272
* @param string|null $proxy The url of your proxy to forward requests through. Example:
7373
* http://********.com:3128
74+
* @param string|null $platformInfo Value for the X-BitPay-Platform header.
7475
* @return Client
7576
* @throws BitPayApiException
7677
* @throws BitPayGenericException
@@ -80,12 +81,13 @@ public static function createWithData(
8081
string $privateKey,
8182
Tokens $tokens,
8283
?string $privateKeySecret = null,
83-
?string $proxy = null
84+
?string $proxy = null,
85+
?string $platformInfo = null,
8486
): Client {
8587
try {
8688
$key = self::initKeys($privateKey, $privateKeySecret);
8789

88-
$restCli = new RESTcli($environment, $key, $proxy);
90+
$restCli = new RESTcli($environment, $key, $proxy, $platformInfo);
8991
$tokenCache = $tokens;
9092

9193
return new Client($restCli, $tokenCache);
@@ -99,11 +101,12 @@ public static function createWithData(
99101
/**
100102
* Constructor for use if the keys and SIN are managed by this library.
101103
*
102-
* @param string $configFilePath The path to the configuration file.
104+
* @param string $configFilePath The path to the configuration file.
105+
* @param string|null $platformInfo Value for the X-BitPay-Platform header.
103106
* @return Client
104107
* @throws BitPayGenericException
105108
*/
106-
public static function createWithFile(string $configFilePath): Client
109+
public static function createWithFile(string $configFilePath, ?string $platformInfo = null): Client
107110
{
108111
try {
109112
$configData = self::getConfigData($configFilePath);
@@ -113,7 +116,7 @@ public static function createWithFile(string $configFilePath): Client
113116
$key = self::initKeys($config['PrivateKeyPath'], $config['PrivateKeySecret']);
114117
$proxy = $config['Proxy'] ?? null;
115118

116-
$restCli = new RESTcli($env, $key, $proxy);
119+
$restCli = new RESTcli($env, $key, $proxy, $platformInfo);
117120
$tokenCache = new Tokens($config['ApiTokens']['merchant'], $config['ApiTokens']['payout']);
118121

119122
return new Client($restCli, $tokenCache);

src/BitPaySDK/PosClient.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,30 @@
2727
class PosClient extends Client
2828
{
2929
protected string $env;
30+
31+
/**
32+
* Value for the X-BitPay-Platform-Info header
33+
* @var string
34+
*/
35+
protected string $platformInfo;
3036
protected Tokens $token;
3137
protected RESTcli $RESTcli;
3238

3339
/**
3440
* Constructor for the BitPay SDK to use with the POS facade.
3541
*
36-
* @param $token string The token generated on the BitPay account.
37-
* @param string|null $environment string The target environment [Default: Production].
42+
* @param string $token The token generated on the BitPay account.
43+
* @param string|null $environment The target environment [Default: Production].
44+
* @param string|null $platformInfo Value for the X-BitPay-Platform-Info header.
3845
*
3946
* @throws BitPayGenericException
4047
*/
41-
public function __construct(string $token, string $environment = null)
48+
public function __construct(string $token, string $environment = null, ?string $platformInfo = null)
4249
{
4350
try {
4451
$this->token = new Tokens(null, null, $token);
4552
$this->env = strtolower($environment) === "test" ? Env::TEST : Env::PROD;
53+
$this->platformInfo = $platformInfo !== null ? trim($platformInfo) : '';
4654
$this->init();
4755
parent::__construct($this->RESTcli, new Tokens(null, null, $token));
4856
} catch (Exception $e) {
@@ -60,7 +68,7 @@ public function __construct(string $token, string $environment = null)
6068
private function init(): void
6169
{
6270
try {
63-
$this->RESTcli = new RESTcli($this->env, new PrivateKey());
71+
$this->RESTcli = new RESTcli($this->env, new PrivateKey(), null, $this->platformInfo);
6472
} catch (Exception $e) {
6573
BitPayExceptionProvider::throwGenericExceptionWithMessage(
6674
'failed to build configuration : ' . $e->getMessage()
@@ -71,7 +79,7 @@ private function init(): void
7179
/**
7280
* Fetch the supported currencies.
7381
*
74-
* @return array A list of BitPay Invoice objects.
82+
* @return array A list of BitPay Invoice objects.
7583
* @throws BitPayGenericException
7684
* @throws BitPayApiException
7785
*/

0 commit comments

Comments
 (0)