From 4de29cf7e377f1d95e32a322d18af0cd42180d60 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Tue, 6 Feb 2024 14:17:55 +0100 Subject: [PATCH 1/3] SP-803 PHP SDK - Proxy --- composer.lock | 65 +++++++++++++++++++--------------------- src/BitPaySDK/Client.php | 3 +- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/composer.lock b/composer.lock index 62a743a4..f57c69fb 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "bitpay/key-utils", - "version": "1.1.2", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/bitpay/bitpay-php-keyutils.git", - "reference": "44283014751d1886b41c7de29f1972737d6dfe4d" + "reference": "61cc4a58f25e79b7f61ff4631152139f6b084cb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bitpay/bitpay-php-keyutils/zipball/44283014751d1886b41c7de29f1972737d6dfe4d", - "reference": "44283014751d1886b41c7de29f1972737d6dfe4d", + "url": "https://api.github.com/repos/bitpay/bitpay-php-keyutils/zipball/61cc4a58f25e79b7f61ff4631152139f6b084cb1", + "reference": "61cc4a58f25e79b7f61ff4631152139f6b084cb1", "shasum": "" }, "require": { @@ -52,9 +52,9 @@ "description": "BitPay Utils pack for cryptography", "support": { "issues": "https://github.com/bitpay/bitpay-php-keyutils/issues", - "source": "https://github.com/bitpay/bitpay-php-keyutils/tree/1.1.2" + "source": "https://github.com/bitpay/bitpay-php-keyutils/tree/1.1.4" }, - "time": "2023-06-15T19:11:27+00:00" + "time": "2024-02-06T02:15:49+00:00" }, { "name": "guzzlehttp/guzzle", @@ -383,16 +383,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v4.2.0", + "version": "v4.4.1", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "f60565f8c0566a31acf06884cdaa591867ecc956" + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/f60565f8c0566a31acf06884cdaa591867ecc956", - "reference": "f60565f8c0566a31acf06884cdaa591867ecc956", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/132c75c7dd83e45353ebb9c6c9f591952995bbf0", + "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0", "shasum": "" }, "require": { @@ -403,7 +403,7 @@ "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0", + "phpunit/phpunit": "~7.5 || ~8.0 || ~9.0 || ~10.0", "squizlabs/php_codesniffer": "~3.5" }, "type": "library", @@ -428,9 +428,9 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.2.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.4.1" }, - "time": "2023-04-09T17:37:40+00:00" + "time": "2024-01-31T06:18:54+00:00" }, { "name": "psr/http-client", @@ -705,16 +705,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -728,9 +728,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -767,7 +764,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -783,20 +780,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/yaml", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587" + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4f9237a1bb42455d609e6687d2613dde5b41a587", - "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d75715985f0f94f978e3a8fa42533e10db921b90", + "reference": "d75715985f0f94f978e3a8fa42533e10db921b90", "shasum": "" }, "require": { @@ -839,7 +836,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.4.0" + "source": "https://github.com/symfony/yaml/tree/v6.4.3" }, "funding": [ { @@ -855,7 +852,7 @@ "type": "tidelift" } ], - "time": "2023-11-06T11:00:25+00:00" + "time": "2024-01-23T14:51:35+00:00" } ], "packages-dev": [ @@ -1410,16 +1407,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.7", + "version": "10.5.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8" + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e5c5b397a95cb0db013270a985726fcae93e61b8", - "reference": "e5c5b397a95cb0db013270a985726fcae93e61b8", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50b8e314b6d0dd06521dc31d1abffa73f25f850c", + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c", "shasum": "" }, "require": { @@ -1491,7 +1488,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.7" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.10" }, "funding": [ { @@ -1507,7 +1504,7 @@ "type": "tidelift" } ], - "time": "2024-01-14T16:40:30+00:00" + "time": "2024-02-04T09:07:51+00:00" }, { "name": "sebastian/cli-parser", diff --git a/src/BitPaySDK/Client.php b/src/BitPaySDK/Client.php index 0063cd1c..a4d32c81 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -111,8 +111,9 @@ public static function createWithFile(string $configFilePath): Client $config = $configData["BitPayConfiguration"]["EnvConfig"][$env]; $key = self::initKeys($config['PrivateKeyPath'], $config['PrivateKeySecret']); + $proxy = $config['proxy'] ?? null; - $restCli = new RESTcli($env, $key, $config['proxy']); + $restCli = new RESTcli($env, $key, $proxy); $tokenCache = new Tokens($config['ApiTokens']['merchant'], $config['ApiTokens']['payout']); return new Client($restCli, $tokenCache); From b3a475f7ec90845e22bb0a4d156e2db06dc96ae9 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Tue, 6 Feb 2024 14:44:47 +0100 Subject: [PATCH 2/3] SP-803 PHP SDK - Proxy --- src/BitPaySDK/Model/Settlement/InvoiceData.php | 10 +++++----- .../BitPaySDK/Model/Settlement/InvoiceDataTest.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/BitPaySDK/Model/Settlement/InvoiceData.php b/src/BitPaySDK/Model/Settlement/InvoiceData.php index 43c1b821..749239c8 100644 --- a/src/BitPaySDK/Model/Settlement/InvoiceData.php +++ b/src/BitPaySDK/Model/Settlement/InvoiceData.php @@ -24,7 +24,7 @@ class InvoiceData protected ?string $currency = null; protected ?string $transactionCurrency = null; protected ?float $overPaidAmount = null; - protected ?float $payoutPercentage = null; + protected ?array $payoutPercentage = null; protected ?RefundInfo $refundInfo = null; public function __construct() @@ -154,9 +154,9 @@ public function setOverPaidAmount(float $overPaidAmount): void /** * Gets The payout percentage defined by the merchant on his BitPay account settings * - * @return float|null the payout percentage + * @return array|null the payout percentage */ - public function getPayoutPercentage(): ?float + public function getPayoutPercentage(): ?array { return $this->payoutPercentage; } @@ -164,9 +164,9 @@ public function getPayoutPercentage(): ?float /** * Sets The payout percentage defined by the merchant on his BitPay account settings * - * @param float $payoutPercentage the payout percentage + * @param array $payoutPercentage the payout percentage */ - public function setPayoutPercentage(float $payoutPercentage): void + public function setPayoutPercentage(array $payoutPercentage): void { $this->payoutPercentage = $payoutPercentage; } diff --git a/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php b/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php index 0550c914..498b1150 100644 --- a/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php +++ b/test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php @@ -70,7 +70,7 @@ public function testGetOverPaidAmount() public function testGetPayoutPercentage() { - $expectedPayoutPercentage = 15; + $expectedPayoutPercentage = ['USD' => 15.12]; $invoiceData = $this->createClassObject(); $invoiceData->setPayoutPercentage($expectedPayoutPercentage); @@ -108,7 +108,7 @@ public function testToArray() self::assertEquals(12.9, $invoiceDataArray['price']); self::assertEquals('BTC', $invoiceDataArray['currency']); self::assertEquals('BTC', $invoiceDataArray['transactionCurrency']); - self::assertEquals(15, $invoiceDataArray['payoutPercentage']); + self::assertEquals(15.12, $invoiceDataArray['payoutPercentage']['USD']); self::assertEquals([], $invoiceDataArray['refundInfo']); } @@ -124,7 +124,7 @@ private function setSetters(InvoiceData $invoiceData) $invoiceData->setPrice(12.9); $invoiceData->setCurrency('BTC'); $invoiceData->setTransactionCurrency('BTC'); - $invoiceData->setPayoutPercentage(15); + $invoiceData->setPayoutPercentage(['USD' => 15.12]); $invoiceData->setRefundInfo($this->getMockBuilder(RefundInfo::class)->getMock()); } } From 37e7eef369010709a595eacba0b17edf687603f9 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Wed, 7 Feb 2024 10:54:04 +0100 Subject: [PATCH 3/3] SP-803 PHP SDK - Proxy --- src/BitPaySDK/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BitPaySDK/Client.php b/src/BitPaySDK/Client.php index a4d32c81..6d0587d5 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -111,7 +111,7 @@ public static function createWithFile(string $configFilePath): Client $config = $configData["BitPayConfiguration"]["EnvConfig"][$env]; $key = self::initKeys($config['PrivateKeyPath'], $config['PrivateKeySecret']); - $proxy = $config['proxy'] ?? null; + $proxy = $config['Proxy'] ?? null; $restCli = new RESTcli($env, $key, $proxy); $tokenCache = new Tokens($config['ApiTokens']['merchant'], $config['ApiTokens']['payout']);