From aa200c7fea3cd10d898df620937427cfd133e9cc Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Mon, 11 Dec 2023 12:20:19 +0100 Subject: [PATCH 1/9] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Currency.php | 54 +---- src/BitPaySDK/Model/Invoice/BuyerFields.php | 129 ++++++++++++ src/BitPaySDK/Model/Invoice/Invoice.php | 43 ++-- src/BitPaySDK/Model/Invoice/InvoiceStatus.php | 20 +- .../Model/Invoice/InvoiceWebhook.php | 195 ++++++++++++++++++ src/BitPaySDK/Model/Invoice/RefundWebhook.php | 72 +++---- src/BitPaySDK/Model/Ledger/Buyer.php | 120 +++++------ src/BitPaySDK/Model/Ledger/LedgerEntry.php | 20 +- src/BitPaySDK/Model/Payout/Payout.php | 38 ++-- .../Model/Payout/PayoutRecipients.php | 19 +- src/BitPaySDK/Model/Payout/PayoutWebhook.php | 189 +++++++++++++++++ .../Model/Payout/RecipientWebhook.php | 80 +++++++ src/BitPaySDK/Model/Settlement/PayoutInfo.php | 54 ++--- src/BitPaySDK/Model/Settlement/Settlement.php | 2 - src/BitPaySDK/Model/Wallet/Wallet.php | 56 ++++- test/unit/BitPaySDK/ClientTest.php | 16 +- test/unit/BitPaySDK/Model/CurrencyTest.php | 30 +-- .../Model/Invoice/BuyerFieldsTest.php | 107 ++++++++++ .../BitPaySDK/Model/Invoice/InvoiceTest.php | 16 +- .../unit/BitPaySDK/Model/Ledger/BuyerTest.php | 106 +++++----- .../Model/Ledger/LedgerEntryTest.php | 6 +- ...ers.json => getLedgerEntriesResponse.json} | 0 ...rBalances.json => getLedgersResponse.json} | 0 23 files changed, 1042 insertions(+), 330 deletions(-) create mode 100644 src/BitPaySDK/Model/Invoice/BuyerFields.php create mode 100644 src/BitPaySDK/Model/Invoice/InvoiceWebhook.php create mode 100644 src/BitPaySDK/Model/Payout/PayoutWebhook.php create mode 100644 src/BitPaySDK/Model/Payout/RecipientWebhook.php create mode 100644 test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php rename test/unit/BitPaySDK/jsonResponse/{getLedgers.json => getLedgerEntriesResponse.json} (100%) rename test/unit/BitPaySDK/jsonResponse/{getLedgerBalances.json => getLedgersResponse.json} (100%) diff --git a/src/BitPaySDK/Model/Currency.php b/src/BitPaySDK/Model/Currency.php index c82e1118..fd5ee8c5 100644 --- a/src/BitPaySDK/Model/Currency.php +++ b/src/BitPaySDK/Model/Currency.php @@ -217,9 +217,8 @@ class Currency protected ?string $alts = null; protected ?string $minimum = null; protected ?bool $sanctioned = null; - protected ?string $decimals = null; - protected array $payoutFields = []; - protected array $settlementMinimum = []; + protected ?int $decimals = null; + protected ?string $chain; /** * Currency validation @@ -425,9 +424,9 @@ public function setSanctioned(bool $sanctioned): void /** * Gets decimal precision * - * @return string|null decimals + * @return int|null decimals */ - public function getDecimals(): ?string + public function getDecimals(): ?int { return $this->decimals; } @@ -435,51 +434,21 @@ public function getDecimals(): ?string /** * Sets decimal precision * - * @param string $decimals decimals + * @param int|null $decimals decimals */ - public function setDecimals(string $decimals): void + public function setDecimals(?int $decimals): void { $this->decimals = $decimals; } - /** - * Gets payout fields - * - * @return array the payout fields - */ - public function getPayoutFields(): array - { - return $this->payoutFields; - } - - /** - * Sets payout fields - * - * @param array $payoutFields the payout fields - */ - public function setPayoutFields(array $payoutFields): void + public function getChain(): ?string { - $this->payoutFields = $payoutFields; + return $this->chain; } - /** - * Gets settlement minimum - * - * @return array the settlement minimum - */ - public function getSettlementMinimum(): array - { - return $this->settlementMinimum; - } - - /** - * Sets settlement minimum - * - * @param array $settlementMinimum the settlement minimum - */ - public function setSettlementMinimum(array $settlementMinimum): void + public function setChain(?string $chain): void { - $this->settlementMinimum = $settlementMinimum; + $this->chain = $chain; } /** @@ -500,8 +469,7 @@ public function toArray(): array 'minimum' => $this->getMinimum(), 'sanctioned' => $this->getSanctioned(), 'decimals' => $this->getDecimals(), - 'payoutFields' => $this->getPayoutFields(), - 'settlementMinimum' => $this->getSettlementMinimum(), + 'chain' => $this->getChain() ]; foreach ($elements as $key => $value) { diff --git a/src/BitPaySDK/Model/Invoice/BuyerFields.php b/src/BitPaySDK/Model/Invoice/BuyerFields.php new file mode 100644 index 00000000..2c3d6371 --- /dev/null +++ b/src/BitPaySDK/Model/Invoice/BuyerFields.php @@ -0,0 +1,129 @@ + + * @license http://www.opensource.org/licenses/mit-license.php MIT + * @see https://developer.bitpay.com/reference/notifications-invoices Notifications Invoices + */ +class BuyerFields +{ + protected ?string $buyerName = null; + protected ?string $buyerAddress1 = null; + protected ?string $buyerAddress2 = null; + protected ?string $buyerCity = null; + protected ?string $buyerState = null; + protected ?string $buyerZip = null; + protected ?string $buyerCountry = null; + protected ?string $buyerPhone = null; + protected ?bool $buyerNotify = null; + protected ?string $buyerEmail = null; + + public function getBuyerName(): ?string + { + return $this->buyerName; + } + + public function setBuyerName(?string $buyerName): void + { + $this->buyerName = $buyerName; + } + + public function getBuyerAddress1(): ?string + { + return $this->buyerAddress1; + } + + public function setBuyerAddress1(?string $buyerAddress1): void + { + $this->buyerAddress1 = $buyerAddress1; + } + + public function getBuyerAddress2(): ?string + { + return $this->buyerAddress2; + } + + public function setBuyerAddress2(?string $buyerAddress2): void + { + $this->buyerAddress2 = $buyerAddress2; + } + + public function getBuyerCity(): ?string + { + return $this->buyerCity; + } + + public function setBuyerCity(?string $buyerCity): void + { + $this->buyerCity = $buyerCity; + } + + public function getBuyerState(): ?string + { + return $this->buyerState; + } + + public function setBuyerState(?string $buyerState): void + { + $this->buyerState = $buyerState; + } + + public function getBuyerZip(): ?string + { + return $this->buyerZip; + } + + public function setBuyerZip(?string $buyerZip): void + { + $this->buyerZip = $buyerZip; + } + + public function getBuyerCountry(): ?string + { + return $this->buyerCountry; + } + + public function setBuyerCountry(?string $buyerCountry): void + { + $this->buyerCountry = $buyerCountry; + } + + public function getBuyerPhone(): ?string + { + return $this->buyerPhone; + } + + public function setBuyerPhone(?string $buyerPhone): void + { + $this->buyerPhone = $buyerPhone; + } + + public function getBuyerNotify(): ?bool + { + return $this->buyerNotify; + } + + public function setBuyerNotify(?bool $buyerNotify): void + { + $this->buyerNotify = $buyerNotify; + } + + public function getBuyerEmail(): ?string + { + return $this->buyerEmail; + } + + public function setBuyerEmail(?string $buyerEmail): void + { + $this->buyerEmail = $buyerEmail; + } +} diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 45f3d13e..6f4819f6 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -39,7 +39,7 @@ class Invoice protected ?array $paymentSubtotals = null; protected ?array $paymentTotals = null; protected ?array $paymentCodes = null; - protected ?float $acceptanceWindow = null; + protected ?int $acceptanceWindow = null; protected ?Buyer $buyer = null; protected ?array $refundAddresses = null; protected ?string $closeURL = null; @@ -60,10 +60,10 @@ class Invoice protected ?string $status = null; protected ?bool $lowFeeDetected = null; protected ?int $invoiceTime = null; - protected ?string $expirationTime = null; - protected ?string $currentTime = null; + protected ?int $expirationTime = null; + protected ?int $currentTime = null; protected ?array $transactions = null; - protected ?bool $exceptionStatus = null; + protected bool|string|null $exceptionStatus = null; protected ?int $targetConfirmations = null; protected ?bool $refundAddressRequestPending = null; protected ?string $buyerProvidedEmail = null; @@ -778,9 +778,9 @@ public function setItemizedDetails(array $itemizedDetails): void * If not set, invoice will default to the account acceptanceWindow. * If account acceptanceWindow is not set, invoice will default to 15 minutes (900,000 milliseconds). * - * @return float|null the acceptance window + * @return int|null the acceptance window */ - public function getAcceptanceWindow(): ?float + public function getAcceptanceWindow(): ?int { return $this->acceptanceWindow; } @@ -792,9 +792,9 @@ public function getAcceptanceWindow(): ?float * If not set, invoice will default to the account acceptanceWindow. * If account acceptanceWindow is not set, invoice will default to 15 minutes (900,000 milliseconds). * - * @param float $acceptanceWindow Number of milliseconds that a user has to pay an invoice before it expire + * @param int $acceptanceWindow Number of milliseconds that a user has to pay an invoice before it expire */ - public function setAcceptanceWindow(float $acceptanceWindow): void + public function setAcceptanceWindow(int $acceptanceWindow): void { $this->acceptanceWindow = $acceptanceWindow; } @@ -960,7 +960,7 @@ public function setUrl(string $url): void * Instant Payment Notification (IPN) section. * * - * @return string|null Invoice status + * @return string|null InvoiceStatus const value */ public function getStatus(): ?string { @@ -973,9 +973,10 @@ public function getStatus(): ?string * Detailed information about invoice status notifications can be found under the * * Instant Payment Notification (IPN) section. + * Use values from InvoiceStatus const. * * - * @param string $status Invoice status + * @param string $status InvoiceStatus const value */ public function setStatus(string $status): void { @@ -1031,9 +1032,9 @@ public function setInvoiceTime(int $invoiceTime) /** * Gets expirationTime - UNIX time when invoice is last available to be paid, in milliseconds * - * @return string|null the UNIX time + * @return int|null the UNIX time */ - public function getExpirationTime(): ?string + public function getExpirationTime(): ?int { return $this->expirationTime; } @@ -1041,9 +1042,9 @@ public function getExpirationTime(): ?string /** * Sets expirationTime - UNIX time when invoice is last available to be paid, in milliseconds * - * @param string $expirationTime UNIX time when invoice is last available to be paid, in milliseconds + * @param int|null $expirationTime UNIX time when invoice is last available to be paid, in milliseconds */ - public function setExpirationTime(string $expirationTime): void + public function setExpirationTime(?int $expirationTime): void { $this->expirationTime = $expirationTime; } @@ -1051,9 +1052,9 @@ public function setExpirationTime(string $expirationTime): void /** * Gets currentTime - UNIX time of API call, in milliseconds * - * @return string|null UNIX time + * @return int|null UNIX time */ - public function getCurrentTime(): ?string + public function getCurrentTime(): ?int { return $this->currentTime; } @@ -1061,9 +1062,9 @@ public function getCurrentTime(): ?string /** * Sets currentTime - UNIX time of API call, in milliseconds * - * @param string $currentTime UNIX time of API call, in milliseconds + * @param int|null $currentTime UNIX time of API call, in milliseconds */ - public function setCurrentTime(string $currentTime): void + public function setCurrentTime(?int $currentTime): void { $this->currentTime = $currentTime; } @@ -1101,9 +1102,9 @@ public function setTransactions(array $transactions): void * "paidPartial": (string) if the consumer did not send enough funds when paying the invoice. * "paidOver": (string) if the consumer sent to much funds when paying the invoice. * - * @return bool|null the exception status + * @return bool|string|null the exception status */ - public function getExceptionStatus(): ?bool + public function getExceptionStatus(): bool|string|null { return $this->exceptionStatus; } @@ -1119,7 +1120,7 @@ public function getExceptionStatus(): ?bool * * @param boolean $exceptionStatus this parameter will indicate if the purchaser sent too much or not enough funds */ - public function setExceptionStatus(bool $exceptionStatus): void + public function setExceptionStatus(bool|string|null $exceptionStatus): void { $this->exceptionStatus = $exceptionStatus; } diff --git a/src/BitPaySDK/Model/Invoice/InvoiceStatus.php b/src/BitPaySDK/Model/Invoice/InvoiceStatus.php index 1c6ad734..c86b7da5 100644 --- a/src/BitPaySDK/Model/Invoice/InvoiceStatus.php +++ b/src/BitPaySDK/Model/Invoice/InvoiceStatus.php @@ -23,7 +23,7 @@ interface InvoiceStatus * it will still reflect a status of new to the merchant. From a merchant system perspective, * an invoice is either paid or not paid, partial payments are automatically refunded by BitPay to the consumer. */ - public const NEW = "new"; + public const NEW = 'new'; /** * As soon as payment is received it is evaluated against the invoice requested amount. @@ -31,7 +31,7 @@ interface InvoiceStatus * To detect whether the invoice has been overpaid consult the invoice exception status (exceptionStatus parameter). * The overpaid amount on an invoice is automatically refunded by BitPay to the consumer. */ - public const PAID = "paid"; + public const PAID = 'paid'; /** * This status can be used by merchants in order to fulfill orders placed by the consumer. @@ -40,7 +40,7 @@ interface InvoiceStatus * This can be configured during invoice creation using the "transactionSpeed" parameter * (section Create an invoice), or at account level via a dashboard setting. */ - public const CONFIRMED = "confirmed"; + public const CONFIRMED = 'confirmed'; /** * When an invoice has the status complete, it means that BitPay has credited the merchant account, @@ -48,12 +48,12 @@ interface InvoiceStatus * 6 confirmation blocks on the bitcoin network are required for an invoice to be complete, * this takes on average 1 hour. */ - public const COMPLETE = "complete"; + public const COMPLETE = 'complete'; /** * An invoice reaches the expired status if no payment was received and the 15 minute payment window has elapsed. */ - public const EXPIRED = "expired"; + public const EXPIRED = 'expired'; /** * An invoice is considered invalid when it was paid, @@ -62,5 +62,13 @@ interface InvoiceStatus * If the transaction confirms after 1 hour, BitPay will update the invoice state from "invalid" to "complete" * (6 confirmations for transactions on the bitcoin network for instance). */ - public const INVALID = "invalid"; + public const INVALID = 'invalid'; + + /** + * An invoice in the declined status is no longer eligible to be successfully completed, + * and the customer will be automatically contacted regarding a refund if needed. + * Reason for this status include cancelling an invoice before completion + * and the invoice remaining unconfirmed after a set time period - typically 24 hours. + */ + public const DECLINED = 'declined'; } diff --git a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php new file mode 100644 index 00000000..9f601cb1 --- /dev/null +++ b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php @@ -0,0 +1,195 @@ + + * @license http://www.opensource.org/licenses/mit-license.php MIT + * @see https://developer.bitpay.com/reference/notifications-invoices Notifications Invoices + */ +class InvoiceWebhook +{ + protected ?string $id; + protected ?string $url; + protected ?string $posData; + protected ?string $status; + protected ?float $price; + protected ?string $currency; + protected ?string $invoiceTime; + protected ?string $currencyTime; + protected ?string $exceptionStatus; + protected ?BuyerFields $buyerFields; + protected ?array $paymentSubtotals; + protected ?array $paymentTotals; + protected ?array $exchangeRates; + protected ?int $amountPaid; + protected ?string $orderId; + protected ?string $transactionCurrency; + + public function getId(): ?string + { + return $this->id; + } + + public function setId(?string $id): void + { + $this->id = $id; + } + + public function getUrl(): ?string + { + return $this->url; + } + + public function setUrl(?string $url): void + { + $this->url = $url; + } + + public function getPosData(): ?string + { + return $this->posData; + } + + public function setPosData(?string $posData): void + { + $this->posData = $posData; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): void + { + $this->status = $status; + } + + public function getPrice(): ?float + { + return $this->price; + } + + public function setPrice(?float $price): void + { + $this->price = $price; + } + + public function getCurrency(): ?string + { + return $this->currency; + } + + public function setCurrency(?string $currency): void + { + $this->currency = $currency; + } + + public function getInvoiceTime(): ?string + { + return $this->invoiceTime; + } + + public function setInvoiceTime(?string $invoiceTime): void + { + $this->invoiceTime = $invoiceTime; + } + + public function getCurrencyTime(): ?string + { + return $this->currencyTime; + } + + public function setCurrencyTime(?string $currencyTime): void + { + $this->currencyTime = $currencyTime; + } + + public function getExceptionStatus(): ?string + { + return $this->exceptionStatus; + } + + public function setExceptionStatus(?string $exceptionStatus): void + { + $this->exceptionStatus = $exceptionStatus; + } + + public function getBuyerFields(): ?BuyerFields + { + return $this->buyerFields; + } + + public function setBuyerFields(?BuyerFields $buyerFields): void + { + $this->buyerFields = $buyerFields; + } + + public function getPaymentSubtotals(): ?array + { + return $this->paymentSubtotals; + } + + public function setPaymentSubtotals(?array $paymentSubtotals): void + { + $this->paymentSubtotals = $paymentSubtotals; + } + + public function getPaymentTotals(): ?array + { + return $this->paymentTotals; + } + + public function setPaymentTotals(?array $paymentTotals): void + { + $this->paymentTotals = $paymentTotals; + } + + public function getExchangeRates(): ?array + { + return $this->exchangeRates; + } + + public function setExchangeRates(?array $exchangeRates): void + { + $this->exchangeRates = $exchangeRates; + } + + public function getAmountPaid(): ?int + { + return $this->amountPaid; + } + + public function setAmountPaid(?int $amountPaid): void + { + $this->amountPaid = $amountPaid; + } + + public function getOrderId(): ?string + { + return $this->orderId; + } + + public function setOrderId(?string $orderId): void + { + $this->orderId = $orderId; + } + + public function getTransactionCurrency(): ?string + { + return $this->transactionCurrency; + } + + public function setTransactionCurrency(?string $transactionCurrency): void + { + $this->transactionCurrency = $transactionCurrency; + } +} diff --git a/src/BitPaySDK/Model/Invoice/RefundWebhook.php b/src/BitPaySDK/Model/Invoice/RefundWebhook.php index fb70d29b..8299ca3d 100644 --- a/src/BitPaySDK/Model/Invoice/RefundWebhook.php +++ b/src/BitPaySDK/Model/Invoice/RefundWebhook.php @@ -18,128 +18,124 @@ */ class RefundWebhook { - protected string $id; - protected string $invoice; - protected string $supportRequest; - protected string $status; - protected float $amount; - protected string $currency; - protected string $lastRefundNotification; - protected float $refundFee; - protected bool $immediate; - protected bool $buyerPaysRefundFee; - protected string $requestDate; - - public function __construct() - { - } - - public function getId(): string + protected ?string $id = null; + protected ?string $invoice = null; + protected ?string $supportRequest = null; + protected ?string $status = null; + protected ?int $amount = null; + protected ?string $currency = null; + protected ?string $lastRefundNotification = null; + protected ?float $refundFee = null; + protected ?bool $immediate = null; + protected ?bool $buyerPaysRefundFee = null; + protected ?string $requestDate = null; + + public function getId(): ?string { return $this->id; } - public function setId(string $id): void + public function setId(?string $id): void { $this->id = $id; } - public function getInvoice(): string + public function getInvoice(): ?string { return $this->invoice; } - public function setInvoice(string $invoice): void + public function setInvoice(?string $invoice): void { $this->invoice = $invoice; } - public function getSupportRequest(): string + public function getSupportRequest(): ?string { return $this->supportRequest; } - public function setSupportRequest(string $supportRequest): void + public function setSupportRequest(?string $supportRequest): void { $this->supportRequest = $supportRequest; } - public function getStatus(): string + public function getStatus(): ?string { return $this->status; } - public function setStatus(string $status): void + public function setStatus(?string $status): void { $this->status = $status; } - public function getAmount(): float + public function getAmount(): ?int { return $this->amount; } - public function setAmount(float $amount): void + public function setAmount(?int $amount): void { $this->amount = $amount; } - public function getCurrency(): string + public function getCurrency(): ?string { return $this->currency; } - public function setCurrency(string $currency): void + public function setCurrency(?string $currency): void { $this->currency = $currency; } - public function getLastRefundNotification(): string + public function getLastRefundNotification(): ?string { return $this->lastRefundNotification; } - public function setLastRefundNotification(string $lastRefundNotification): void + public function setLastRefundNotification(?string $lastRefundNotification): void { $this->lastRefundNotification = $lastRefundNotification; } - public function getRefundFee(): float + public function getRefundFee(): ?float { return $this->refundFee; } - public function setRefundFee(float $refundFee): void + public function setRefundFee(?float $refundFee): void { $this->refundFee = $refundFee; } - public function getImmediate(): bool + public function getImmediate(): ?bool { return $this->immediate; } - public function setImmediate(bool $immediate): void + public function setImmediate(?bool $immediate): void { $this->immediate = $immediate; } - public function getBuyerPaysRefundFee(): bool + public function getBuyerPaysRefundFee(): ?bool { return $this->buyerPaysRefundFee; } - public function setBuyerPaysRefundFee(bool $buyerPaysRefundFee): void + public function setBuyerPaysRefundFee(?bool $buyerPaysRefundFee): void { $this->buyerPaysRefundFee = $buyerPaysRefundFee; } - public function getRequestDate(): string + public function getRequestDate(): ?string { return $this->requestDate; } - public function setRequestDate(string $requestDate): void + public function setRequestDate(?string $requestDate): void { $this->requestDate = $requestDate; } diff --git a/src/BitPaySDK/Model/Ledger/Buyer.php b/src/BitPaySDK/Model/Ledger/Buyer.php index d411cb19..8111c392 100644 --- a/src/BitPaySDK/Model/Ledger/Buyer.php +++ b/src/BitPaySDK/Model/Ledger/Buyer.php @@ -16,16 +16,16 @@ */ class Buyer { - protected ?string $name = null; - protected ?string $address1 = null; - protected ?string $address2 = null; - protected ?string $city = null; - protected ?string $state = null; - protected ?string $zip = null; - protected ?string $country = null; - protected ?string $phone = null; - protected ?bool $notify = null; - protected ?string $email = null; + protected ?string $buyerName = null; + protected ?string $buyerAddress1 = null; + protected ?string $buyerAddress2 = null; + protected ?string $buyerCity = null; + protected ?string $buyerState = null; + protected ?string $buyerZip = null; + protected ?string $buyerCountry = null; + protected ?string $buyerPhone = null; + protected ?bool $buyerNotify = null; + protected ?string $buyerEmail = null; public function __construct() { @@ -36,9 +36,9 @@ public function __construct() * * @return string|null the name */ - public function getName(): ?string + public function getBuyerName(): ?string { - return $this->name; + return $this->buyerName; } /** @@ -46,9 +46,9 @@ public function getName(): ?string * * @param string $name the name */ - public function setName(string $name): void + public function setBuyerName(string $name): void { - $this->name = $name; + $this->buyerName = $name; } /** @@ -56,9 +56,9 @@ public function setName(string $name): void * * @return string|null the address1 */ - public function getAddress1(): ?string + public function getBuyerAddress1(): ?string { - return $this->address1; + return $this->buyerAddress1; } /** @@ -66,9 +66,9 @@ public function getAddress1(): ?string * * @param string $address1 the address1 */ - public function setAddress1(string $address1): void + public function setBuyerAddress1(string $address1): void { - $this->address1 = $address1; + $this->buyerAddress1 = $address1; } /** @@ -76,9 +76,9 @@ public function setAddress1(string $address1): void * * @return string|null the address2 */ - public function getAddress2(): ?string + public function getBuyerAddress2(): ?string { - return $this->address2; + return $this->buyerAddress2; } /** @@ -86,9 +86,9 @@ public function getAddress2(): ?string * * @param string $address2 the address2 */ - public function setAddress2(string $address2): void + public function setBuyerAddress2(string $address2): void { - $this->address2 = $address2; + $this->buyerAddress2 = $address2; } /** @@ -96,9 +96,9 @@ public function setAddress2(string $address2): void * * @return string|null the city */ - public function getCity(): ?string + public function getBuyerCity(): ?string { - return $this->city; + return $this->buyerCity; } /** @@ -106,9 +106,9 @@ public function getCity(): ?string * * @param string $city the city */ - public function setCity(string $city): void + public function setBuyerCity(string $city): void { - $this->city = $city; + $this->buyerCity = $city; } /** @@ -116,9 +116,9 @@ public function setCity(string $city): void * * @return string|null the state */ - public function getState(): ?string + public function getBuyerState(): ?string { - return $this->state; + return $this->buyerState; } /** @@ -126,9 +126,9 @@ public function getState(): ?string * * @param string $state the state */ - public function setState(string $state): void + public function setBuyerState(string $state): void { - $this->state = $state; + $this->buyerState = $state; } /** @@ -136,9 +136,9 @@ public function setState(string $state): void * * @return string|null the zip */ - public function getZip(): ?string + public function getBuyerZip(): ?string { - return $this->zip; + return $this->buyerZip; } /** @@ -146,9 +146,9 @@ public function getZip(): ?string * * @param string $zip the zip */ - public function setZip(string $zip): void + public function setBuyerZip(string $zip): void { - $this->zip = $zip; + $this->buyerZip = $zip; } /** @@ -156,9 +156,9 @@ public function setZip(string $zip): void * * @return string|null the country */ - public function getCountry(): ?string + public function getBuyerCountry(): ?string { - return $this->country; + return $this->buyerCountry; } /** @@ -166,9 +166,9 @@ public function getCountry(): ?string * * @param string $country the country */ - public function setCountry(string $country): void + public function setBuyerCountry(string $country): void { - $this->country = $country; + $this->buyerCountry = $country; } /** @@ -176,9 +176,9 @@ public function setCountry(string $country): void * * @return string|null the email */ - public function getEmail(): ?string + public function getBuyerEmail(): ?string { - return $this->email; + return $this->buyerEmail; } /** @@ -186,9 +186,9 @@ public function getEmail(): ?string * * @param string $email the email */ - public function setEmail(string $email): void + public function setBuyerEmail(string $email): void { - $this->email = $email; + $this->buyerEmail = $email; } /** @@ -196,9 +196,9 @@ public function setEmail(string $email): void * * @return string|null the phone */ - public function getPhone(): ?string + public function getBuyerPhone(): ?string { - return $this->phone; + return $this->buyerPhone; } /** @@ -206,9 +206,9 @@ public function getPhone(): ?string * * @param string $phone the phone */ - public function setPhone(string $phone): void + public function setBuyerPhone(string $phone): void { - $this->phone = $phone; + $this->buyerPhone = $phone; } /** @@ -216,9 +216,9 @@ public function setPhone(string $phone): void * * @return bool|null notify */ - public function getNotify(): ?bool + public function getBuyerNotify(): ?bool { - return $this->notify; + return $this->buyerNotify; } /** @@ -226,9 +226,9 @@ public function getNotify(): ?bool * * @param bool $notify notify */ - public function setNotify(bool $notify): void + public function setBuyerNotify(bool $notify): void { - $this->notify = $notify; + $this->buyerNotify = $notify; } /** @@ -239,16 +239,16 @@ public function setNotify(bool $notify): void public function toArray(): array { $elements = [ - 'name' => $this->getName(), - 'address1' => $this->getAddress1(), - 'address2' => $this->getAddress2(), - 'city' => $this->getCity(), - 'state' => $this->getState(), - 'zip' => $this->getZip(), - 'country' => $this->getCountry(), - 'phone' => $this->getPhone(), - 'notify' => $this->getNotify(), - 'email' => $this->getEmail(), + 'buyerName' => $this->getBuyerName(), + 'buyerAddress1' => $this->getBuyerAddress1(), + 'buyerAddress2' => $this->getBuyerAddress2(), + 'buyerCity' => $this->getBuyerCity(), + 'buyerState' => $this->getBuyerState(), + 'buyerZip' => $this->getBuyerZip(), + 'buyerCountry' => $this->getBuyerCountry(), + 'buyerPhone' => $this->getBuyerPhone(), + 'buyerNotify' => $this->getBuyerNotify(), + 'buyerEmail' => $this->getBuyerEmail(), ]; foreach ($elements as $key => $value) { diff --git a/src/BitPaySDK/Model/Ledger/LedgerEntry.php b/src/BitPaySDK/Model/Ledger/LedgerEntry.php index b33c9173..49f4c257 100644 --- a/src/BitPaySDK/Model/Ledger/LedgerEntry.php +++ b/src/BitPaySDK/Model/Ledger/LedgerEntry.php @@ -22,8 +22,8 @@ class LedgerEntry { protected ?string $type = null; - protected ?string $amount = null; - protected ?string $code = null; + protected ?float $amount = null; + protected ?int $code = null; protected ?string $timestamp = null; protected ?string $currency = null; protected ?string $txType = null; @@ -72,9 +72,9 @@ public function setType(string $type): void * Gets Ledger entry amount, relative to the scale. * The decimal amount can be obtained by dividing the amount field by the scale parameter. * - * @return string|null + * @return float|null */ - public function getAmount(): ?string + public function getAmount(): ?float { return $this->amount; } @@ -83,9 +83,9 @@ public function getAmount(): ?string * Sets Ledger entry amount, relative to the scale. * The decimal amount can be obtained by dividing the amount field by the scale parameter. * - * @param string $amount the amount + * @param float $amount the amount */ - public function setAmount(string $amount): void + public function setAmount(float $amount): void { $this->amount = $amount; } @@ -96,9 +96,9 @@ public function setAmount(string $amount): void * Contains the Ledger entry code. * See the list of Ledger Entry Codes: https://bitpay.com/api/?php#ledger-entry-codes * - * @return string|null the code + * @return int|null the code */ - public function getCode(): ?string + public function getCode(): ?int { return $this->code; } @@ -109,9 +109,9 @@ public function getCode(): ?string * Contains the Ledger entry code. * See the list of Ledger Entry Codes: https://bitpay.com/api/?php#ledger-entry-codes * - * @param string $code the code + * @param int $code the code */ - public function setCode(string $code): void + public function setCode(int $code): void { $this->code = $code; } diff --git a/src/BitPaySDK/Model/Payout/Payout.php b/src/BitPaySDK/Model/Payout/Payout.php index d8df287e..e43c61eb 100644 --- a/src/BitPaySDK/Model/Payout/Payout.php +++ b/src/BitPaySDK/Model/Payout/Payout.php @@ -20,20 +20,20 @@ */ class Payout { - protected string $token = ''; + protected ?string $token = null; protected ?float $amount = null; protected ?string $currency = null; protected ?string $effectiveDate = null; protected ?string $ledgerCurrency = null; - protected string $reference = ''; - protected string $notificationURL = ''; - protected string $notificationEmail = ''; - protected string $accountId = ''; - protected string $email = ''; - protected string $recipientId = ''; - protected string $shopperId = ''; - protected string $label = ''; - protected string $message = ''; + protected ?string $reference = null; + protected ?string $notificationURL = null; + protected ?string $notificationEmail = null; + protected ?string $accountId = null; + protected ?string $email = null; + protected ?string $recipientId = null; + protected ?string $shopperId = null; + protected ?string $label = null; + protected ?string $message = null; protected bool $ignoreEmails = false; protected ?string $groupId = null; protected ?int $code = null; @@ -229,7 +229,7 @@ public function setLedgerCurrency(string $ledgerCurrency): void * * @return string */ - public function getReference(): string + public function getReference(): ?string { return $this->reference; } @@ -255,7 +255,7 @@ public function setReference(string $reference): void * * @return string */ - public function getNotificationURL(): string + public function getNotificationURL(): ?string { return $this->notificationURL; } @@ -279,7 +279,7 @@ public function setNotificationURL(string $notificationURL): void * * @return string */ - public function getNotificationEmail(): string + public function getNotificationEmail(): ?string { return $this->notificationEmail; } @@ -302,7 +302,7 @@ public function setNotificationEmail(string $notificationEmail): void * * @return string */ - public function getAccountId(): string + public function getAccountId(): ?string { return $this->accountId; } @@ -327,7 +327,7 @@ public function setAccountId(string $accountId): void * * @return string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } @@ -351,7 +351,7 @@ public function setEmail(string $email): void * * @return string */ - public function getRecipientId(): string + public function getRecipientId(): ?string { return $this->recipientId; } @@ -378,7 +378,7 @@ public function setRecipientId(string $recipientId): void * * @return string */ - public function getShopperId(): string + public function getShopperId(): ?string { return $this->shopperId; } @@ -408,7 +408,7 @@ public function setShopperId(string $shopperId): void * * @return string */ - public function getLabel(): string + public function getLabel(): ?string { return $this->label; } @@ -433,7 +433,7 @@ public function setLabel(string $label): void * * @return string */ - public function getMessage(): string + public function getMessage(): ?string { return $this->message; } diff --git a/src/BitPaySDK/Model/Payout/PayoutRecipients.php b/src/BitPaySDK/Model/Payout/PayoutRecipients.php index 5da7e110..d90bc5ab 100644 --- a/src/BitPaySDK/Model/Payout/PayoutRecipients.php +++ b/src/BitPaySDK/Model/Payout/PayoutRecipients.php @@ -13,7 +13,8 @@ namespace BitPaySDK\Model\Payout; -use BitPaySDK\Exceptions\PayoutRecipientException; +use BitPaySDK\Exceptions\BitPayExceptionProvider; +use BitPaySDK\Exceptions\BitPayValidationException; /** * @package BitPaySDK\Model\Payout @@ -24,8 +25,8 @@ class PayoutRecipients { protected array $recipients = []; - protected string $guid = ''; - protected string $token = ''; + protected ?string $guid = null; + protected ?string $token = null; /** * Constructor, create an recipient-full request PayoutBatch object. @@ -43,9 +44,9 @@ public function __construct(array $recipients = []) /** * Gets guid. * - * @return string + * @return string|null */ - public function getGuid(): string + public function getGuid(): ?string { return $this->guid; } @@ -63,9 +64,9 @@ public function setGuid(string $guid): void /** * Gets token. * - * @return string + * @return string|null */ - public function getToken(): string + public function getToken(): ?string { return $this->token; } @@ -97,13 +98,13 @@ public function getRecipients(): array * Sets array with all recipients. * * @param PayoutRecipient[] $recipients - * @throws PayoutRecipientException + * @throws BitPayValidationException */ public function setRecipients(array $recipients): void { foreach ($recipients as $recipient) { if (!$recipient instanceof PayoutRecipient) { - throw new PayoutRecipientException('Array should contains only PayoutRecipient objects'); + BitPayExceptionProvider::throwValidationException('Array should contains only PayoutRecipient objects'); } } diff --git a/src/BitPaySDK/Model/Payout/PayoutWebhook.php b/src/BitPaySDK/Model/Payout/PayoutWebhook.php new file mode 100644 index 00000000..2bf445d0 --- /dev/null +++ b/src/BitPaySDK/Model/Payout/PayoutWebhook.php @@ -0,0 +1,189 @@ +id; + } + + public function setId(?string $id): void + { + $this->id = $id; + } + + public function getRecipientId(): ?string + { + return $this->recipientId; + } + + public function setRecipientId(?string $recipientId): void + { + $this->recipientId = $recipientId; + } + + public function getShopperId(): ?string + { + return $this->shopperId; + } + + public function setShopperId(?string $shopperId): void + { + $this->shopperId = $shopperId; + } + + public function getPrice(): ?float + { + return $this->price; + } + + public function setPrice(?float $price): void + { + $this->price = $price; + } + + public function getCurrency(): ?string + { + return $this->currency; + } + + public function setCurrency(?string $currency): void + { + $this->currency = $currency; + } + + public function getLedgerCurrency(): ?string + { + return $this->ledgerCurrency; + } + + public function setLedgerCurrency(?string $ledgerCurrency): void + { + $this->ledgerCurrency = $ledgerCurrency; + } + + public function getExchangeRates(): ?array + { + return $this->exchangeRates; + } + + public function setExchangeRates(?array $exchangeRates): void + { + $this->exchangeRates = $exchangeRates; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(?string $email): void + { + $this->email = $email; + } + + public function getReference(): ?string + { + return $this->reference; + } + + public function setReference(?string $reference): void + { + $this->reference = $reference; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): void + { + $this->label = $label; + } + + public function getNotificationURL(): ?string + { + return $this->notificationURL; + } + + public function setNotificationURL(?string $notificationURL): void + { + $this->notificationURL = $notificationURL; + } + + public function getNotificationEmail(): ?string + { + return $this->notificationEmail; + } + + public function setNotificationEmail(?string $notificationEmail): void + { + $this->notificationEmail = $notificationEmail; + } + + public function getEffectiveDate(): ?string + { + return $this->effectiveDate; + } + + public function setEffectiveDate(?string $effectiveDate): void + { + $this->effectiveDate = $effectiveDate; + } + + public function getRequestDate(): ?string + { + return $this->requestDate; + } + + public function setRequestDate(?string $requestDate): void + { + $this->requestDate = $requestDate; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): void + { + $this->status = $status; + } + + public function getTransactions(): ?array + { + return $this->transactions; + } + + public function setTransactions(?array $transactions): void + { + $this->transactions = $transactions; + } +} diff --git a/src/BitPaySDK/Model/Payout/RecipientWebhook.php b/src/BitPaySDK/Model/Payout/RecipientWebhook.php new file mode 100644 index 00000000..98920a3f --- /dev/null +++ b/src/BitPaySDK/Model/Payout/RecipientWebhook.php @@ -0,0 +1,80 @@ +email; + } + + public function setEmail(?string $email): void + { + $this->email = $email; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): void + { + $this->label = $label; + } + + /** + * @return string|null RecipientStatus value + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param string|null $status RecipientStatus value + * @return void + */ + public function setStatus(?string $status): void + { + $this->status = $status; + } + + public function getId(): ?string + { + return $this->id; + } + + public function setId(?string $id): void + { + $this->id = $id; + } + + public function getShopperId(): ?string + { + return $this->shopperId; + } + + public function setShopperId(?string $shopperId): void + { + $this->shopperId = $shopperId; + } + + + + + +} diff --git a/src/BitPaySDK/Model/Settlement/PayoutInfo.php b/src/BitPaySDK/Model/Settlement/PayoutInfo.php index 21ecbb45..6e6a6d42 100644 --- a/src/BitPaySDK/Model/Settlement/PayoutInfo.php +++ b/src/BitPaySDK/Model/Settlement/PayoutInfo.php @@ -19,9 +19,7 @@ class PayoutInfo { protected ?string $name = null; - protected ?string $account = null; protected ?string $routing = null; - protected ?string $merchantEin = null; protected ?string $label = null; protected ?string $bankCountry = null; protected ?string $bank = null; @@ -29,8 +27,10 @@ class PayoutInfo protected ?string $address = null; protected ?string $city = null; protected ?string $postal = null; + protected ?string $account = null; + protected ?string $merchantEin = null; protected ?string $sort = null; - protected ?string $wire = null; + protected ?bool $wire = null; protected ?string $bankName = null; protected ?string $bankAddress = null; protected ?string $bankAddress2 = null; @@ -47,26 +47,6 @@ public function __construct() { } - /** - * Gets Bank account number of the merchant - * - * @return string|null the bank account number - */ - public function getAccount(): ?string - { - return $this->account; - } - - /** - * Sets Bank account number of the merchant - * - * @param string $account the bank account number - */ - public function setAccount(string $account): void - { - $this->account = $account; - } - /** * Gets routing * @@ -280,6 +260,26 @@ public function setPostal(string $postal): void $this->postal = $postal; } + /** + * Gets Bank account number of the merchant + * + * @return string|null the bank account number + */ + public function getAccount(): ?string + { + return $this->account; + } + + /** + * Sets Bank account number of the merchant + * + * @param string $account the bank account number + */ + public function setAccount(string $account): void + { + $this->account = $account; + } + /** * Gets sort * @@ -308,9 +308,9 @@ public function setSort(string $sort): void * If set to true, this means BitPay will be settling the account using an international transfer via the SWIFT * network instead of local settlement methods like ACH(United States) or SEPA (European Economic Area) * - * @return string|null the wire + * @return bool|null the wire */ - public function getWire(): ?string + public function getWire(): ?bool { return $this->wire; } @@ -318,9 +318,9 @@ public function getWire(): ?string /** * Sets wire * - * @param string $wire the wire + * @param bool $wire the wire */ - public function setWire(string $wire): void + public function setWire(bool $wire): void { $this->wire = $wire; } diff --git a/src/BitPaySDK/Model/Settlement/Settlement.php b/src/BitPaySDK/Model/Settlement/Settlement.php index efd5947a..fd6a7b60 100644 --- a/src/BitPaySDK/Model/Settlement/Settlement.php +++ b/src/BitPaySDK/Model/Settlement/Settlement.php @@ -8,8 +8,6 @@ namespace BitPaySDK\Model\Settlement; -use BitPaySDK\Exceptions\SettlementException; - /** * Settlement data object. * diff --git a/src/BitPaySDK/Model/Wallet/Wallet.php b/src/BitPaySDK/Model/Wallet/Wallet.php index 579ee5e9..812f3c81 100644 --- a/src/BitPaySDK/Model/Wallet/Wallet.php +++ b/src/BitPaySDK/Model/Wallet/Wallet.php @@ -22,6 +22,9 @@ class Wallet protected Currencies $currencies; protected ?string $image = null; protected ?bool $payPro = null; + protected ?string $uniCode = null; + protected ?bool $offChainMode = null; + protected ?string $invoiceDefault = null; /** * Constructor, create a minimal request Wallet object. @@ -171,6 +174,54 @@ public function setImage(string $image): void $this->image = $image; } + /** + * @return string|null + */ + public function getUniCode(): ?string + { + return $this->uniCode; + } + + /** + * @param string|null $uniCode + */ + public function setUniCode(?string $uniCode): void + { + $this->uniCode = $uniCode; + } + + /** + * @return bool|null + */ + public function getOffChainMode(): ?bool + { + return $this->offChainMode; + } + + /** + * @param bool|null $offChainMode + */ + public function setOffChainMode(?bool $offChainMode): void + { + $this->offChainMode = $offChainMode; + } + + /** + * @return string|null + */ + public function getInvoiceDefault(): ?string + { + return $this->invoiceDefault; + } + + /** + * @param string|null $invoiceDefault + */ + public function setInvoiceDefault(?string $invoiceDefault): void + { + $this->invoiceDefault = $invoiceDefault; + } + /** * Gets Wallet as array * @@ -184,7 +235,10 @@ public function toArray(): array 'avatar' => $this->getAvatar(), 'paypro' => $this->getPayPro(), 'currencies' => $this->getCurrencies()->toArray(), - 'image' => $this->getImage() + 'image' => $this->getImage(), + 'uniCode' => $this->getUniCode(), + 'offChainMode' => $this->getOffChainMode(), + 'invoiceDefault' => $this->getInvoiceDefault() ]; } } diff --git a/test/unit/BitPaySDK/ClientTest.php b/test/unit/BitPaySDK/ClientTest.php index ae4bd209..5bed61ef 100644 --- a/test/unit/BitPaySDK/ClientTest.php +++ b/test/unit/BitPaySDK/ClientTest.php @@ -622,13 +622,13 @@ public function testDeliverBillShouldCatchRestCliException() $client->deliverBill($exampleBillId, $exampleBillToken); } - public function testGetLedger() + public function testGetLedgerEntries() { $exampleCurrency = Currency::BTC; $exampleStartDate = '2021-5-10'; $exampleEndDate = '2021-5-31'; $restCliMock = $this->getRestCliMock(); - $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getLedgerBalances.json'); + $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getLedgerEntriesResponse.json'); $params['token'] = 'kQLZ7C9YKPSnMCC4EJwrqRHXuQkLzL1W8DfZCh37DHb'; $params["currency"] = $exampleCurrency; @@ -645,9 +645,9 @@ public function testGetLedger() $result = $client->getLedgerEntries($exampleCurrency, $exampleStartDate, $exampleEndDate); self::assertIsArray($result); - self::assertEquals('EUR', $result[0]->getCurrency()); - self::assertEquals('USD', $result[1]->getCurrency()); - self::assertEquals('BTC', $result[2]->getCurrency()); + self::assertCount(3, $result); + self::assertEquals(-8000000, $result[1]->getAmount()); + self::assertEquals("John Doe", $result[1]->getBuyerFields()->getBuyerName()); self::assertInstanceOf(LedgerEntry::class, $result[0]); } @@ -706,7 +706,7 @@ public function testGetLedgers() { $restCliMock = $this->getRestCliMock(); $params['token'] = 'kQLZ7C9YKPSnMCC4EJwrqRHXuQkLzL1W8DfZCh37DHb'; - $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getLedgers.json'); + $exampleResponse = file_get_contents(__DIR__ . '/jsonResponse/getLedgersResponse.json'); $restCliMock ->expects(self::once()) @@ -720,7 +720,9 @@ public function testGetLedgers() self::assertIsArray($result); - self::assertInstanceOf(Ledger::class, $result[0]); + $ledger = $result[1]; + self::assertInstanceOf(Ledger::class, $ledger); + self::assertEquals(2389.82, $ledger->getBalance()); } public function testGetLedgersShouldCatchBitPayException() diff --git a/test/unit/BitPaySDK/Model/CurrencyTest.php b/test/unit/BitPaySDK/Model/CurrencyTest.php index 6f7da423..df337d04 100644 --- a/test/unit/BitPaySDK/Model/CurrencyTest.php +++ b/test/unit/BitPaySDK/Model/CurrencyTest.php @@ -48,8 +48,6 @@ public function testToArray() self::assertArrayHasKey('minimum', $currencyArray); self::assertArrayHasKey('sanctioned', $currencyArray); self::assertArrayHasKey('decimals', $currencyArray); - self::assertArrayHasKey('payoutFields', $currencyArray); - self::assertArrayHasKey('settlementMinimum', $currencyArray); self::assertEquals('BTC', $currencyArray['code']); self::assertEquals('Symbol', $currencyArray['symbol']); self::assertEquals(1, $currencyArray['precision']); @@ -59,9 +57,8 @@ public function testToArray() self::assertEquals('alts', $currencyArray['alts']); self::assertEquals('minimum', $currencyArray['minimum']); self::assertEquals(true, $currencyArray['sanctioned']); - self::assertEquals('decimals', $currencyArray['decimals']); - self::assertEquals(['test'], $currencyArray['payoutFields']); - self::assertEquals(['test'], $currencyArray['settlementMinimum']); + self::assertEquals(2, $currencyArray['decimals']); + self::assertEquals('chain', $currencyArray['chain']); } public function testGetCode() @@ -130,23 +127,11 @@ public function testGetSanctioned() public function testGetDecimals() { $currency = $this->createClassObject(); - $currency->setDecimals('testDecimals'); - self::assertEquals('testDecimals', $currency->getDecimals()); + $expected = 2; + $currency->setDecimals($expected); + self::assertEquals($expected, $currency->getDecimals()); } - public function testGetPayoutFields() - { - $currency = $this->createClassObject(); - $currency->setPayoutFields(['test']); - self::assertEquals(['test'], $currency->getPayoutFields()); - } - - public function testGetSettlementMinimum() - { - $currency = $this->createClassObject(); - $currency->setSettlementMinimum(['test']); - self::assertEquals(['test'], $currency->getSettlementMinimum()); - } private function createClassObject(): Currency { @@ -164,8 +149,7 @@ private function setSetters(Currency $currency) $currency->setAlts('alts'); $currency->setMinimum('minimum'); $currency->setSanctioned(true); - $currency->setDecimals('decimals'); - $currency->setPayoutFields(['test']); - $currency->setSettlementMinimum(['test']); + $currency->setDecimals(2); + $currency->setChain('chain'); } } diff --git a/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php new file mode 100644 index 00000000..cfd3952a --- /dev/null +++ b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php @@ -0,0 +1,107 @@ +getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerAddress1($expected); + + self::assertEquals($expected, $testedClass->getBuyerAddress1()); + } + + public function testManipulateBuyerAddress2(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerAddress2($expected); + + self::assertEquals($expected, $testedClass->getBuyerAddress2()); + } + + public function testManipulateBuyerCity(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerCity($expected); + + self::assertEquals($expected, $testedClass->getBuyerCity()); + } + + public function testManipulateBuyerCountry(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerCountry($expected); + + self::assertEquals($expected, $testedClass->getBuyerCountry()); + } + + public function testManipulateBuyerEmail(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerEmail($expected); + + self::assertEquals($expected, $testedClass->getBuyerEmail()); + } + + public function testManipulateBuyerName(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerName($expected); + + self::assertEquals($expected, $testedClass->getBuyerName()); + } + + public function testManipulateBuyerNotify(): void + { + $testedClass = $this->getTestedClass(); + $expected = true; + $testedClass->setBuyerNotify($expected); + + self::assertEquals($expected, $testedClass->getBuyerNotify()); + } + + public function testManipulateBuyerPhone(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerPhone($expected); + + self::assertEquals($expected, $testedClass->getBuyerPhone()); + } + + public function testManipulateBuyerState(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerState($expected); + + self::assertEquals($expected, $testedClass->getBuyerState()); + } + + public function testManipulateBuyerZip(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setBuyerZip($expected); + + self::assertEquals($expected, $testedClass->getBuyerZip()); + } + + + private function getTestedClass(): BuyerFields + { + return new BuyerFields(); + } +} diff --git a/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php b/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php index 8460150c..628b87a5 100644 --- a/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/InvoiceTest.php @@ -340,7 +340,7 @@ public function testGetInvoiceTime() public function testGetExpirationTime() { - $expectedExpirationTime = '01:01:01'; + $expectedExpirationTime = 123456; $invoice = $this->createClassObject(); $invoice->setExpirationTime($expectedExpirationTime); @@ -349,7 +349,7 @@ public function testGetExpirationTime() public function testGetCurrentTime() { - $expectedCurrencyTime = '01:01:01'; + $expectedCurrencyTime = 123456; $invoice = $this->createClassObject(); $invoice->setCurrentTime($expectedCurrencyTime); @@ -739,7 +739,7 @@ public function testToArray() self::assertEquals('Test item code', $invoiceArray['itemCode']); self::assertTrue($invoiceArray['physical']); self::assertEquals(['BTC'], $invoiceArray['paymentCurrencies']); - self::assertEquals(1.1, $invoiceArray['acceptanceWindow']); + self::assertEquals(1, $invoiceArray['acceptanceWindow']); self::assertEquals('http://test.com', $invoiceArray['closeURL']); self::assertTrue($invoiceArray['autoRedirect']); self::assertEquals(['Test refund address'], $invoiceArray['refundAddresses']); @@ -748,8 +748,8 @@ public function testToArray() self::assertEquals('pending', $invoiceArray['status']); self::assertEquals('Low fee detected', $invoiceArray['lowFeeDetected']); self::assertEquals(1620734545366, $invoiceArray['invoiceTime']); - self::assertEquals('01:01:01', $invoiceArray['expirationTime']); - self::assertEquals('01:01:01', $invoiceArray['currentTime']); + self::assertEquals(123456, $invoiceArray['expirationTime']); + self::assertEquals(456789, $invoiceArray['currentTime']); self::assertEquals('Exception status', $invoiceArray['exceptionStatus']); self::assertEquals(6, $invoiceArray['targetConfirmations']); self::assertEquals('test@email.com', $invoiceArray['buyerProvidedEmail']); @@ -805,7 +805,7 @@ private function setObjectSetters(Invoice $invoice) $invoice->setItemCode('Test item code'); $invoice->setPhysical(true); $invoice->setPaymentCurrencies(['BTC']); - $invoice->setAcceptanceWindow(1.1); + $invoice->setAcceptanceWindow(1); $invoice->setCloseURL('http://test.com'); $invoice->setAutoRedirect(true); $invoice->setRefundAddresses(['Test refund address']); @@ -814,8 +814,8 @@ private function setObjectSetters(Invoice $invoice) $invoice->setStatus('pending'); $invoice->setLowFeeDetected('Low fee detected'); $invoice->setInvoiceTime(1620734545366); - $invoice->setExpirationTime('01:01:01'); - $invoice->setCurrentTime('01:01:01'); + $invoice->setExpirationTime(123456); + $invoice->setCurrentTime(456789); $invoice->setTransactions([]); $invoice->setExceptionStatus('Exception status'); $invoice->setTargetConfirmations(6); diff --git a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php index d3711f4f..b0f1c330 100644 --- a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php @@ -18,8 +18,8 @@ public function testGetName() $expectedName = 'Test Name'; $buyer = $this->createClassObject(); - $buyer->setName($expectedName); - self::assertEquals($expectedName, $buyer->getName()); + $buyer->setBuyerName($expectedName); + self::assertEquals($expectedName, $buyer->getBuyerName()); } public function testGetAddress1() @@ -27,8 +27,8 @@ public function testGetAddress1() $expectedAddress1 = 'Address 1'; $buyer = $this->createClassObject(); - $buyer->setAddress1($expectedAddress1); - self::assertEquals($expectedAddress1, $buyer->getAddress1()); + $buyer->setBuyerAddress1($expectedAddress1); + self::assertEquals($expectedAddress1, $buyer->getBuyerAddress1()); } public function testGetAddress2() @@ -36,8 +36,8 @@ public function testGetAddress2() $expectedAddress2 = 'Address 2'; $buyer = $this->createClassObject(); - $buyer->setAddress2($expectedAddress2); - self::assertEquals($expectedAddress2, $buyer->getAddress2()); + $buyer->setBuyerAddress2($expectedAddress2); + self::assertEquals($expectedAddress2, $buyer->getBuyerAddress2()); } public function testGetCity() @@ -45,8 +45,8 @@ public function testGetCity() $expectedCity = 'Miami'; $buyer = $this->createClassObject(); - $buyer->setCity($expectedCity); - self::assertEquals($expectedCity, $buyer->getCity()); + $buyer->setBuyerCity($expectedCity); + self::assertEquals($expectedCity, $buyer->getBuyerCity()); } public function testGetState() @@ -54,8 +54,8 @@ public function testGetState() $expectedState = 'AB'; $buyer = $this->createClassObject(); - $buyer->setState($expectedState); - self::assertEquals($expectedState, $buyer->getState()); + $buyer->setBuyerState($expectedState); + self::assertEquals($expectedState, $buyer->getBuyerState()); } public function testGetZip() @@ -63,8 +63,8 @@ public function testGetZip() $expectedZip = '12345'; $buyer = $this->createClassObject(); - $buyer->setZip($expectedZip); - self::assertEquals($expectedZip, $buyer->getZip()); + $buyer->setBuyerZip($expectedZip); + self::assertEquals($expectedZip, $buyer->getBuyerZip()); } public function testGetCountry() @@ -72,8 +72,8 @@ public function testGetCountry() $expectedCountry = 'Canada'; $buyer = $this->createClassObject(); - $buyer->setCountry($expectedCountry); - self::assertEquals($expectedCountry, $buyer->getCountry()); + $buyer->setBuyerCountry($expectedCountry); + self::assertEquals($expectedCountry, $buyer->getBuyerCountry()); } public function testGetEmail() @@ -81,8 +81,8 @@ public function testGetEmail() $expectedEmail = 'test@email.com'; $buyer = $this->createClassObject(); - $buyer->setEmail($expectedEmail); - self::assertEquals($expectedEmail, $buyer->getEmail()); + $buyer->setBuyerEmail($expectedEmail); + self::assertEquals($expectedEmail, $buyer->getBuyerEmail()); } public function testGetPhone() @@ -90,18 +90,18 @@ public function testGetPhone() $expectedPhone = '123456789'; $buyer = $this->createClassObject(); - $buyer->setPhone($expectedPhone); - self::assertEquals($expectedPhone, $buyer->getPhone()); + $buyer->setBuyerPhone($expectedPhone); + self::assertEquals($expectedPhone, $buyer->getBuyerPhone()); } public function testGetNotify() { $buyer = $this->createClassObject(); - $buyer->setNotify(true); - self::assertTrue($buyer->getNotify()); + $buyer->setBuyerNotify(true); + self::assertTrue($buyer->getBuyerNotify()); - $buyer->setNotify(false); - self::assertFalse($buyer->getNotify()); + $buyer->setBuyerNotify(false); + self::assertFalse($buyer->getBuyerNotify()); } public function testToArray() @@ -114,27 +114,27 @@ public function testToArray() self::assertNotNull($buyerArray); self::assertIsArray($buyerArray); - self::assertArrayHasKey('name', $buyerArray); - self::assertArrayHasKey('address1', $buyerArray); - self::assertArrayHasKey('address2', $buyerArray); - self::assertArrayHasKey('city', $buyerArray); - self::assertArrayHasKey('state', $buyerArray); - self::assertArrayHasKey('zip', $buyerArray); - self::assertArrayHasKey('country', $buyerArray); - self::assertArrayHasKey('phone', $buyerArray); - self::assertArrayHasKey('notify', $buyerArray); - self::assertArrayHasKey('email', $buyerArray); - - self::assertEquals('TestName', $buyerArray['name']); - self::assertEquals('Address1', $buyerArray['address1']); - self::assertEquals('Address2', $buyerArray['address2']); - self::assertEquals('Miami', $buyerArray['city']); - self::assertEquals('AB', $buyerArray['state']); - self::assertEquals('12345', $buyerArray['zip']); - self::assertEquals('USA', $buyerArray['country']); - self::assertEquals('123456789', $buyerArray['phone']); - self::assertTrue($buyerArray['notify']); - self::assertEquals('test@email.com', $buyerArray['email']); + self::assertArrayHasKey('buyerName', $buyerArray); + self::assertArrayHasKey('buyerAddress1', $buyerArray); + self::assertArrayHasKey('buyerAddress2', $buyerArray); + self::assertArrayHasKey('buyerCity', $buyerArray); + self::assertArrayHasKey('buyerState', $buyerArray); + self::assertArrayHasKey('buyerZip', $buyerArray); + self::assertArrayHasKey('buyerCountry', $buyerArray); + self::assertArrayHasKey('buyerPhone', $buyerArray); + self::assertArrayHasKey('buyerNotify', $buyerArray); + self::assertArrayHasKey('buyerEmail', $buyerArray); + + self::assertEquals('TestName', $buyerArray['buyerName']); + self::assertEquals('Address1', $buyerArray['buyerAddress1']); + self::assertEquals('Address2', $buyerArray['buyerAddress2']); + self::assertEquals('Miami', $buyerArray['buyerCity']); + self::assertEquals('AB', $buyerArray['buyerState']); + self::assertEquals('12345', $buyerArray['buyerZip']); + self::assertEquals('USA', $buyerArray['buyerCountry']); + self::assertEquals('123456789', $buyerArray['buyerPhone']); + self::assertTrue($buyerArray['buyerNotify']); + self::assertEquals('test@email.com', $buyerArray['buyerEmail']); } private function createClassObject(): Buyer @@ -144,15 +144,15 @@ private function createClassObject(): Buyer private function setSetters(Buyer $buyer) { - $buyer->setName('TestName'); - $buyer->setAddress1('Address1'); - $buyer->setAddress2('Address2'); - $buyer->setCity('Miami'); - $buyer->setState('AB'); - $buyer->setZip('12345'); - $buyer->setCountry('USA'); - $buyer->setPhone('123456789'); - $buyer->setNotify(true); - $buyer->setEmail('test@email.com'); + $buyer->setBuyerName('TestName'); + $buyer->setBuyerAddress1('Address1'); + $buyer->setBuyerAddress2('Address2'); + $buyer->setBuyerCity('Miami'); + $buyer->setBuyerState('AB'); + $buyer->setBuyerZip('12345'); + $buyer->setBuyerCountry('USA'); + $buyer->setBuyerPhone('123456789'); + $buyer->setBuyerNotify(true); + $buyer->setBuyerEmail('test@email.com'); } } \ No newline at end of file diff --git a/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php b/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php index 4d3768e7..bcfa297c 100644 --- a/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php @@ -34,7 +34,7 @@ public function testGetAmount() public function testGetCode() { - $expectedCode = 'abc123'; + $expectedCode = 1324; $ledgerEntry = $this->createClassObject(); $ledgerEntry->setCode($expectedCode); @@ -175,7 +175,7 @@ public function testToArray() self::assertEquals('TestType', $ledgerEntryArray['type']); self::assertEquals('1', $ledgerEntryArray['amount']); - self::assertEquals('abc123', $ledgerEntryArray['code']); + self::assertEquals(111, $ledgerEntryArray['code']); self::assertEquals('2020-01-01 18:10:10', $ledgerEntryArray['timestamp']); self::assertEquals('BTC', $ledgerEntryArray['currency']); self::assertEquals('TxType', $ledgerEntryArray['txType']); @@ -198,7 +198,7 @@ private function setSetters(LedgerEntry $ledgerEntry) { $ledgerEntry->setType('TestType'); $ledgerEntry->setAmount('1'); - $ledgerEntry->setCode('abc123'); + $ledgerEntry->setCode(111); $ledgerEntry->setTimestamp('2020-01-01 18:10:10'); $ledgerEntry->setCurrency('BTC'); $ledgerEntry->setTxType('TxType'); diff --git a/test/unit/BitPaySDK/jsonResponse/getLedgers.json b/test/unit/BitPaySDK/jsonResponse/getLedgerEntriesResponse.json similarity index 100% rename from test/unit/BitPaySDK/jsonResponse/getLedgers.json rename to test/unit/BitPaySDK/jsonResponse/getLedgerEntriesResponse.json diff --git a/test/unit/BitPaySDK/jsonResponse/getLedgerBalances.json b/test/unit/BitPaySDK/jsonResponse/getLedgersResponse.json similarity index 100% rename from test/unit/BitPaySDK/jsonResponse/getLedgerBalances.json rename to test/unit/BitPaySDK/jsonResponse/getLedgersResponse.json From fab422be081e503f4e5bc2f94cc1644b8035048d Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Mon, 11 Dec 2023 13:47:18 +0100 Subject: [PATCH 2/9] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Invoice/Invoice.php | 30 +- .../Model/Invoice/InvoiceWebhook.php | 6 +- src/BitPaySDK/Model/Invoice/RefundWebhook.php | 6 +- test/unit/BitPaySDK/Model/CurrencyTest.php | 8 + .../Model/Invoice/BuyerFieldsTest.php | 1 - .../Model/Invoice/InvoiceWebhookTest.php | 145 +++++++++ .../unit/BitPaySDK/Model/Ledger/BuyerTest.php | 24 +- .../Model/Payout/PayoutWebhookTest.php | 160 ++++++++++ .../Model/Payout/RecipientWebhookTest.php | 61 ++++ .../BitPaySDK/Model/Wallet/WalletTest.php | 287 ++++++++++-------- 10 files changed, 564 insertions(+), 164 deletions(-) create mode 100644 test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php create mode 100644 test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php create mode 100644 test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 6f4819f6..4c223fe7 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -78,9 +78,9 @@ class Invoice protected bool $extendedNotifications = false; protected ?bool $isCancelled = null; protected ?string $transactionCurrency = null; - protected ?int $underpaidAmount = null; - protected ?int $overpaidAmount = null; - protected ?int $amountPaid = null; + protected ?float $underpaidAmount = null; + protected ?float $overpaidAmount = null; + protected ?float $amountPaid = null; protected ?string $displayAmountPaid = null; protected ?array $exchangeRates = null; protected ?bool $bitpayIdRequired = null; @@ -1455,9 +1455,9 @@ public function setPaymentCodes(?array $paymentCodes) * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @return int|null + * @return float|null */ - public function getUnderpaidAmount(): ?int + public function getUnderpaidAmount(): ?float { return $this->underpaidAmount; } @@ -1470,9 +1470,9 @@ public function getUnderpaidAmount(): ?int * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @param int $underpaidAmount the underpaid amount + * @param float|null $underpaidAmount the underpaid amount */ - public function setUnderpaidAmount(int $underpaidAmount): void + public function setUnderpaidAmount(?float $underpaidAmount): void { $this->underpaidAmount = $underpaidAmount; } @@ -1485,9 +1485,9 @@ public function setUnderpaidAmount(int $underpaidAmount): void * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @return int|null + * @return float|null */ - public function getOverpaidAmount(): ?int + public function getOverpaidAmount(): ?float { return $this->overpaidAmount; } @@ -1500,9 +1500,9 @@ public function getOverpaidAmount(): ?int * It equals to the absolute difference between amountPaid * and paymentTotals for the corresponding transactionCurrency used. * - * @param int $overpaidAmount the overpaid amount + * @param float|null $overpaidAmount the overpaid amount */ - public function setOverpaidAmount(int $overpaidAmount): void + public function setOverpaidAmount(?float $overpaidAmount): void { $this->overpaidAmount = $overpaidAmount; } @@ -1714,9 +1714,9 @@ public function setTransactionCurrency(string $transactionCurrency): void * The total amount paid to the invoice in terms of the invoice transactionCurrency indicated * in the smallest possible unit for the corresponding transactionCurrency (e.g satoshis for BTC and BCH) * - * @return int|null + * @return float|null */ - public function getAmountPaid(): ?int + public function getAmountPaid(): ?float { return $this->amountPaid; } @@ -1727,9 +1727,9 @@ public function getAmountPaid(): ?int * The total amount paid to the invoice in terms of the invoice transactionCurrency indicated * in the smallest possible unit for the corresponding transactionCurrency (e.g satoshis for BTC and BCH) * - * @param int $amountPaid The total amount paid to the invoice + * @param float|null $amountPaid The total amount paid to the invoice */ - public function setAmountPaid(int $amountPaid): void + public function setAmountPaid(?float $amountPaid): void { $this->amountPaid = $amountPaid; } diff --git a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php index 9f601cb1..57fcb5c7 100644 --- a/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php +++ b/src/BitPaySDK/Model/Invoice/InvoiceWebhook.php @@ -29,7 +29,7 @@ class InvoiceWebhook protected ?array $paymentSubtotals; protected ?array $paymentTotals; protected ?array $exchangeRates; - protected ?int $amountPaid; + protected ?float $amountPaid; protected ?string $orderId; protected ?string $transactionCurrency; @@ -163,12 +163,12 @@ public function setExchangeRates(?array $exchangeRates): void $this->exchangeRates = $exchangeRates; } - public function getAmountPaid(): ?int + public function getAmountPaid(): ?float { return $this->amountPaid; } - public function setAmountPaid(?int $amountPaid): void + public function setAmountPaid(?float $amountPaid): void { $this->amountPaid = $amountPaid; } diff --git a/src/BitPaySDK/Model/Invoice/RefundWebhook.php b/src/BitPaySDK/Model/Invoice/RefundWebhook.php index 8299ca3d..ac2187ce 100644 --- a/src/BitPaySDK/Model/Invoice/RefundWebhook.php +++ b/src/BitPaySDK/Model/Invoice/RefundWebhook.php @@ -22,7 +22,7 @@ class RefundWebhook protected ?string $invoice = null; protected ?string $supportRequest = null; protected ?string $status = null; - protected ?int $amount = null; + protected ?float $amount = null; protected ?string $currency = null; protected ?string $lastRefundNotification = null; protected ?float $refundFee = null; @@ -70,12 +70,12 @@ public function setStatus(?string $status): void $this->status = $status; } - public function getAmount(): ?int + public function getAmount(): ?float { return $this->amount; } - public function setAmount(?int $amount): void + public function setAmount(?float $amount): void { $this->amount = $amount; } diff --git a/test/unit/BitPaySDK/Model/CurrencyTest.php b/test/unit/BitPaySDK/Model/CurrencyTest.php index df337d04..2f553cdc 100644 --- a/test/unit/BitPaySDK/Model/CurrencyTest.php +++ b/test/unit/BitPaySDK/Model/CurrencyTest.php @@ -132,6 +132,14 @@ public function testGetDecimals() self::assertEquals($expected, $currency->getDecimals()); } + public function testModifyChain(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setChain($expected); + + self::assertEquals($expected, $testedClass->getChain()); + } private function createClassObject(): Currency { diff --git a/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php index cfd3952a..6c21c7ec 100644 --- a/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/BuyerFieldsTest.php @@ -99,7 +99,6 @@ public function testManipulateBuyerZip(): void self::assertEquals($expected, $testedClass->getBuyerZip()); } - private function getTestedClass(): BuyerFields { return new BuyerFields(); diff --git a/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php new file mode 100644 index 00000000..e7f8ef2e --- /dev/null +++ b/test/unit/BitPaySDK/Model/Invoice/InvoiceWebhookTest.php @@ -0,0 +1,145 @@ +getTestedClass(); + $expected = 12.23; + $testedClass->setAmountPaid($expected); + self::assertEquals($expected, $testedClass->getamountPaid()); + } + + public function testManipulateBuyerFields(): void + { + $testedClass = $this->getTestedClass(); + $expected = new BuyerFields(); + $testedClass->setBuyerFields($expected); + self::assertEquals($expected, $testedClass->getbuyerFields()); + } + + public function testManipulateCurrency(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setCurrency($expected); + self::assertEquals($expected, $testedClass->getCurrency()); + } + + public function testManipulateCurrencyTime(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setCurrencyTime($expected); + self::assertEquals($expected, $testedClass->getCurrencyTime()); + } + + public function testManipulateExceptionStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setExceptionStatus($expected); + self::assertEquals($expected, $testedClass->getExceptionStatus()); + } + + public function testManipulateExchangeRates(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setExchangeRates($expected); + self::assertEquals($expected, $testedClass->getExchangeRates()); + } + + public function testManipulateId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setid($expected); + self::assertEquals($expected, $testedClass->getId()); + } + + public function testManipulateInvoiceTime(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setInvoiceTime($expected); + self::assertEquals($expected, $testedClass->getInvoiceTime()); + } + + public function testManipulateOrderId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setOrderId($expected); + self::assertEquals($expected, $testedClass->getOrderId()); + } + + public function testManipulate_paymentSubtotals(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setPaymentSubtotals($expected); + self::assertEquals($expected, $testedClass->getPaymentSubtotals()); + } + + public function testManipulatePaymentTotals(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setPaymentTotals($expected); + self::assertEquals($expected, $testedClass->getPaymentTotals()); + } + + public function testManipulatePosData(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setPosData($expected); + self::assertEquals($expected, $testedClass->getPosData()); + } + + public function testManipulatePrice(): void + { + $testedClass = $this->getTestedClass(); + $expected = 123.78; + $testedClass->setPrice($expected); + self::assertEquals($expected, $testedClass->getPrice()); + } + + public function testManipulateStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setStatus($expected); + self::assertEquals($expected, $testedClass->getStatus()); + } + + public function testManipulateTransactionCurrency(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setTransactionCurrency($expected); + self::assertEquals($expected, $testedClass->getTransactionCurrency()); + } + + public function testManipulateUrl(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setUrl($expected); + self::assertEquals($expected, $testedClass->getUrl()); + } + + private function getTestedClass(): InvoiceWebhook + { + return new InvoiceWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php index b0f1c330..d34a7334 100644 --- a/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/BuyerTest.php @@ -7,13 +7,13 @@ class BuyerTest extends TestCase { - public function testInstanceOf() + public function testInstanceOf(): void { $buyer = $this->createClassObject(); self::assertInstanceOf(Buyer::class, $buyer); } - public function testGetName() + public function testModifyBuyerName(): void { $expectedName = 'Test Name'; @@ -22,7 +22,7 @@ public function testGetName() self::assertEquals($expectedName, $buyer->getBuyerName()); } - public function testGetAddress1() + public function testModifyBuyerAddress1(): void { $expectedAddress1 = 'Address 1'; @@ -31,7 +31,7 @@ public function testGetAddress1() self::assertEquals($expectedAddress1, $buyer->getBuyerAddress1()); } - public function testGetAddress2() + public function testModifyBuyerAddress2(): void { $expectedAddress2 = 'Address 2'; @@ -40,7 +40,7 @@ public function testGetAddress2() self::assertEquals($expectedAddress2, $buyer->getBuyerAddress2()); } - public function testGetCity() + public function testModifyBuyerCity(): void { $expectedCity = 'Miami'; @@ -49,7 +49,7 @@ public function testGetCity() self::assertEquals($expectedCity, $buyer->getBuyerCity()); } - public function testGetState() + public function testModifyBuyerState(): void { $expectedState = 'AB'; @@ -58,7 +58,7 @@ public function testGetState() self::assertEquals($expectedState, $buyer->getBuyerState()); } - public function testGetZip() + public function testModifyBuyerZip(): void { $expectedZip = '12345'; @@ -67,7 +67,7 @@ public function testGetZip() self::assertEquals($expectedZip, $buyer->getBuyerZip()); } - public function testGetCountry() + public function testModifyBuyerCountry(): void { $expectedCountry = 'Canada'; @@ -76,7 +76,7 @@ public function testGetCountry() self::assertEquals($expectedCountry, $buyer->getBuyerCountry()); } - public function testGetEmail() + public function testModifyBuyerEmail(): void { $expectedEmail = 'test@email.com'; @@ -85,7 +85,7 @@ public function testGetEmail() self::assertEquals($expectedEmail, $buyer->getBuyerEmail()); } - public function testGetPhone() + public function testModifyBuyerPhone(): void { $expectedPhone = '123456789'; @@ -94,7 +94,7 @@ public function testGetPhone() self::assertEquals($expectedPhone, $buyer->getBuyerPhone()); } - public function testGetNotify() + public function testModifyBuyerNotify(): void { $buyer = $this->createClassObject(); $buyer->setBuyerNotify(true); @@ -104,7 +104,7 @@ public function testGetNotify() self::assertFalse($buyer->getBuyerNotify()); } - public function testToArray() + public function testToArray(): void { $buyer = $this->createClassObject(); $this->setSetters($buyer); diff --git a/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php new file mode 100644 index 00000000..a1ba47fb --- /dev/null +++ b/test/unit/BitPaySDK/Model/Payout/PayoutWebhookTest.php @@ -0,0 +1,160 @@ +getTestedClass(); + $expected = 'someValue'; + $testedClass->setCurrency($expected); + + self::assertEquals($expected, $testedClass->getCurrency()); + } + + public function testModifyEffectiveDate(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setEffectiveDate($expected); + + self::assertEquals($expected, $testedClass->getEffectiveDate()); + } + + public function testModifyEmail(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setEmail($expected); + + self::assertEquals($expected, $testedClass->getEmail()); + } + + public function testModifyExchangeRates(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setExchangeRates($expected); + + self::assertEquals($expected, $testedClass->getExchangeRates()); + } + + public function testModifyId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setId($expected); + + self::assertEquals($expected, $testedClass->getId()); + } + + public function testModifyLabel(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setLabel($expected); + + self::assertEquals($expected, $testedClass->getLabel()); + } + + public function testModifyLedgerCurrency(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setLedgerCurrency($expected); + + self::assertEquals($expected, $testedClass->getLedgerCurrency()); + } + + public function testModifyNotificationEmail(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setNotificationEmail($expected); + + self::assertEquals($expected, $testedClass->getNotificationEmail()); + } + + public function testModifyNotificationURL(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setNotificationURL($expected); + + self::assertEquals($expected, $testedClass->getNotificationURL()); + } + + public function testModifyPrice(): void + { + $testedClass = $this->getTestedClass(); + $expected = 12.67; + $testedClass->setprice($expected); + + self::assertEquals($expected, $testedClass->getPrice()); + } + + public function testModifyRecipientId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setRecipientId($expected); + + self::assertEquals($expected, $testedClass->getRecipientId()); + } + + public function testModifyReference(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setReference($expected); + + self::assertEquals($expected, $testedClass->getReference()); + } + + public function testModifyRequestDate(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setRequestDate($expected); + + self::assertEquals($expected, $testedClass->getRequestDate()); + } + + public function testModifyShopperId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setShopperId($expected); + + self::assertEquals($expected, $testedClass->getShopperId()); + } + + public function testModifyStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setStatus($expected); + + self::assertEquals($expected, $testedClass->getStatus()); + } + + public function testModifyTransactions(): void + { + $testedClass = $this->getTestedClass(); + $expected = []; + $testedClass->setTransactions($expected); + + self::assertEquals($expected, $testedClass->getTransactions()); + } + + private function getTestedClass(): PayoutWebhook + { + return new PayoutWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php b/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php new file mode 100644 index 00000000..3f13b8a1 --- /dev/null +++ b/test/unit/BitPaySDK/Model/Payout/RecipientWebhookTest.php @@ -0,0 +1,61 @@ +getTestedClass(); + $expected = 'someValue'; + $testedClass->setEmail($expected); + + self::assertEquals($expected, $testedClass->getEmail()); + } + + public function testModifyId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setId($expected); + + self::assertEquals($expected, $testedClass->getId()); + } + + public function testModifyLabel(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setLabel($expected); + + self::assertEquals($expected, $testedClass->getLabel()); + } + + public function testModifyShopperId(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setShopperId($expected); + + self::assertEquals($expected, $testedClass->getShopperId()); + } + + public function testModifyStatus(): void + { + $testedClass = $this->getTestedClass(); + $expected = 'someValue'; + $testedClass->setstatus($expected); + + self::assertEquals($expected, $testedClass->getStatus()); + } + + private function getTestedClass(): RecipientWebhook + { + return new RecipientWebhook(); + } +} diff --git a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php index 066d030d..57fbda65 100644 --- a/test/unit/BitPaySDK/Model/Wallet/WalletTest.php +++ b/test/unit/BitPaySDK/Model/Wallet/WalletTest.php @@ -9,134 +9,161 @@ class WalletTest extends TestCase { - public function testInstanceOf() - { - $wallet = $this->createClassObject(); - self::assertInstanceOf(Wallet::class, $wallet); - } - - public function testGetKey() - { - $expectedKey = 'abcd123'; - - $wallet = $this->createClassObject(); - $wallet->setKey($expectedKey); - self::assertEquals($expectedKey, $wallet->getKey()); - } - - public function testGetDisplayName() - { - $expectedDisplayName = 'My Wallet'; - - $wallet = $this->createClassObject(); - $wallet->setDisplayName($expectedDisplayName); - self::assertEquals($expectedDisplayName, $wallet->getDisplayName()); - } - - public function testGetAvatar() - { - $expectedAvatar = 'image.png'; - - $wallet = $this->createClassObject(); - $wallet->setAvatar($expectedAvatar); - self::assertEquals($expectedAvatar, $wallet->getAvatar()); - } - - public function testGetPayPro() - { - $wallet = $this->createClassObject(); - $wallet->setPayPro(true); - self::assertTrue($wallet->getPayPro()); - } - - public function testGetCurrencies() - { - $currencyQr = new CurrencyQr; - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - - $expectedCurrencies = new Currencies(); - $expectedCurrencies->setCode('BTH'); - $expectedCurrencies->setP2p(true); - $expectedCurrencies->setDappBrowser(true); - $expectedCurrencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - $expectedCurrencies->setPayPro(true); - $expectedCurrencies->setQr($currencyQr); - $expectedCurrencies->setWithdrawalFee('1.23'); - $expectedCurrencies->setWalletConnect(true); - - $wallet = $this->createClassObject(); - $wallet->setCurrencies($expectedCurrencies); - self::assertEquals($expectedCurrencies, $wallet->getCurrencies()); - } - - public function testGetImage() - { - $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; - - $wallet = $this->createClassObject(); - $wallet->setImage($expectedImage); - self::assertEquals($expectedImage, $wallet->getImage()); - } - - public function testToArray() - { - $wallet = $this->createClassObject(); - $this->objectSetters($wallet); - $walletArray = $wallet->toArray(); - - self::assertNotNull($walletArray); - self::assertIsArray($walletArray); - - self::assertArrayHasKey('key', $walletArray); - self::assertArrayHasKey('displayName', $walletArray); - self::assertArrayHasKey('avatar', $walletArray); - self::assertArrayHasKey('paypro', $walletArray); - self::assertArrayHasKey('currencies', $walletArray); - self::assertArrayHasKey('image', $walletArray); - - self::assertEquals('abcd123', $walletArray['key']); - self::assertEquals('My Wallet', $walletArray['displayName']); - self::assertEquals('image.png', $walletArray['avatar']); - self::assertTrue($walletArray['paypro']); - self::assertEquals('BTH', $walletArray['currencies']['code']); - self::assertTrue($walletArray['currencies']['p2p']); - self::assertTrue($walletArray['currencies']['dappBrowser']); - self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['currencies']['image']); - self::assertTrue($walletArray['currencies']['paypro']); - self::assertEquals('BIP21', $walletArray['currencies']['qr']['type']); - self::assertFalse($walletArray['currencies']['qr']['collapsed']); - self::assertEquals('1.23', $walletArray['currencies']['withdrawalFee']); - self::assertTrue($walletArray['currencies']['walletConnect']); - self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['image']); - } - - private function createClassObject(): Wallet - { - return new Wallet(); - } - - private function objectSetters(Wallet $wallet): void - { - $currencyQr = new CurrencyQr; - $currencyQr->setType('BIP21'); - $currencyQr->setCollapsed(false); - - $currencies = new Currencies(); - $currencies->setCode('BTH'); - $currencies->setP2p(true); - $currencies->setDappBrowser(true); - $currencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - $currencies->setPayPro(true); - $currencies->setQr($currencyQr); - $currencies->setWithdrawalFee('1.23'); - $currencies->setWalletConnect(true); - - $wallet->setKey('abcd123'); - $wallet->setDisplayName('My Wallet'); - $wallet->setAvatar('image.png'); - $wallet->setPayPro(true); - $wallet->setCurrencies($currencies); - $wallet->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); - } + public function testInstanceOf() + { + $wallet = $this->createClassObject(); + self::assertInstanceOf(Wallet::class, $wallet); + } + + public function testGetKey() + { + $expectedKey = 'abcd123'; + + $wallet = $this->createClassObject(); + $wallet->setKey($expectedKey); + self::assertEquals($expectedKey, $wallet->getKey()); + } + + public function testGetDisplayName() + { + $expectedDisplayName = 'My Wallet'; + + $wallet = $this->createClassObject(); + $wallet->setDisplayName($expectedDisplayName); + self::assertEquals($expectedDisplayName, $wallet->getDisplayName()); + } + + public function testGetAvatar() + { + $expectedAvatar = 'image.png'; + + $wallet = $this->createClassObject(); + $wallet->setAvatar($expectedAvatar); + self::assertEquals($expectedAvatar, $wallet->getAvatar()); + } + + public function testGetPayPro() + { + $wallet = $this->createClassObject(); + $wallet->setPayPro(true); + self::assertTrue($wallet->getPayPro()); + } + + public function testGetCurrencies() + { + $currencyQr = new CurrencyQr; + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + + $expectedCurrencies = new Currencies(); + $expectedCurrencies->setCode('BTH'); + $expectedCurrencies->setP2p(true); + $expectedCurrencies->setDappBrowser(true); + $expectedCurrencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + $expectedCurrencies->setPayPro(true); + $expectedCurrencies->setQr($currencyQr); + $expectedCurrencies->setWithdrawalFee('1.23'); + $expectedCurrencies->setWalletConnect(true); + + $wallet = $this->createClassObject(); + $wallet->setCurrencies($expectedCurrencies); + self::assertEquals($expectedCurrencies, $wallet->getCurrencies()); + } + + public function testGetImage() + { + $expectedImage = 'https://bitpay.com/api/images/logo-6fa5404d.svg'; + + $wallet = $this->createClassObject(); + $wallet->setImage($expectedImage); + self::assertEquals($expectedImage, $wallet->getImage()); + } + + public function modifyUniCode(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setUniCode($expected); + + self::assertEquals($expected, $testedClass->getUniCode()); + } + + public function modifyOffChainMode(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setOffChainMode($expected); + + self::assertEquals($expected, $testedClass->getOffChainMode()); + } + + public function modifyInvoiceDefault(): void + { + $testedClass = $this->createClassObject(); + $expected = 'someValue'; + $testedClass->setInvoiceDefault($expected); + + self::assertEquals($expected, $testedClass->getInvoiceDefault()); + } + + public function testToArray() + { + $wallet = $this->createClassObject(); + $this->objectSetters($wallet); + $walletArray = $wallet->toArray(); + + self::assertNotNull($walletArray); + self::assertIsArray($walletArray); + + self::assertArrayHasKey('key', $walletArray); + self::assertArrayHasKey('displayName', $walletArray); + self::assertArrayHasKey('avatar', $walletArray); + self::assertArrayHasKey('paypro', $walletArray); + self::assertArrayHasKey('currencies', $walletArray); + self::assertArrayHasKey('image', $walletArray); + + self::assertEquals('abcd123', $walletArray['key']); + self::assertEquals('My Wallet', $walletArray['displayName']); + self::assertEquals('image.png', $walletArray['avatar']); + self::assertTrue($walletArray['paypro']); + self::assertEquals('BTH', $walletArray['currencies']['code']); + self::assertTrue($walletArray['currencies']['p2p']); + self::assertTrue($walletArray['currencies']['dappBrowser']); + self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['currencies']['image']); + self::assertTrue($walletArray['currencies']['paypro']); + self::assertEquals('BIP21', $walletArray['currencies']['qr']['type']); + self::assertFalse($walletArray['currencies']['qr']['collapsed']); + self::assertEquals('1.23', $walletArray['currencies']['withdrawalFee']); + self::assertTrue($walletArray['currencies']['walletConnect']); + self::assertEquals('https://bitpay.com/api/images/logo-6fa5404d.svg', $walletArray['image']); + } + + private function createClassObject(): Wallet + { + return new Wallet(); + } + + private function objectSetters(Wallet $wallet): void + { + $currencyQr = new CurrencyQr; + $currencyQr->setType('BIP21'); + $currencyQr->setCollapsed(false); + + $currencies = new Currencies(); + $currencies->setCode('BTH'); + $currencies->setP2p(true); + $currencies->setDappBrowser(true); + $currencies->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + $currencies->setPayPro(true); + $currencies->setQr($currencyQr); + $currencies->setWithdrawalFee('1.23'); + $currencies->setWalletConnect(true); + + $wallet->setKey('abcd123'); + $wallet->setDisplayName('My Wallet'); + $wallet->setAvatar('image.png'); + $wallet->setPayPro(true); + $wallet->setCurrencies($currencies); + $wallet->setImage('https://bitpay.com/api/images/logo-6fa5404d.svg'); + } } \ No newline at end of file From 6b2be56e1a6674418f326f7fff316ee986ed4e44 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Mon, 11 Dec 2023 14:12:05 +0100 Subject: [PATCH 3/9] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Invoice/Invoice.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index 4c223fe7..c95eaf34 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -63,7 +63,7 @@ class Invoice protected ?int $expirationTime = null; protected ?int $currentTime = null; protected ?array $transactions = null; - protected bool|string|null $exceptionStatus = null; + protected string|null $exceptionStatus = null; protected ?int $targetConfirmations = null; protected ?bool $refundAddressRequestPending = null; protected ?string $buyerProvidedEmail = null; @@ -1098,13 +1098,13 @@ public function setTransactions(array $transactions): void * * Initially a boolean false, this parameter will indicate if the purchaser sent too much ("paidOver") * or not enough funds ("paidPartial") in the transaction to pay the BitPay invoice. Possible values are: - * false: default value (boolean) unless an exception is triggered. + * "false": default value unless an exception is triggered. * "paidPartial": (string) if the consumer did not send enough funds when paying the invoice. * "paidOver": (string) if the consumer sent to much funds when paying the invoice. * - * @return bool|string|null the exception status + * @return string|null the exception status */ - public function getExceptionStatus(): bool|string|null + public function getExceptionStatus(): string|null { return $this->exceptionStatus; } @@ -1114,13 +1114,13 @@ public function getExceptionStatus(): bool|string|null * * Initially a boolean false, this parameter will indicate if the purchaser sent too much ("paidOver") * or not enough funds ("paidPartial") in the transaction to pay the BitPay invoice. Possible values are: - * false: default value (boolean) unless an exception is triggered. + * "false": default value (boolean) unless an exception is triggered. * "paidPartial": (string) if the consumer did not send enough funds when paying the invoice. * "paidOver": (string) if the consumer sent to much funds when paying the invoice. * - * @param boolean $exceptionStatus this parameter will indicate if the purchaser sent too much or not enough funds + * @param string|null $exceptionStatus this parameter will indicate if the purchaser sent too much or not enough funds */ - public function setExceptionStatus(bool|string|null $exceptionStatus): void + public function setExceptionStatus(string|null $exceptionStatus): void { $this->exceptionStatus = $exceptionStatus; } From ae3eb4e5486d9c8914deeac23824447eeab3a6c8 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Mon, 11 Dec 2023 14:13:38 +0100 Subject: [PATCH 4/9] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Invoice/Invoice.php | 2 +- src/BitPaySDK/Model/Payout/RecipientWebhook.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/BitPaySDK/Model/Invoice/Invoice.php b/src/BitPaySDK/Model/Invoice/Invoice.php index c95eaf34..7903b563 100644 --- a/src/BitPaySDK/Model/Invoice/Invoice.php +++ b/src/BitPaySDK/Model/Invoice/Invoice.php @@ -1118,7 +1118,7 @@ public function getExceptionStatus(): string|null * "paidPartial": (string) if the consumer did not send enough funds when paying the invoice. * "paidOver": (string) if the consumer sent to much funds when paying the invoice. * - * @param string|null $exceptionStatus this parameter will indicate if the purchaser sent too much or not enough funds + * @param string|null $exceptionStatus parameter will indicate if the purchaser sent too much or not enough funds */ public function setExceptionStatus(string|null $exceptionStatus): void { diff --git a/src/BitPaySDK/Model/Payout/RecipientWebhook.php b/src/BitPaySDK/Model/Payout/RecipientWebhook.php index 98920a3f..287ebfd7 100644 --- a/src/BitPaySDK/Model/Payout/RecipientWebhook.php +++ b/src/BitPaySDK/Model/Payout/RecipientWebhook.php @@ -72,9 +72,4 @@ public function setShopperId(?string $shopperId): void { $this->shopperId = $shopperId; } - - - - - } From 7a9c359e1af422edccd5dedaa35c0abfa4b300eb Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Mon, 11 Dec 2023 15:54:22 +0100 Subject: [PATCH 5/9] SP-735 Type Review: PHP --- src/BitPaySDK/Model/Invoice/MinerFeesItem.php | 12 ++++++------ .../BitPaySDK/Model/Invoice/MinerFeesItemTest.php | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BitPaySDK/Model/Invoice/MinerFeesItem.php b/src/BitPaySDK/Model/Invoice/MinerFeesItem.php index 2c187d31..b313aa44 100644 --- a/src/BitPaySDK/Model/Invoice/MinerFeesItem.php +++ b/src/BitPaySDK/Model/Invoice/MinerFeesItem.php @@ -18,30 +18,30 @@ */ class MinerFeesItem { - protected ?float $satoshisPerByte = null; - protected ?float $totalFee = null; + protected ?int $satoshisPerByte = null; + protected ?int $totalFee = null; protected ?float $fiatAmount = null; public function __construct() { } - public function getSatoshisPerByte(): ?float + public function getSatoshisPerByte(): ?int { return $this->satoshisPerByte; } - public function setSatoshisPerByte(float $satoshisPerByte): void + public function setSatoshisPerByte(int $satoshisPerByte): void { $this->satoshisPerByte = $satoshisPerByte; } - public function getTotalFee(): ?float + public function getTotalFee(): ?int { return $this->totalFee; } - public function setTotalFee(float $totalFee): void + public function setTotalFee(int $totalFee): void { $this->totalFee = $totalFee; } diff --git a/test/unit/BitPaySDK/Model/Invoice/MinerFeesItemTest.php b/test/unit/BitPaySDK/Model/Invoice/MinerFeesItemTest.php index eca59875..a5d35746 100644 --- a/test/unit/BitPaySDK/Model/Invoice/MinerFeesItemTest.php +++ b/test/unit/BitPaySDK/Model/Invoice/MinerFeesItemTest.php @@ -15,7 +15,7 @@ public function testInstanceOf() public function testGetSatoshisPerByte() { - $expectedSatoshiPerByte = 1.1; + $expectedSatoshiPerByte = 1; $minerFeesItem = $this->createClassObject(); $minerFeesItem->setSatoshisPerByte($expectedSatoshiPerByte); @@ -24,7 +24,7 @@ public function testGetSatoshisPerByte() public function testGetTotalFee() { - $expectedTotalFee = 1.1; + $expectedTotalFee = 1; $minerFeesItem = $this->createClassObject(); $minerFeesItem->setTotalFee($expectedTotalFee); @@ -43,8 +43,8 @@ public function testGetFiatAmount() public function testToArray() { $minerFeesItem = $this->createClassObject(); - $minerFeesItem->setSatoshisPerByte(1.1); - $minerFeesItem->setTotalFee(1.1); + $minerFeesItem->setSatoshisPerByte(1); + $minerFeesItem->setTotalFee(1); $minerFeesItem->setFiatAmount(null); $minerFeesItemArray = $minerFeesItem->toArray(); @@ -56,8 +56,8 @@ public function testToArray() self::assertArrayHasKey('totalFee', $minerFeesItemArray); self::assertArrayNotHasKey('fiatAmount', $minerFeesItemArray); - self::assertEquals(1.1, $minerFeesItemArray['satoshisPerByte']); - self::assertEquals(1.1, $minerFeesItemArray['totalFee']); + self::assertEquals(1, $minerFeesItemArray['satoshisPerByte']); + self::assertEquals(1, $minerFeesItemArray['totalFee']); } private function createClassObject(): MinerFeesItem From 6023da3bafc23178044fddf5aebb1310707b0d92 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Thu, 21 Dec 2023 17:54:25 +0100 Subject: [PATCH 6/9] SP-750 Code Examples: PHP --- composer.json | 3 +- composer.lock | 727 +++++++++------------- examples/ClientProvider.php | 23 + examples/General/UseLogger.php | 65 ++ examples/Merchant/BillRequests.php | 74 +++ examples/Merchant/InvoiceRequests.php | 92 +++ examples/Merchant/LedgerRequests.php | 32 + examples/Merchant/RefundRequests.php | 62 ++ examples/Merchant/SettlementRequests.php | 36 ++ examples/Payout/PayoutRequests.php | 61 ++ examples/Payout/RecipientRequests.php | 66 ++ examples/Pos/BillRequests.php | 51 ++ examples/Pos/InvoiceRequests.php | 66 ++ examples/Public/RateRequests.php | 25 + examples/Public/WalletRequests.php | 21 + src/BitPaySDK/Client.php | 7 +- src/BitPaySDK/Client/SettlementClient.php | 9 +- src/BitPaySDK/Model/Currency.php | 76 ++- test/unit/BitPaySDK/ClientTest.php | 20 +- 19 files changed, 1066 insertions(+), 450 deletions(-) create mode 100644 examples/ClientProvider.php create mode 100644 examples/General/UseLogger.php create mode 100644 examples/Merchant/BillRequests.php create mode 100644 examples/Merchant/InvoiceRequests.php create mode 100644 examples/Merchant/LedgerRequests.php create mode 100644 examples/Merchant/RefundRequests.php create mode 100644 examples/Merchant/SettlementRequests.php create mode 100644 examples/Payout/PayoutRequests.php create mode 100644 examples/Payout/RecipientRequests.php create mode 100644 examples/Pos/BillRequests.php create mode 100644 examples/Pos/InvoiceRequests.php create mode 100644 examples/Public/RateRequests.php create mode 100644 examples/Public/WalletRequests.php diff --git a/composer.json b/composer.json index acc652de..3a8c9b27 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ }, "autoload": { "psr-4": { - "BitPaySDK\\": "src/BitPaySDK" + "BitPaySDK\\": "src/BitPaySDK", + "BitPaySDKexamples\\": "examples" } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index db7dcf5f..b2c5e803 100644 --- a/composer.lock +++ b/composer.lock @@ -58,22 +58,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.7.0", + "version": "7.8.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", + "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0", - "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -82,11 +82,11 @@ "psr/http-client-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", + "bamarni/composer-bin-plugin": "^1.8.2", "ext-curl": "*", "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "phpunit/phpunit": "^8.5.36 || ^9.6.15", "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { @@ -164,7 +164,7 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.7.0" + "source": "https://github.com/guzzle/guzzle/tree/7.8.1" }, "funding": [ { @@ -180,28 +180,28 @@ "type": "tidelift" } ], - "time": "2023-05-21T14:04:53+00:00" + "time": "2023-12-03T20:35:24+00:00" }, { "name": "guzzlehttp/promises", - "version": "2.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", - "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", + "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", "shasum": "" }, "require": { "php": "^7.2.5 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.36 || ^9.6.15" }, "type": "library", "extra": { @@ -247,7 +247,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.0" + "source": "https://github.com/guzzle/promises/tree/2.0.2" }, "funding": [ { @@ -263,20 +263,20 @@ "type": "tidelift" } ], - "time": "2023-05-21T13:50:22+00:00" + "time": "2023-12-03T20:19:20+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.5.0", + "version": "2.6.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", + "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", "shasum": "" }, "require": { @@ -290,9 +290,9 @@ "psr/http-message-implementation": "1.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.1", + "bamarni/composer-bin-plugin": "^1.8.2", "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.29 || ^9.5.23" + "phpunit/phpunit": "^8.5.36 || ^9.6.15" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" @@ -363,7 +363,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" + "source": "https://github.com/guzzle/psr7/tree/2.6.2" }, "funding": [ { @@ -379,7 +379,7 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:11:26+00:00" + "time": "2023-12-03T20:05:35+00:00" }, { "name": "netresearch/jsonmapper", @@ -434,16 +434,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -480,9 +480,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -638,25 +638,25 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.0.2", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", - "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { - "php": ">=8.0.2" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -685,7 +685,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" }, "funding": [ { @@ -701,20 +701,20 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:55:41+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -729,7 +729,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -767,7 +767,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" }, "funding": [ { @@ -783,34 +783,32 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/yaml", - "version": "v6.0.19", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "deec3a812a0305a50db8ae689b183f43d915c884" + "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/deec3a812a0305a50db8ae689b183f43d915c884", - "reference": "deec3a812a0305a50db8ae689b183f43d915c884", + "url": "https://api.github.com/repos/symfony/yaml/zipball/4f9237a1bb42455d609e6687d2613dde5b41a587", + "reference": "4f9237a1bb42455d609e6687d2613dde5b41a587", "shasum": "" }, "require": { - "php": ">=8.0.2", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8" }, "conflict": { "symfony/console": "<5.4" }, "require-dev": { - "symfony/console": "^5.4|^6.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "symfony/console": "^5.4|^6.0|^7.0" }, "bin": [ "Resources/bin/yaml-lint" @@ -841,7 +839,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.0.19" + "source": "https://github.com/symfony/yaml/tree/v6.4.0" }, "funding": [ { @@ -857,80 +855,10 @@ "type": "tidelift" } ], - "time": "2023-01-11T11:50:03+00:00" + "time": "2023-11-06T11:00:25+00:00" } ], "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", - "shasum": "" - }, - "require": { - "php": "^8.1" - }, - "require-dev": { - "doctrine/coding-standard": "^11", - "ext-pdo": "*", - "ext-phar": "*", - "phpbench/phpbench": "^1.2", - "phpstan/phpstan": "^1.9.4", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.27", - "vimeo/psalm": "^5.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "https://ocramius.github.io/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", - "keywords": [ - "constructor", - "instantiate" - ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/2.0.0" - }, - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", - "type": "tidelift" - } - ], - "time": "2022-12-30T00:23:10+00:00" - }, { "name": "myclabs/deep-copy", "version": "1.11.1", @@ -992,16 +920,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v4.18.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "shasum": "" }, "require": { @@ -1042,9 +970,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-12-10T21:03:43+00:00" }, { "name": "phar-io/manifest", @@ -1159,35 +1087,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "10.1.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "78c3b7625965c2513ee96569a4dbb62601784145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/b0a88255cb70d52653d80c890bd7f38740ea50d1", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", + "reference": "78c3b7625965c2513ee96569a4dbb62601784145", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", - "php": ">=7.3", - "phpunit/php-file-iterator": "^3.0.3", - "phpunit/php-text-template": "^2.0.2", - "sebastian/code-unit-reverse-lookup": "^2.0.2", - "sebastian/complexity": "^2.0", - "sebastian/environment": "^5.1.2", - "sebastian/lines-of-code": "^1.0.3", - "sebastian/version": "^3.0.1", + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-text-template": "^3.0", + "sebastian/code-unit-reverse-lookup": "^3.0", + "sebastian/complexity": "^3.0", + "sebastian/environment": "^6.0", + "sebastian/lines-of-code": "^2.0", + "sebastian/version": "^4.0", "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.1" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -1196,7 +1124,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-main": "10.1-dev" } }, "autoload": { @@ -1225,7 +1153,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.27" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" }, "funding": [ { @@ -1233,32 +1161,32 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-12-21T15:38:30+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.6", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", - "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1285,7 +1213,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" }, "funding": [ { @@ -1293,28 +1222,28 @@ "type": "github" } ], - "time": "2021-12-02T12:48:52+00:00" + "time": "2023-08-31T06:24:48+00:00" }, { "name": "phpunit/php-invoker", - "version": "3.1.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", - "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "suggest": { "ext-pcntl": "*" @@ -1322,7 +1251,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -1348,7 +1277,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" }, "funding": [ { @@ -1356,32 +1285,32 @@ "type": "github" } ], - "time": "2020-09-28T05:58:55+00:00" + "time": "2023-02-03T06:56:09+00:00" }, { "name": "phpunit/php-text-template", - "version": "2.0.4", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", - "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1407,7 +1336,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" }, "funding": [ { @@ -1415,32 +1345,32 @@ "type": "github" } ], - "time": "2020-10-26T05:33:50+00:00" + "time": "2023-08-31T14:07:24+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.3", + "version": "6.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", - "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1466,7 +1396,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" }, "funding": [ { @@ -1474,24 +1404,23 @@ "type": "github" } ], - "time": "2020-10-26T13:16:10+00:00" + "time": "2023-02-03T06:57:52+00:00" }, { "name": "phpunit/phpunit", - "version": "9.6.11", + "version": "10.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0" + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/810500e92855eba8a7a5319ae913be2da6f957b0", - "reference": "810500e92855eba8a7a5319ae913be2da6f957b0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6fce887c71076a73f32fd3e0774a6833fc5c7f19", + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -1501,27 +1430,26 @@ "myclabs/deep-copy": "^1.10.1", "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", - "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", - "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.8", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.5", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.2", - "sebastian/version": "^3.0.2" + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.5", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-invoker": "^4.0", + "phpunit/php-text-template": "^3.0", + "phpunit/php-timer": "^6.0", + "sebastian/cli-parser": "^2.0", + "sebastian/code-unit": "^2.0", + "sebastian/comparator": "^5.0", + "sebastian/diff": "^5.0", + "sebastian/environment": "^6.0", + "sebastian/exporter": "^5.1", + "sebastian/global-state": "^6.0.1", + "sebastian/object-enumerator": "^5.0", + "sebastian/recursion-context": "^5.0", + "sebastian/type": "^4.0", + "sebastian/version": "^4.0" }, "suggest": { - "ext-soap": "To be able to generate mocks based on WSDL files", - "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + "ext-soap": "To be able to generate mocks based on WSDL files" }, "bin": [ "phpunit" @@ -1529,7 +1457,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.6-dev" + "dev-main": "10.5-dev" } }, "autoload": { @@ -1561,7 +1489,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.11" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.3" }, "funding": [ { @@ -1577,32 +1505,32 @@ "type": "tidelift" } ], - "time": "2023-08-19T07:10:56+00:00" + "time": "2023-12-13T07:25:23+00:00" }, { "name": "sebastian/cli-parser", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", + "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -1625,7 +1553,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" }, "funding": [ { @@ -1633,32 +1561,32 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2023-02-03T06:58:15+00:00" }, { "name": "sebastian/code-unit", - "version": "1.0.8", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", - "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -1681,7 +1609,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" }, "funding": [ { @@ -1689,32 +1617,32 @@ "type": "github" } ], - "time": "2020-10-26T13:08:54+00:00" + "time": "2023-02-03T06:58:43+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.3", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", - "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -1736,7 +1664,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" }, "funding": [ { @@ -1744,34 +1672,36 @@ "type": "github" } ], - "time": "2020-09-28T05:30:19+00:00" + "time": "2023-02-03T06:59:15+00:00" }, { "name": "sebastian/comparator", - "version": "4.0.8", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", - "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/diff": "^4.0", - "sebastian/exporter": "^4.0" + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -1810,7 +1740,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" }, "funding": [ { @@ -1818,33 +1749,33 @@ "type": "github" } ], - "time": "2022-09-14T12:41:17+00:00" + "time": "2023-08-14T13:18:12+00:00" }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", - "php": ">=7.3" + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -1867,7 +1798,8 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -1875,33 +1807,33 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^10.0", "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -1933,7 +1865,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" }, "funding": [ { @@ -1941,27 +1874,27 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2023-05-01T07:48:21+00:00" }, { "name": "sebastian/environment", - "version": "5.1.5", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", - "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951", + "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "suggest": { "ext-posix": "*" @@ -1969,7 +1902,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -1988,7 +1921,7 @@ } ], "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", + "homepage": "https://github.com/sebastianbergmann/environment", "keywords": [ "Xdebug", "environment", @@ -1996,7 +1929,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.0.1" }, "funding": [ { @@ -2004,34 +1938,34 @@ "type": "github" } ], - "time": "2023-02-03T06:03:51+00:00" + "time": "2023-04-11T05:39:26+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc", + "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/recursion-context": "^4.0" + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" }, "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -2073,7 +2007,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1" }, "funding": [ { @@ -2081,38 +2016,35 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2023-09-24T13:22:09+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.6", + "version": "6.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^9.3" - }, - "suggest": { - "ext-uopz": "*" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-main": "6.0-dev" } }, "autoload": { @@ -2137,7 +2069,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1" }, "funding": [ { @@ -2145,33 +2078,33 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2023-07-19T07:19:23+00:00" }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", - "php": ">=7.3" + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "2.0-dev" } }, "autoload": { @@ -2194,7 +2127,8 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -2202,34 +2136,34 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.4", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", - "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", "shasum": "" }, "require": { - "php": ">=7.3", - "sebastian/object-reflector": "^2.0", - "sebastian/recursion-context": "^4.0" + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2251,7 +2185,7 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" }, "funding": [ { @@ -2259,32 +2193,32 @@ "type": "github" } ], - "time": "2020-10-26T13:12:34+00:00" + "time": "2023-02-03T07:08:32+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", - "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -2306,7 +2240,7 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" }, "funding": [ { @@ -2314,32 +2248,32 @@ "type": "github" } ], - "time": "2020-10-26T13:14:26+00:00" + "time": "2023-02-03T07:06:18+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.5", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" + "reference": "05909fb5bc7df4c52992396d0116aed689f93712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", - "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.3" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-main": "5.0-dev" } }, "autoload": { @@ -2369,7 +2303,7 @@ "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" }, "funding": [ { @@ -2377,87 +2311,32 @@ "type": "github" } ], - "time": "2023-02-03T06:07:39+00:00" - }, - { - "name": "sebastian/resource-operations", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "shasum": "" - }, - "require": { - "php": ">=7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides a list of PHP built-in functions that operate on resources", - "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2023-02-03T07:05:40+00:00" }, { "name": "sebastian/type", - "version": "3.2.1", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", - "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -2480,7 +2359,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" }, "funding": [ { @@ -2488,29 +2367,29 @@ "type": "github" } ], - "time": "2023-02-03T06:13:03+00:00" + "time": "2023-02-03T07:10:45+00:00" }, { "name": "sebastian/version", - "version": "3.0.2", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c6c1022351a901512170118436c764e473f6de8c" + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", - "reference": "c6c1022351a901512170118436c764e473f6de8c", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", "shasum": "" }, "require": { - "php": ">=7.3" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "4.0-dev" } }, "autoload": { @@ -2533,7 +2412,7 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" }, "funding": [ { @@ -2541,20 +2420,20 @@ "type": "github" } ], - "time": "2020-09-28T06:39:44+00:00" + "time": "2023-02-07T11:34:05+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -2583,7 +2462,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -2591,7 +2470,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" } ], "aliases": [], @@ -2605,5 +2484,5 @@ "ext-reflection": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/examples/ClientProvider.php b/examples/ClientProvider.php new file mode 100644 index 00000000..5fdfd93f --- /dev/null +++ b/examples/ClientProvider.php @@ -0,0 +1,23 @@ +getLogMessage('Request', $method, $endpoint, $json); + $this->newLine(); + } + + public function logResponse(string $method, string $endpoint, ?string $json): void + { + echo $this->getLogMessage('Response', $method, $endpoint, $json); + $this->newLine(); + } + + public function logError(?string $message): void + { + echo $message; + $this->newLine(); + } + + private function getLogMessage(string $type, string $method, string $endpoint, ?string $json): string + { + $array = [ + 'type' => $type, + 'method' => $method, + 'endpoint' => $endpoint, + 'json' => $json + ]; + + return json_encode($array, JSON_THROW_ON_ERROR | JSON_ERROR_NONE); + } + + private function newLine(): void + { + echo "\r\n"; + } + } + ); + + // for monolog implementation you can use code from src/BitPaySDK/Logger/MonologLoggerExample.php + + $client = ClientProvider::create(); + + $invoice = $client->getInvoiceByGuid("someGuid"); // requests/response will be logged + } +} diff --git a/examples/Merchant/BillRequests.php b/examples/Merchant/BillRequests.php new file mode 100644 index 00000000..794dd37a --- /dev/null +++ b/examples/Merchant/BillRequests.php @@ -0,0 +1,74 @@ +setName('someName'); + $bill->setEmail('someEmail@email.com'); + $bill->setAddress1('SomeAddress'); + $bill->setCity('MyCity'); + // ... + + $client->createBill($bill); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getBill(): void + { + $client = ClientProvider::create(); + + $bill = $client->getBill('someBillId'); + + $bills = $client->getBills('draft'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function updateBill(): void + { + $client = ClientProvider::create(); + + $item = new Item(); + $item->setPrice(12.34); + $item->setQuantity(5); + $item->setDescription('someDecription'); + + $bill = new Bill(); + $bill->setEmail('myNew@email.com'); + $bill->setItems([$item]); + + $client->updateBill($bill, $bill->getId()); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function deliverBillViaEmail(): void + { + $client = ClientProvider::create(); + + $client->deliverBill('someBillId', 'myBillToken'); + } +} diff --git a/examples/Merchant/InvoiceRequests.php b/examples/Merchant/InvoiceRequests.php new file mode 100644 index 00000000..f6db829f --- /dev/null +++ b/examples/Merchant/InvoiceRequests.php @@ -0,0 +1,92 @@ +setFullNotifications(true); + $invoice->setExtendedNotifications(true); + $invoice->setNotificationURL("https://test/lJnJg9WW7MtG9GZlPVdj"); + $invoice->setRedirectURL("https://test/lJnJg9WW7MtG9GZlPVdj"); + $invoice->setNotificationEmail("my@email.com"); + $invoice->setBuyerSms('+12223334445'); + + $buyer = new Buyer(); + $buyer->setName("Test"); + $buyer->setEmail("test@email.com"); + $buyer->setAddress1("168 General Grove"); + $buyer->setCountry("AD"); + $buyer->setLocality("Port Horizon"); + $buyer->setNotify(true); + $buyer->setPhone("+990123456789"); + $buyer->setPostalCode("KY7 1TH"); + $buyer->setRegion("New Port"); + + $invoice->setBuyer($buyer); + + $client = ClientProvider::create(); + + $createdInvoice = $client->createInvoice($invoice); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getInvoice(): void + { + $client = ClientProvider::create(); + + $invoiceById = $client->getInvoice("myInvoiceId"); + $invoiceByGuid = $client->getInvoiceByGuid("someGuid"); // we can add a GUID during the invoice creation + $invoices = $client->getInvoices("2023-04-14", "2023-04-17"); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function updateInvoice(): void + { + $client = ClientProvider::create(); + + $invoice = $client->updateInvoice("someId", "123321312", null, null); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function cancelInvoice(): void + { + $client = ClientProvider::create(); + + $client->cancelInvoice('invoiceId'); + + $client->cancelInvoiceByGuid('invoiceGuid'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function requestInvoiceWebhookToBeResent(): void + { + $client = ClientProvider::create(); + + $client->requestInvoiceNotification('someInvoiceId'); + } +} diff --git a/examples/Merchant/LedgerRequests.php b/examples/Merchant/LedgerRequests.php new file mode 100644 index 00000000..9a5cb19f --- /dev/null +++ b/examples/Merchant/LedgerRequests.php @@ -0,0 +1,32 @@ +getLedgers(); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getLedgerEntries(): void + { + $client = ClientProvider::create(); + + $ledgerEntries = $client->getLedgerEntries('USD', '2023-08-14', '2023-08-22'); + } +} diff --git a/examples/Merchant/RefundRequests.php b/examples/Merchant/RefundRequests.php new file mode 100644 index 00000000..7208b677 --- /dev/null +++ b/examples/Merchant/RefundRequests.php @@ -0,0 +1,62 @@ +createRefund("myInvoiceId", 12.34, "USD"); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + */ + public function updateRefund(): void + { + $client = ClientProvider::create(); + + $updatedRefund = $client->updateRefund('myRefundId','created'); + $updatedRefundByGuid = $client->updateRefundByGuid('myRefundId','created'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getRefund(): void + { + $client = ClientProvider::create(); + + $refund = $client->getRefund('someRefundId'); + $refundByGuid = $client->getRefundByGuid('someGuid'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + */ + public function cancelRefund(): void + { + $client = ClientProvider::create(); + + $cancelRefund = $client->cancelRefund('myRefundId'); + $cancelRefundByGuid = $client->cancelRefundByGuid('someGuid'); + } + + public function requestRefundNotificationToBeResent(): void + { + $client = ClientProvider::create(); + + $client->sendRefundNotification('someRefundId'); + } +} diff --git a/examples/Merchant/SettlementRequests.php b/examples/Merchant/SettlementRequests.php new file mode 100644 index 00000000..4c1fa3a3 --- /dev/null +++ b/examples/Merchant/SettlementRequests.php @@ -0,0 +1,36 @@ +getSettlement('someSettlementId'); + $settlements = $client->getSettlements('USD', '2023-08-14', '2023-08-22'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function fetchReconciliationReport(): void + { + $client = ClientProvider::create(); + + $settlement = new Settlement(); + + $client->getSettlementReconciliationReport('settlementId', 'settlementToken'); + } +} diff --git a/examples/Payout/PayoutRequests.php b/examples/Payout/PayoutRequests.php new file mode 100644 index 00000000..b07c88c7 --- /dev/null +++ b/examples/Payout/PayoutRequests.php @@ -0,0 +1,61 @@ +setNotificationEmail('myEmail@email.com'); + $payout->setNotificationURL('https://my-url.com'); + + $payout = $client->submitPayout($payout); + + $payouts = $client->createPayoutGroup([ + new Payout(12.34, 'USD', 'USD'), + new Payout(56.14, 'USD', 'USD'), + ]); + } + + public function getPayout(): void + { + $client = ClientProvider::create(); + + $payout = $client->getPayout('myPayoutId'); + + $payouts = $client->getPayouts('2023-08-14', '2023-08-22'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function cancelPayout(): void + { + $client = ClientProvider::create(); + + $client->cancelPayout('somePayoutId'); + + // $payoutGroupId = $payout->getGroupId(); + $cancelledPayouts = $client->cancelPayoutGroup('payoutGroupId'); + } + + public function requestPayoutWebhookToBeResent(): void + { + $client = ClientProvider::create(); + + $client->requestPayoutNotification('somePayoutId'); + } +} diff --git a/examples/Payout/RecipientRequests.php b/examples/Payout/RecipientRequests.php new file mode 100644 index 00000000..03540626 --- /dev/null +++ b/examples/Payout/RecipientRequests.php @@ -0,0 +1,66 @@ +setEmail('some@email.com'); + + $payoutRecipients = new PayoutRecipients([$payoutRecipient]); + + $recipients = $client->submitPayoutRecipients($payoutRecipients); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getRecipient(): void + { + $client = ClientProvider::create(); + + $recipient = $client->getPayoutRecipient('someRecipientId'); + + $recipients = $client->getPayoutRecipients('invited'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function updateRecipient(): void + { + $client = ClientProvider::create(); + + $payoutRecipient = new PayoutRecipient(); + $payoutRecipient->setLabel('some label'); + + $recipient = $client->updatePayoutRecipient($payoutRecipient->getId(), $payoutRecipient); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function removeRecipient(): void + { + $client = ClientProvider::create(); + + $result = $client->deletePayoutRecipient('somePayoutRecipientId'); + } +} diff --git a/examples/Pos/BillRequests.php b/examples/Pos/BillRequests.php new file mode 100644 index 00000000..f2ef587f --- /dev/null +++ b/examples/Pos/BillRequests.php @@ -0,0 +1,51 @@ +setName('someName'); + $bill->setEmail('someEmail@email.com'); + $bill->setAddress1('SomeAddress'); + $bill->setCity('MyCity'); + // ... + + $client->createBill($bill); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getBill(): void + { + $client = ClientProvider::createPos(); + + $bill = $client->getBill('someBillId'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function deliverBillViaEmail(): void + { + $client = ClientProvider::createPos(); + + $client->deliverBill('someBillId', 'myBillToken'); + } +} diff --git a/examples/Pos/InvoiceRequests.php b/examples/Pos/InvoiceRequests.php new file mode 100644 index 00000000..d6445497 --- /dev/null +++ b/examples/Pos/InvoiceRequests.php @@ -0,0 +1,66 @@ +setFullNotifications(true); + $invoice->setExtendedNotifications(true); + $invoice->setNotificationURL('https://test/lJnJg9WW7MtG9GZlPVdj'); + $invoice->setRedirectURL('https://test/lJnJg9WW7MtG9GZlPVdj'); + $invoice->setNotificationEmail('my@email.com'); + $invoice->setBuyerSms('+12223334445'); + + $buyer = new Buyer(); + $buyer->setName('Test'); + $buyer->setEmail('test@email.com'); + $buyer->setAddress1('168 General Grove'); + $buyer->setCountry('AD'); + $buyer->setLocality('Port Horizon'); + $buyer->setNotify(true); + $buyer->setPhone('+990123456789'); + $buyer->setPostalCode('KY7 1TH'); + $buyer->setRegion('New Port'); + + $invoice->setBuyer($buyer); + + $client = ClientProvider::createPos(); + + $createdInvoice = $client->createInvoice($invoice); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function getInvoice(): void + { + $client = ClientProvider::createPos(); + + $invoiceById = $client->getInvoice('myInvoiceId'); + } + + /** + * @throws \BitPaySDK\Exceptions\BitPayApiException + * @throws \BitPaySDK\Exceptions\BitPayGenericException + */ + public function requestInvoiceWebhookToBeResent(): void + { + $client = ClientProvider::createPos(); + + $client->requestInvoiceNotification('someInvoiceId'); + } +} diff --git a/examples/Public/RateRequests.php b/examples/Public/RateRequests.php new file mode 100644 index 00000000..b692661f --- /dev/null +++ b/examples/Public/RateRequests.php @@ -0,0 +1,25 @@ +getRates(); + + $currencyRates = $client->getCurrencyRates('BTC'); + + $currencyPairRate = $client->getCurrencyPairRate('BTC', 'USD'); + } +} diff --git a/examples/Public/WalletRequests.php b/examples/Public/WalletRequests.php new file mode 100644 index 00000000..9098b4ff --- /dev/null +++ b/examples/Public/WalletRequests.php @@ -0,0 +1,21 @@ +getSupportedWallets(); + } +} diff --git a/src/BitPaySDK/Client.php b/src/BitPaySDK/Client.php index 7ef343ed..c200de5e 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -995,16 +995,17 @@ public function getSettlement(string $settlementId): Settlement * * @see https://developer.bitpay.com/reference/fetch-a-reconciliation-report Fetch a Reconciliation Report * - * @param Settlement $settlement Settlement to generate report for. + * @param string $settlementId Settlement ID + * @param string $settlementToken Settlement Token * @return Settlement * @throws BitPayApiException * @throws BitPayGenericException */ - public function getSettlementReconciliationReport(Settlement $settlement): Settlement + public function getSettlementReconciliationReport(string $settlementId, string $settlementToken): Settlement { $settlementsClient = $this->getSettlementClient(); - return $settlementsClient->getReconciliationReport($settlement); + return $settlementsClient->getReconciliationReport( $settlementId, $settlementToken); } /** diff --git a/src/BitPaySDK/Client/SettlementClient.php b/src/BitPaySDK/Client/SettlementClient.php index ee45e6ed..6f9700b5 100644 --- a/src/BitPaySDK/Client/SettlementClient.php +++ b/src/BitPaySDK/Client/SettlementClient.php @@ -134,18 +134,19 @@ public function get(string $settlementId): Settlement /** * Gets a detailed reconciliation report of the activity within the settlement period. * - * @param Settlement $settlement Settlement to generate report for. + * @param string $settlementId Settlement ID + * @param string $settlementToken Settlement Token * @return Settlement * @throws BitPayApiException * @throws BitPayGenericException */ - public function getReconciliationReport(Settlement $settlement): Settlement + public function getReconciliationReport(string $settlementId, string $settlementToken): Settlement { $params = []; - $params["token"] = $settlement->getToken(); + $params["token"] = $settlementToken; $responseJson = $this->restCli->get( - "settlements/" . $settlement->getId() . "/reconciliationReport", + "settlements/" . $settlementId . "/reconciliationReport", $params ); diff --git a/src/BitPaySDK/Model/Currency.php b/src/BitPaySDK/Model/Currency.php index fd5ee8c5..0d588015 100644 --- a/src/BitPaySDK/Model/Currency.php +++ b/src/BitPaySDK/Model/Currency.php @@ -218,7 +218,11 @@ class Currency protected ?string $minimum = null; protected ?bool $sanctioned = null; protected ?int $decimals = null; - protected ?string $chain; + protected ?string $chain = null; + protected ?string $displayCode = null; + protected ?float $maxSupply = null; + protected ?int $trancheDecimals = null; + protected ?string $contractAddress = null; /** * Currency validation @@ -451,6 +455,70 @@ public function setChain(?string $chain): void $this->chain = $chain; } + /** + * @return string|null + */ + public function getDisplayCode(): ?string + { + return $this->displayCode; + } + + /** + * @param string|null $displayCode + */ + public function setDisplayCode(?string $displayCode): void + { + $this->displayCode = $displayCode; + } + + /** + * @return float|null + */ + public function getMaxSupply(): ?float + { + return $this->maxSupply; + } + + /** + * @param float|null $maxSupply + */ + public function setMaxSupply(?float $maxSupply): void + { + $this->maxSupply = $maxSupply; + } + + /** + * @return int|null + */ + public function getTrancheDecimals(): ?int + { + return $this->trancheDecimals; + } + + /** + * @param int|null $trancheDecimals + */ + public function setTrancheDecimals(?int $trancheDecimals): void + { + $this->trancheDecimals = $trancheDecimals; + } + + /** + * @return string|null + */ + public function getContractAddress(): ?string + { + return $this->contractAddress; + } + + /** + * @param string|null $contractAddress + */ + public function setContractAddress(?string $contractAddress): void + { + $this->contractAddress = $contractAddress; + } + /** * Gets currency data as array * @@ -469,7 +537,11 @@ public function toArray(): array 'minimum' => $this->getMinimum(), 'sanctioned' => $this->getSanctioned(), 'decimals' => $this->getDecimals(), - 'chain' => $this->getChain() + 'chain' => $this->getChain(), + 'displayCode' => $this->getDisplayCode(), + 'maxSupply' => $this->getMaxSupply(), + 'trancheDecimals' => $this->getTrancheDecimals(), + 'contractAddress' => $this->getContractAddress(), ]; foreach ($elements as $key => $value) { diff --git a/test/unit/BitPaySDK/ClientTest.php b/test/unit/BitPaySDK/ClientTest.php index 5bed61ef..0686b81c 100644 --- a/test/unit/BitPaySDK/ClientTest.php +++ b/test/unit/BitPaySDK/ClientTest.php @@ -1679,11 +1679,8 @@ public function testGetSettlementShouldCatchJsonMapperException() public function testGetSettlementReconciliationReport() { - $settlement = $this->createMock(Settlement::class); $exampleToken = self::MERCHANT_TOKEN; $exampleId = 'RPWTabW8urd3xWv2To989v'; - $settlement->method('getToken')->willReturn($exampleToken); - $settlement->method('getId')->willReturn($exampleId); $params['token'] = $exampleToken; $exampleResponse = file_get_contents( __DIR__ . '/jsonResponse/getSettlementReconciliationReportResponse.json' @@ -1698,7 +1695,7 @@ public function testGetSettlementReconciliationReport() $client = $this->getClient($restCliMock); - $result = $client->getSettlementReconciliationReport($settlement); + $result = $client->getSettlementReconciliationReport($exampleId, $exampleToken); self::assertEquals('RvNuCTMAkURKimwgvSVEMP', $result->getId()); self::assertEquals('processing', $result->getStatus()); @@ -1708,11 +1705,8 @@ public function testGetSettlementReconciliationReport() public function testGetSettlementReconciliationReportShouldCatchRestCliBitPayException() { - $settlement = $this->createMock(Settlement::class); $exampleToken = self::MERCHANT_TOKEN; $exampleId = 'RPWTabW8urd3xWv2To989v'; - $settlement->method('getToken')->willReturn($exampleToken); - $settlement->method('getId')->willReturn($exampleId); $params['token'] = $exampleToken; $restCliMock = $this->getRestCliMock(); @@ -1725,16 +1719,13 @@ public function testGetSettlementReconciliationReportShouldCatchRestCliBitPayExc $client = $this->getClient($restCliMock); $this->expectException(BitPayApiException::class); - $client->getSettlementReconciliationReport($settlement); + $client->getSettlementReconciliationReport($exampleId, $exampleToken); } public function testGetSettlementReconciliationReportShouldCatchRestCliException() { - $settlement = $this->createMock(Settlement::class); $exampleToken = self::MERCHANT_TOKEN; $exampleId = 'RPWTabW8urd3xWv2To989v'; - $settlement->method('getToken')->willReturn($exampleToken); - $settlement->method('getId')->willReturn($exampleId); $params['token'] = $exampleToken; $restCliMock = $this->getRestCliMock(); @@ -1747,16 +1738,13 @@ public function testGetSettlementReconciliationReportShouldCatchRestCliException $client = $this->getClient($restCliMock); $this->expectException(BitPayApiException::class); - $client->getSettlementReconciliationReport($settlement); + $client->getSettlementReconciliationReport($exampleId, $exampleToken); } public function testGetSettlementReconciliationReportShouldCatchJsonMapperException() { - $settlement = $this->createMock(Settlement::class); $exampleToken = self::MERCHANT_TOKEN; $exampleId = 'RPWTabW8urd3xWv2To989v'; - $settlement->method('getToken')->willReturn($exampleToken); - $settlement->method('getId')->willReturn($exampleId); $params['token'] = $exampleToken; $badResponse = file_get_contents(__DIR__ . '/jsonResponse/badResponse.json'); @@ -1770,7 +1758,7 @@ public function testGetSettlementReconciliationReportShouldCatchJsonMapperExcept $client = $this->getClient($restCliMock); $this->expectException(BitPayGenericException::class); - $client->getSettlementReconciliationReport($settlement); + $client->getSettlementReconciliationReport($exampleId, $exampleToken); } /** From 634a62a950d3a3c20f9e759a9229f2a75fe6e3a9 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Thu, 21 Dec 2023 18:02:13 +0100 Subject: [PATCH 7/9] SP-750 Code Examples: PHP --- 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 c200de5e..0063cd1c 100644 --- a/src/BitPaySDK/Client.php +++ b/src/BitPaySDK/Client.php @@ -1005,7 +1005,7 @@ public function getSettlementReconciliationReport(string $settlementId, string $ { $settlementsClient = $this->getSettlementClient(); - return $settlementsClient->getReconciliationReport( $settlementId, $settlementToken); + return $settlementsClient->getReconciliationReport($settlementId, $settlementToken); } /** From d5270622ee636cb34ea4e3044324a6ef20c45747 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Thu, 11 Jan 2024 10:14:03 +0100 Subject: [PATCH 8/9] SP-750 Code Examples: PHP --- examples/Merchant/BillRequests.php | 7 +- examples/Merchant/SettlementRequests.php | 3 - examples/Pos/BillRequests.php | 2 +- examples/Pos/InvoiceRequests.php | 11 - src/BitPaySDK/Model/Currency.php | 10 +- src/BitPaySDK/Model/Invoice/MinerFees.php | 48 ++++ .../SupportedTransactionCurrencies.php | 240 ++++++++++++++++++ src/BitPaySDK/Model/Ledger/LedgerEntry.php | 10 +- .../BitPaySDK/PayoutRecipientsClientTest.php | 3 - .../Model/Ledger/LedgerEntryTest.php | 6 +- 10 files changed, 305 insertions(+), 35 deletions(-) diff --git a/examples/Merchant/BillRequests.php b/examples/Merchant/BillRequests.php index 794dd37a..fdb541a6 100644 --- a/examples/Merchant/BillRequests.php +++ b/examples/Merchant/BillRequests.php @@ -6,6 +6,7 @@ use BitPaySDK\Model\Bill\Bill; use BitPaySDK\Model\Bill\Item; +use BitPaySDK\Model\Facade; use BitPaySDKexamples\ClientProvider; final class BillRequests @@ -25,7 +26,7 @@ public function createBill(): void $bill->setCity('MyCity'); // ... - $client->createBill($bill); + $client->createBill($bill, Facade::MERCHANT, false); } /** @@ -36,9 +37,7 @@ public function getBill(): void { $client = ClientProvider::create(); - $bill = $client->getBill('someBillId'); - - $bills = $client->getBills('draft'); + $bill = $client->getBill('someBillId', Facade::MERCHANT, false); } /** diff --git a/examples/Merchant/SettlementRequests.php b/examples/Merchant/SettlementRequests.php index 4c1fa3a3..57da76e9 100644 --- a/examples/Merchant/SettlementRequests.php +++ b/examples/Merchant/SettlementRequests.php @@ -4,7 +4,6 @@ namespace BitPaySDKexamples\Merchant; -use BitPaySDK\Model\Settlement\Settlement; use BitPaySDKexamples\ClientProvider; final class SettlementRequests @@ -29,8 +28,6 @@ public function fetchReconciliationReport(): void { $client = ClientProvider::create(); - $settlement = new Settlement(); - $client->getSettlementReconciliationReport('settlementId', 'settlementToken'); } } diff --git a/examples/Pos/BillRequests.php b/examples/Pos/BillRequests.php index f2ef587f..6ee73dce 100644 --- a/examples/Pos/BillRequests.php +++ b/examples/Pos/BillRequests.php @@ -46,6 +46,6 @@ public function deliverBillViaEmail(): void { $client = ClientProvider::createPos(); - $client->deliverBill('someBillId', 'myBillToken'); + $result = $client->deliverBill('someBillId', 'myBillToken'); } } diff --git a/examples/Pos/InvoiceRequests.php b/examples/Pos/InvoiceRequests.php index d6445497..8c22fde9 100644 --- a/examples/Pos/InvoiceRequests.php +++ b/examples/Pos/InvoiceRequests.php @@ -52,15 +52,4 @@ public function getInvoice(): void $invoiceById = $client->getInvoice('myInvoiceId'); } - - /** - * @throws \BitPaySDK\Exceptions\BitPayApiException - * @throws \BitPaySDK\Exceptions\BitPayGenericException - */ - public function requestInvoiceWebhookToBeResent(): void - { - $client = ClientProvider::createPos(); - - $client->requestInvoiceNotification('someInvoiceId'); - } } diff --git a/src/BitPaySDK/Model/Currency.php b/src/BitPaySDK/Model/Currency.php index 0d588015..a4871827 100644 --- a/src/BitPaySDK/Model/Currency.php +++ b/src/BitPaySDK/Model/Currency.php @@ -220,7 +220,7 @@ class Currency protected ?int $decimals = null; protected ?string $chain = null; protected ?string $displayCode = null; - protected ?float $maxSupply = null; + protected ?string $maxSupply = null; protected ?int $trancheDecimals = null; protected ?string $contractAddress = null; @@ -472,17 +472,17 @@ public function setDisplayCode(?string $displayCode): void } /** - * @return float|null + * @return string|null */ - public function getMaxSupply(): ?float + public function getMaxSupply(): ?string { return $this->maxSupply; } /** - * @param float|null $maxSupply + * @param string|null $maxSupply */ - public function setMaxSupply(?float $maxSupply): void + public function setMaxSupply(?string $maxSupply): void { $this->maxSupply = $maxSupply; } diff --git a/src/BitPaySDK/Model/Invoice/MinerFees.php b/src/BitPaySDK/Model/Invoice/MinerFees.php index ff693db8..854d0639 100644 --- a/src/BitPaySDK/Model/Invoice/MinerFees.php +++ b/src/BitPaySDK/Model/Invoice/MinerFees.php @@ -33,6 +33,8 @@ class MinerFees protected MinerFeesItem $ltc; protected MinerFeesItem $dai; protected MinerFeesItem $wbtc; + protected MinerFeesItem $matic; + protected MinerFeesItem $usdcM; /** * MinerFees constructor. @@ -51,6 +53,8 @@ public function __construct() $this->ltc = new MinerFeesItem(); $this->dai = new MinerFeesItem(); $this->wbtc = new MinerFeesItem(); + $this->matic = new MinerFeesItem(); + $this->usdcM = new MinerFeesItem(); } /** @@ -293,6 +297,48 @@ public function setWBTC(MinerFeesItem $wbtc): void $this->wbtc = $wbtc; } + /** + * Gets MATIC. + * + * @return MinerFeesItem + */ + public function getMATIC(): MinerFeesItem + { + return $this->matic; + } + + /** + * Sets MATIC. + * + * @param MinerFeesItem $matic + * @return void + */ + public function setMATIC(MinerFeesItem $matic): void + { + $this->matic = $matic; + } + + /** + * Gets USDC_m. + * + * @return MinerFeesItem + */ + public function getUsdcM(): MinerFeesItem + { + return $this->usdcM; + } + + /** + * Sets USDC_m. + * + * @param MinerFeesItem $usdcM + * @return void + */ + public function setUsdcM(MinerFeesItem $usdcM): void + { + $this->usdcM = $usdcM; + } + /** * Return array with details for currencies. * @@ -313,6 +359,8 @@ public function toArray(): array 'ltc' => $this->getLTC()->toArray(), 'dai' => $this->getDAI()->toArray(), 'wbtc' => $this->getWBTC()->toArray(), + 'matic' => $this->getMATIC()->toArray(), + 'usdc_m' => $this->getUsdcM()->toArray() ]; foreach ($elements as $key => $value) { diff --git a/src/BitPaySDK/Model/Invoice/SupportedTransactionCurrencies.php b/src/BitPaySDK/Model/Invoice/SupportedTransactionCurrencies.php index 2131d57e..26344620 100644 --- a/src/BitPaySDK/Model/Invoice/SupportedTransactionCurrencies.php +++ b/src/BitPaySDK/Model/Invoice/SupportedTransactionCurrencies.php @@ -29,6 +29,16 @@ class SupportedTransactionCurrencies protected SupportedTransactionCurrency $doge; protected SupportedTransactionCurrency $ltc; protected SupportedTransactionCurrency $wbtc; + protected SupportedTransactionCurrency $dai; + protected SupportedTransactionCurrency $euroc; + protected SupportedTransactionCurrency $matic; + protected SupportedTransactionCurrency $maticE; + protected SupportedTransactionCurrency $ethM; + protected SupportedTransactionCurrency $usdcM; + protected SupportedTransactionCurrency $busdM; + protected SupportedTransactionCurrency $daiM; + protected SupportedTransactionCurrency $wbtcM; + protected SupportedTransactionCurrency $shibM; /** * SupportedTransactionCurrencies constructor. @@ -46,6 +56,16 @@ public function __construct() $this->doge = new SupportedTransactionCurrency(); $this->ltc = new SupportedTransactionCurrency(); $this->wbtc = new SupportedTransactionCurrency(); + $this->dai = new SupportedTransactionCurrency(); + $this->euroc = new SupportedTransactionCurrency(); + $this->matic = new SupportedTransactionCurrency(); + $this->maticE = new SupportedTransactionCurrency(); + $this->ethM = new SupportedTransactionCurrency(); + $this->usdcM = new SupportedTransactionCurrency(); + $this->busdM = new SupportedTransactionCurrency(); + $this->daiM = new SupportedTransactionCurrency(); + $this->wbtcM = new SupportedTransactionCurrency(); + $this->shibM = new SupportedTransactionCurrency(); } /** @@ -268,6 +288,216 @@ public function setWBTC(SupportedTransactionCurrency $wbtc): void $this->wbtc = $wbtc; } + /** + * Gets DAI. + * + * @return SupportedTransactionCurrency + */ + public function getDAI(): SupportedTransactionCurrency + { + return $this->dai; + } + + /** + * Sets DAI. + * + * @param SupportedTransactionCurrency $dai + * @return void + */ + public function setDAI(SupportedTransactionCurrency $dai): void + { + $this->dai = $dai; + } + + /** + * Gets EUROC. + * + * @return SupportedTransactionCurrency + */ + public function getEUROC(): SupportedTransactionCurrency + { + return $this->euroc; + } + + /** + * Sets EUROC. + * + * @param SupportedTransactionCurrency $euroc + * @return void + */ + public function setEUROC(SupportedTransactionCurrency $euroc): void + { + $this->euroc = $euroc; + } + + /** + * Gets MATIC. + * + * @return SupportedTransactionCurrency + */ + public function getMATIC(): SupportedTransactionCurrency + { + return $this->matic; + } + + /** + * Sets MATIC. + * + * @param SupportedTransactionCurrency $matic + * @return void + */ + public function setMATIC(SupportedTransactionCurrency $matic): void + { + $this->matic = $matic; + } + + /** + * Gets MATIC_e + * + * @return SupportedTransactionCurrency + */ + public function getMaticE(): SupportedTransactionCurrency + { + return $this->maticE; + } + + /** + * Sets MATIC_e. + * + * @param SupportedTransactionCurrency $maticE + * @return void + */ + public function setMaticE(SupportedTransactionCurrency $maticE): void + { + $this->maticE = $maticE; + } + + /** + * Gets ETC_m. + * + * @return SupportedTransactionCurrency + */ + public function getEthM(): SupportedTransactionCurrency + { + return $this->ethM; + } + + /** + * Sets ETC_m. + * + * @param SupportedTransactionCurrency $ethM + * @return void + */ + public function setEthM(SupportedTransactionCurrency $ethM): void + { + $this->ethM = $ethM; + } + + /** + * Gets USDC_m. + * + * @return SupportedTransactionCurrency + */ + public function getUsdcM(): SupportedTransactionCurrency + { + return $this->usdcM; + } + + /** + * Sets USDC_m. + * + * @param SupportedTransactionCurrency $usdcM + * @return void + */ + public function setUsdcM(SupportedTransactionCurrency $usdcM): void + { + $this->usdcM = $usdcM; + } + + /** + * Gets BUSD_m. + * + * @return SupportedTransactionCurrency + */ + public function getBusdM(): SupportedTransactionCurrency + { + return $this->busdM; + } + + /** + * Sets BUSD_m. + * + * @param SupportedTransactionCurrency $busdM + * @return void + */ + public function setBusdM(SupportedTransactionCurrency $busdM): void + { + $this->busdM = $busdM; + } + + /** + * Gets DAI_m. + * + * @return SupportedTransactionCurrency + */ + public function getDaiM(): SupportedTransactionCurrency + { + return $this->daiM; + } + + /** + * Sets DAI_m. + * + * @param SupportedTransactionCurrency $daiM + * @return void + */ + public function setDaiM(SupportedTransactionCurrency $daiM): void + { + $this->daiM = $daiM; + } + + /** + * Gets WBTC_m. + * + * @return SupportedTransactionCurrency + */ + public function getWbtcM(): SupportedTransactionCurrency + { + return $this->wbtcM; + } + + /** + * Sets WBTC_m. + * + * @param SupportedTransactionCurrency $wbtcM + * @return void + */ + public function setWbtcM(SupportedTransactionCurrency $wbtcM): void + { + $this->wbtcM = $wbtcM; + } + + /** + * Gets SHIB_m. + * + * @return SupportedTransactionCurrency + */ + public function getShibM(): SupportedTransactionCurrency + { + return $this->shibM; + } + + /** + * Sets SHIB_m. + * + * @param SupportedTransactionCurrency $shibM + * @return void + */ + public function setShibM(SupportedTransactionCurrency $shibM): void + { + $this->shibM = $shibM; + } + /** * Return array with details for currencies. * @@ -287,6 +517,16 @@ public function toArray(): array 'doge' => $this->getDOGE()->toArray(), 'ltc' => $this->getLTC()->toArray(), 'wbtc' => $this->getWBTC()->toArray(), + 'dai' => $this->getDAI()->toArray(), + 'euroc' => $this->getEUROC()->toArray(), + 'matic' => $this->getMATIC()->toArray(), + 'maticE' => $this->getMaticE()->toArray(), + 'ethM' => $this->getEthM()->toArray(), + 'usdcM' => $this->getUsdcM()->toArray(), + 'busdM' => $this->getBusdM()->toArray(), + 'daiM' => $this->getDaiM()->toArray(), + 'wbtcM' => $this->getWbtcM()->toArray(), + 'shibM' => $this->getShibM()->toArray(), ]; foreach ($elements as $key => $value) { diff --git a/src/BitPaySDK/Model/Ledger/LedgerEntry.php b/src/BitPaySDK/Model/Ledger/LedgerEntry.php index 49f4c257..f8e6c12e 100644 --- a/src/BitPaySDK/Model/Ledger/LedgerEntry.php +++ b/src/BitPaySDK/Model/Ledger/LedgerEntry.php @@ -27,7 +27,7 @@ class LedgerEntry protected ?string $timestamp = null; protected ?string $currency = null; protected ?string $txType = null; - protected ?string $scale = null; + protected ?int $scale = null; protected ?string $id = null; protected ?string $supportRequest = null; protected ?string $description = null; @@ -185,9 +185,9 @@ public function setTxType(string $txType): void * * Power of 10 used for conversion * - * @return string|null the scale + * @return int|null the scale */ - public function getScale(): ?string + public function getScale(): ?int { return $this->scale; } @@ -197,9 +197,9 @@ public function getScale(): ?string * * Power of 10 used for conversion * - * @param string $scale the scale + * @param int $scale the scale */ - public function setScale(string $scale): void + public function setScale(int $scale): void { $this->scale = $scale; } diff --git a/test/functional/BitPaySDK/PayoutRecipientsClientTest.php b/test/functional/BitPaySDK/PayoutRecipientsClientTest.php index 1774661e..c92b5ba3 100644 --- a/test/functional/BitPaySDK/PayoutRecipientsClientTest.php +++ b/test/functional/BitPaySDK/PayoutRecipientsClientTest.php @@ -14,9 +14,6 @@ class PayoutRecipientsClientTest extends AbstractClientTestCase { - /** - * @throws PayoutRecipientCreationException - */ public function testSubmitPayoutRecipients(): void { $recipientsList = [ diff --git a/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php b/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php index bcfa297c..166b7100 100644 --- a/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php +++ b/test/unit/BitPaySDK/Model/Ledger/LedgerEntryTest.php @@ -70,7 +70,7 @@ public function testGetTxType() public function testGetScale() { - $expectedScale = 'TestScale'; + $expectedScale = 132132; $ledgerEntry = $this->createClassObject(); $ledgerEntry->setScale($expectedScale); @@ -179,7 +179,7 @@ public function testToArray() self::assertEquals('2020-01-01 18:10:10', $ledgerEntryArray['timestamp']); self::assertEquals('BTC', $ledgerEntryArray['currency']); self::assertEquals('TxType', $ledgerEntryArray['txType']); - self::assertEquals('Test scale', $ledgerEntryArray['scale']); + self::assertEquals(100000, $ledgerEntryArray['scale']); self::assertEquals('1', $ledgerEntryArray['id']); self::assertEquals('Test support request', $ledgerEntryArray['supportRequest']); self::assertEquals('Test description', $ledgerEntryArray['description']); @@ -202,7 +202,7 @@ private function setSetters(LedgerEntry $ledgerEntry) $ledgerEntry->setTimestamp('2020-01-01 18:10:10'); $ledgerEntry->setCurrency('BTC'); $ledgerEntry->setTxType('TxType'); - $ledgerEntry->setScale('Test scale'); + $ledgerEntry->setScale(100000); $ledgerEntry->setId('1'); $ledgerEntry->setSupportRequest('Test support request'); $ledgerEntry->setDescription('Test description'); From 35eed1d9178960eeb71e4355f35a5092f3b7f769 Mon Sep 17 00:00:00 2001 From: Marcin Warzybok Date: Thu, 11 Jan 2024 15:33:28 +0100 Subject: [PATCH 9/9] SP-750 Code Examples: PHP --- examples/Merchant/BillRequests.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/Merchant/BillRequests.php b/examples/Merchant/BillRequests.php index fdb541a6..34fedb12 100644 --- a/examples/Merchant/BillRequests.php +++ b/examples/Merchant/BillRequests.php @@ -38,6 +38,8 @@ public function getBill(): void $client = ClientProvider::create(); $bill = $client->getBill('someBillId', Facade::MERCHANT, false); + + $bills = $client->getBills('draft'); } /** @@ -51,7 +53,7 @@ public function updateBill(): void $item = new Item(); $item->setPrice(12.34); $item->setQuantity(5); - $item->setDescription('someDecription'); + $item->setDescription('someDescription'); $bill = new Bill(); $bill->setEmail('myNew@email.com');