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