diff --git a/Changelog.md b/Changelog.md index 9b23a0f..4623c4d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,12 @@ ## 3.x Series +## Unreleased +##### 2023-XX-YY + +- Added missing Payment Status magic comparison annotations to the interface/model +- Added the `hasRemoteId()`, `getRemoteId()` and `isOffline()` helper methods to the Payment model (v4 interface candidates) + ## 3.7.0 ##### 2023-04-04 diff --git a/Contracts/Payment.php b/Contracts/Payment.php index b525556..f376286 100644 --- a/Contracts/Payment.php +++ b/Contracts/Payment.php @@ -34,8 +34,11 @@ public function getStatus(): PaymentStatus; public function getMethod(): PaymentMethod; /** - * @todo add this in v4 + * @todo add these in v4 * public function getSubtype(): ?string + * public function hasRemoteId(): bool + * public function getRemoteId(): ?string + * public function isOffline(): bool */ public function getPayable(): Payable; diff --git a/Contracts/PaymentStatus.php b/Contracts/PaymentStatus.php index 0c74b7e..d8af0b4 100644 --- a/Contracts/PaymentStatus.php +++ b/Contracts/PaymentStatus.php @@ -24,6 +24,17 @@ * @method static PaymentStatus TIMEOUT() * @method static PaymentStatus CANCELLED() * @method static PaymentStatus REFUNDED() + * + * @method bool isPending() + * @method bool isAuthorized() + * @method bool isOnHold() + * @method bool isPaid() + * @method bool isPartiallyPaid() + * @method bool isDeclined() + * @method bool isTimeout() + * @method bool isCancelled() + * @method bool isRefunded() + * @method bool isPartiallyRefunded() */ interface PaymentStatus { diff --git a/Models/Payment.php b/Models/Payment.php index 0c6b298..ddb4476 100644 --- a/Models/Payment.php +++ b/Models/Payment.php @@ -114,6 +114,21 @@ public static function findByRemoteId(string $remoteId, int $paymentMethodId = n ->first(); } + public function hasRemoteId(): bool + { + return null !== $this->remote_id; + } + + public function getRemoteId(): ?string + { + return $this->remote_id; + } + + public function isOffline(): bool + { + return $this->method->getGateway()->isOffline(); + } + public function getPaymentId(): string { return $this->hash; diff --git a/Models/PaymentStatus.php b/Models/PaymentStatus.php index 49c3130..e1e57a6 100644 --- a/Models/PaymentStatus.php +++ b/Models/PaymentStatus.php @@ -27,6 +27,28 @@ * @method static PaymentStatus CANCELLED() * @method static PaymentStatus REFUNDED() * @method static PaymentStatus PARTIALLY_REFUNDED() + * + * @method bool isPending() + * @method bool isAuthorized() + * @method bool isOnHold() + * @method bool isPaid() + * @method bool isPartiallyPaid() + * @method bool isDeclined() + * @method bool isTimeout() + * @method bool isCancelled() + * @method bool isRefunded() + * @method bool isPartiallyRefunded() + * + * @property-read bool $is_pending + * @property-read bool $is_authorized + * @property-read bool $is_on_hold + * @property-read bool $is_paid + * @property-read bool $is_partially_paid + * @property-read bool $is_declined + * @property-read bool $is_timeout + * @property-read bool $is_cancelled + * @property-read bool $is_refunded + * @property-read bool $is_partially_refunded */ class PaymentStatus extends Enum implements PaymentStatusContract {