Skip to content

Commit

Permalink
Merge pull request #289 from mwarzybok-sumoheavy/feature/SP-803_9
Browse files Browse the repository at this point in the history
SP-803 PHP SDK - Proxy
  • Loading branch information
bobbrodie authored Feb 8, 2024
2 parents 3927d12 + 37e7eef commit 8626b8d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 43 deletions.
65 changes: 31 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/BitPaySDK/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions src/BitPaySDK/Model/Settlement/InvoiceData.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -154,19 +154,19 @@ 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;
}

/**
* 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;
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/BitPaySDK/Model/Settlement/InvoiceDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testGetOverPaidAmount()

public function testGetPayoutPercentage()
{
$expectedPayoutPercentage = 15;
$expectedPayoutPercentage = ['USD' => 15.12];

$invoiceData = $this->createClassObject();
$invoiceData->setPayoutPercentage($expectedPayoutPercentage);
Expand Down Expand Up @@ -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']);
}

Expand All @@ -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());
}
}

0 comments on commit 8626b8d

Please sign in to comment.