From b77ca912c4f66658dfd19f5529db8638c1c23ae3 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Tue, 23 Jan 2024 13:45:10 +0100 Subject: [PATCH 1/2] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Invoice/Invoice.php | 4 +- .../Model/Invoice/InvoiceRefundAddresses.php | 53 ++++++++ .../Model/Invoice/InvoiceTransaction.php | 128 ++++++++++++++++++ .../Model/Invoice/InvoiceWebhook.php | 25 ++++ src/BitPaySDK/Model/Invoice/RefundWebhook.php | 98 +++++++++++++- .../Model/Payout/PayoutTransaction.php | 10 +- src/BitPaySDK/Model/Payout/PayoutWebhook.php | 42 ++++++ .../Model/Invoice/RefundWebhookTest.php | 24 ++++ 8 files changed, 376 insertions(+), 8 deletions(-) create mode 100644 src/BitPaySDK/Model/Invoice/InvoiceRefundAddresses.php create mode 100644 src/BitPaySDK/Model/Invoice/InvoiceTransaction.php diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 7903b563..586f37dd 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -887,7 +887,7 @@ public function setBuyerSms(string $buyerSms): void * This field will be populated with the refund address * provided by the customer if you request a refund of the specific invoice. * - * @return array|null Refund address provided by the customer + * @return array|null [[string, InvoiceRefundAddress]] Refund address provided by the customer */ public function getRefundAddresses(): ?array { @@ -901,7 +901,7 @@ public function getRefundAddresses(): ?array * This field will be populated with the refund address * provided by the customer if you request a refund of the specific invoice. * - * @param array $refundAddresses Refund address provided by the customer + * @param array [[string, InvoiceRefundAddress]] $refundAddresses Refund address provided by the customer */ public function setRefundAddresses(array $refundAddresses): void { diff --git a/src/BitPaySDK/Model/Invoice/InvoiceRefundAddresses.php b/src/BitPaySDK/Model/Invoice/InvoiceRefundAddresses.php new file mode 100644 index 00000000..2b15d8ee --- /dev/null +++ b/src/BitPaySDK/Model/Invoice/InvoiceRefundAddresses.php @@ -0,0 +1,53 @@ +type; + } + + public function setType(string $type): void + { + $this->type = $type; + } + + public function getDate(): string + { + return $this->date; + } + + public function setDate(string $date): void + { + $this->date = $date; + } + + public function getTag(): ?int + { + return $this->tag; + } + + public function setTag(?int $tag): void + { + $this->tag = $tag; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(?string $email): void + { + $this->email = $email; + } +} diff --git a/src/BitPaySDK/Model/Invoice/InvoiceTransaction.php b/src/BitPaySDK/Model/Invoice/InvoiceTransaction.php new file mode 100644 index 00000000..d6d7e6f6 --- /dev/null +++ b/src/BitPaySDK/Model/Invoice/InvoiceTransaction.php @@ -0,0 +1,128 @@ +amount; + } + + /** + * @param string $amount + */ + public function setAmount(string $amount): void + { + $this->amount = $amount; + } + + /** + * @return int + */ + public function getConfirmations(): int + { + return $this->confirmations; + } + + /** + * @param int $confirmations + */ + public function setConfirmations(int $confirmations): void + { + $this->confirmations = $confirmations; + } + + /** + * @return string + */ + public function getTime(): string + { + return $this->time; + } + + /** + * @param string $time + */ + public function setTime(string $time): void + { + $this->time = $time; + } + + /** + * @return string + */ + public function getReceivedTime(): string + { + return $this->receivedTime; + } + + /** + * @param string $receivedTime + */ + public function setReceivedTime(string $receivedTime): void + { + $this->receivedTime = $receivedTime; + } + + /** + * @return string + */ + public function getTxid(): string + { + return $this->txid; + } + + /** + * @param string $txid + */ + public function setTxid(string $txid): void + { + $this->txid = $txid; + } + + /** + * @return array [string => float] + */ + public function getExRates(): array + { + return $this->exRates; + } + + /** + * @param array $exRates [string => float] + */ + public function setExRates(array $exRates): void + { + $this->exRates = $exRates; + } + + /** + * @return int + */ + public function getOutputIndex(): int + { + return $this->outputIndex; + } + + /** + * @param int $outputIndex + */ + public function setOutputIndex(int $outputIndex): void + { + $this->outputIndex = $outputIndex; + } +} diff --git a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php index 57fcb5c7..b301c17b 100644 --- a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php +++ b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php @@ -32,6 +32,8 @@ class InvoiceWebhook protected ?float $amountPaid; protected ?string $orderId; protected ?string $transactionCurrency; + protected ?string $inInvoiceId; + protected ?string $inPaymentRequest; public function getId(): ?string { @@ -192,4 +194,27 @@ public function setTransactionCurrency(?string $transactionCurrency): void { $this->transactionCurrency = $transactionCurrency; } + + /** + * @return string|null + */ + public function getInInvoiceId(): ?string + { + return $this->inInvoiceId; + } + + public function setInInvoiceId(?string $inInvoiceId): void + { + $this->inInvoiceId = $inInvoiceId; + } + + public function getInPaymentRequest(): ?string + { + return $this->inPaymentRequest; + } + + public function setInPaymentRequest(?string $inPaymentRequest): void + { + $this->inPaymentRequest = $inPaymentRequest; + } } diff --git a/src/BitPaySDK/Model/Invoice/RefundWebhook.php b/src/BitPaySDK/Model/Invoice/RefundWebhook.php index ac2187ce..2a6c85c2 100644 --- a/src/BitPaySDK/Model/Invoice/RefundWebhook.php +++ b/src/BitPaySDK/Model/Invoice/RefundWebhook.php @@ -29,6 +29,14 @@ class RefundWebhook protected ?bool $immediate = null; protected ?bool $buyerPaysRefundFee = null; protected ?string $requestDate = null; + protected ?string $reference; + protected ?string $guid; + protected ?string $refundAddress; + protected ?string $type; + protected ?string $txid; + protected ?string $transactionCurrency; + protected ?float $transactionAmount; + protected ?float $transactionRefundFee; public function getId(): ?string { @@ -140,6 +148,86 @@ public function setRequestDate(?string $requestDate): void $this->requestDate = $requestDate; } + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): void + { + $this->reference = $reference; + } + + public function getGuid(): ?string + { + return $this->guid; + } + + public function setGuid(?string $guid): void + { + $this->guid = $guid; + } + + public function getRefundAddress(): ?string + { + return $this->refundAddress; + } + + public function setRefundAddress(?string $refundAddress): void + { + $this->refundAddress = $refundAddress; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(?string $type): void + { + $this->type = $type; + } + + public function getTxid(): ?string + { + return $this->txid; + } + + public function setTxid(?string $txid): void + { + $this->txid = $txid; + } + + public function getTransactionCurrency(): ?string + { + return $this->transactionCurrency; + } + + public function setTransactionCurrency(?string $transactionCurrency): void + { + $this->transactionCurrency = $transactionCurrency; + } + + public function getTransactionAmount(): ?float + { + return $this->transactionAmount; + } + + public function setTransactionAmount(?float $transactionAmount): void + { + $this->transactionAmount = $transactionAmount; + } + + public function getTransactionRefundFee(): ?float + { + return $this->transactionRefundFee; + } + + public function setTransactionRefundFee(?float $transactionRefundFee): void + { + $this->transactionRefundFee = $transactionRefundFee; + } + public function toArray(): array { return [ @@ -153,7 +241,15 @@ public function toArray(): array 'refundFee' => $this->getRefundFee(), 'immediate' => $this->getImmediate(), 'buyerPaysRefundFee' => $this->getBuyerPaysRefundFee(), - 'requestDate' => $this->getRequestDate() + 'requestDate' => $this->getRequestDate(), + 'reference' => $this->getReference(), + 'guid' => $this->getGuid(), + 'refundAddress' => $this->getRefundAddress(), + 'type' => $this->getType(), + 'txid' => $this->getTxid(), + 'transactionCurrency' => $this->getTransactionCurrency(), + 'transactionAmount' => $this->getTransactionAmount(), + 'transactionRefundFee' => $this->getTransactionRefundFee(), ]; } } diff --git a/src/BitPaySDK/Model/Payout/PayoutTransaction.php b/src/BitPaySDK/Model/Payout/PayoutTransaction.php index 713b6e7b..a5a88196 100644 --- a/src/BitPaySDK/Model/Payout/PayoutTransaction.php +++ b/src/BitPaySDK/Model/Payout/PayoutTransaction.php @@ -26,7 +26,7 @@ class PayoutTransaction protected ?string $txid = null; protected ?float $amount = null; protected ?string $date = null; - protected ?string $confirmations = null; + protected ?int $confirmations = null; public function __construct() { @@ -97,9 +97,9 @@ public function setDate(?string $date): void /** * Gets the number of confirmations the transaction has received. * - * @return string|null + * @return int|null */ - public function getConfirmations(): ?string + public function getConfirmations(): ?int { return $this->confirmations; } @@ -107,9 +107,9 @@ public function getConfirmations(): ?string /** * Sets the number of confirmations the transaction has received. * - * @param string|null $confirmations + * @param int|null $confirmations */ - public function setConfirmations(?string $confirmations): void + public function setConfirmations(?int $confirmations): void { $this->confirmations = $confirmations; } diff --git a/src/BitPaySDK/Model/Payout/PayoutWebhook.php b/src/BitPaySDK/Model/Payout/PayoutWebhook.php index 2bf445d0..834f8661 100644 --- a/src/BitPaySDK/Model/Payout/PayoutWebhook.php +++ b/src/BitPaySDK/Model/Payout/PayoutWebhook.php @@ -26,6 +26,9 @@ class PayoutWebhook protected ?string $requestDate = null; protected ?string $status = null; protected ?array $transactions = null; + protected ?string $accountId = null; + protected ?string $date = null; + protected ?string $groupId = null; public function getId(): ?string { @@ -186,4 +189,43 @@ public function setTransactions(?array $transactions): void { $this->transactions = $transactions; } + + /** + * @return string|null + */ + public function getAccountId(): ?string + { + return $this->accountId; + } + + /** + * @param string|null $accountId + */ + public function setAccountId(?string $accountId): void + { + $this->accountId = $accountId; + } + + /** + * @return string|null + */ + public function getDate(): ?string + { + return $this->date; + } + + public function setDate(?string $date): void + { + $this->date = $date; + } + + public function getGroupId(): ?string + { + return $this->groupId; + } + + public function setGroupId(?string $groupId): void + { + $this->groupId = $groupId; + } } diff --git a/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php b/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php index 81ddbc74..d4f4dab4 100644 --- a/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/RefundWebhookTest.php @@ -129,6 +129,14 @@ public function testToArray() self::assertArrayHasKey('immediate', $refundWebhookArray); self::assertArrayHasKey('buyerPaysRefundFee', $refundWebhookArray); self::assertArrayHasKey('requestDate', $refundWebhookArray); + self::assertArrayHasKey('reference', $refundWebhookArray); + self::assertArrayHasKey('guid', $refundWebhookArray); + self::assertArrayHasKey('refundAddress', $refundWebhookArray); + self::assertArrayHasKey('type', $refundWebhookArray); + self::assertArrayHasKey('txid', $refundWebhookArray); + self::assertArrayHasKey('transactionCurrency', $refundWebhookArray); + self::assertArrayHasKey('transactionAmount', $refundWebhookArray); + self::assertArrayHasKey('transactionRefundFee', $refundWebhookArray); self::assertEquals('GZBBLcsgQamua3PN8GX92s', $refundWebhookArray['id']); self::assertEquals('Wp9cpGphCz7cSeFh6MSYpb', $refundWebhookArray['invoice']); @@ -141,6 +149,14 @@ public function testToArray() self::assertEquals(false, $refundWebhookArray['immediate']); self::assertEquals(true, $refundWebhookArray['buyerPaysRefundFee']); self::assertEquals('2022-01-11T16:58:23.000Z', $refundWebhookArray['requestDate']); + self::assertEquals('someReference', $refundWebhookArray['reference']); + self::assertEquals('someGuid', $refundWebhookArray['guid']); + self::assertEquals('someRefundAddress', $refundWebhookArray['refundAddress']); + self::assertEquals('someType', $refundWebhookArray['type']); + self::assertEquals('someTxid', $refundWebhookArray['txid']); + self::assertEquals('someTransactionCurrency', $refundWebhookArray['transactionCurrency']); + self::assertEquals(12.34, $refundWebhookArray['transactionAmount']); + self::assertEquals(12.11, $refundWebhookArray['transactionRefundFee']); } private function createClassObject(): RefundWebhook @@ -161,5 +177,13 @@ private function objectSetters(RefundWebhook $refundWebhook): void $refundWebhook->setImmediate(false); $refundWebhook->setBuyerPaysRefundFee(true); $refundWebhook->setRequestDate('2022-01-11T16:58:23.000Z'); + $refundWebhook->setReference('someReference'); + $refundWebhook->setGuid('someGuid'); + $refundWebhook->setRefundAddress('someRefundAddress'); + $refundWebhook->setType('someType'); + $refundWebhook->setTxid('someTxid'); + $refundWebhook->setTransactionCurrency('someTransactionCurrency'); + $refundWebhook->setTransactionAmount(12.34); + $refundWebhook->setTransactionRefundFee(12.11); } } \ No newline at end of file From 1c5795ab53d8fa3a97fd3796a5e24d76e4f64b2d Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Tue, 23 Jan 2024 16:07:19 +0100 Subject: [PATCH 2/2] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Payout/PayoutWebhook.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BitPaySDK/Model/Payout/PayoutWebhook.php b/src/BitPaySDK/Model/Payout/PayoutWebhook.php index 834f8661..68ae9df6 100644 --- a/src/BitPaySDK/Model/Payout/PayoutWebhook.php +++ b/src/BitPaySDK/Model/Payout/PayoutWebhook.php @@ -27,7 +27,7 @@ class PayoutWebhook protected ?string $status = null; protected ?array $transactions = null; protected ?string $accountId = null; - protected ?string $date = null; + protected ?string $dateExecuted = null; protected ?string $groupId = null; public function getId(): ?string @@ -209,14 +209,14 @@ public function setAccountId(?string $accountId): void /** * @return string|null */ - public function getDate(): ?string + public function getDateExecuted(): ?string { - return $this->date; + return $this->dateExecuted; } - public function setDate(?string $date): void + public function setDateExecuted(?string $dateExecuted): void { - $this->date = $date; + $this->dateExecuted = $dateExecuted; } public function getGroupId(): ?string