DonationMetaKeys.php
2 years ago
DonationMode.php
3 years ago
DonationNoteMetaKeys.php
3 years ago
DonationNoteType.php
3 years ago
DonationStatus.php
3 years ago
DonationType.php
3 years ago
DonationStatus.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Donations\ValueObjects; |
| 4 | |
| 5 | use Give\Framework\Support\ValueObjects\Enum; |
| 6 | |
| 7 | /** |
| 8 | * @since 2.19.6 |
| 9 | * |
| 10 | * @method static DonationStatus PENDING() |
| 11 | * @method static DonationStatus COMPLETE() |
| 12 | * @method static DonationStatus REFUNDED() |
| 13 | * @method static DonationStatus FAILED() |
| 14 | * @method static DonationStatus CANCELLED() |
| 15 | * @method static DonationStatus ABANDONED() |
| 16 | * @method static DonationStatus PREAPPROVAL() |
| 17 | * @method static DonationStatus PROCESSING() |
| 18 | * @method static DonationStatus REVOKED() |
| 19 | * @method static DonationStatus RENEWAL() @deprecated |
| 20 | * @method bool isPending() |
| 21 | * @method bool isComplete() |
| 22 | * @method bool isRefunded() |
| 23 | * @method bool isFailed() |
| 24 | * @method bool isCancelled() |
| 25 | * @method bool isAbandoned() |
| 26 | * @method bool isPreapproval() |
| 27 | * @method bool isProcessing() |
| 28 | * @method bool isRevoked() |
| 29 | * @method bool isRenewal() @deprecated Do not use this. Instead, set the donation type to "renewal" and use COMPLETE status. |
| 30 | */ |
| 31 | class DonationStatus extends Enum |
| 32 | { |
| 33 | const PENDING = 'pending'; |
| 34 | const PROCESSING = 'processing'; |
| 35 | const COMPLETE = 'publish'; |
| 36 | const REFUNDED = 'refunded'; |
| 37 | const FAILED = 'failed'; |
| 38 | const CANCELLED = 'cancelled'; |
| 39 | const ABANDONED = 'abandoned'; |
| 40 | const PREAPPROVAL = 'preapproval'; |
| 41 | const REVOKED = 'revoked'; |
| 42 | |
| 43 | /** |
| 44 | * @deprecated 2.23.0 Use DonationStatus::COMPLETE |
| 45 | */ |
| 46 | const RENEWAL = 'give_subscription'; |
| 47 | |
| 48 | /** |
| 49 | * @since 2.24.0 |
| 50 | * |
| 51 | * @return array |
| 52 | */ |
| 53 | public static function labels(): array |
| 54 | { |
| 55 | return [ |
| 56 | self::PENDING => __('Pending', 'give'), |
| 57 | self::PROCESSING => __('Processing', 'give'), |
| 58 | self::COMPLETE => __('Completed', 'give'), |
| 59 | self::REFUNDED => __('Refunded', 'give'), |
| 60 | self::FAILED => __('Failed', 'give'), |
| 61 | self::CANCELLED => __('Cancelled', 'give'), |
| 62 | self::ABANDONED => __('Abandoned', 'give'), |
| 63 | self::PREAPPROVAL => __('Preapproval', 'give'), |
| 64 | self::REVOKED => __('Revoked', 'give'), |
| 65 | self::RENEWAL => __('Renewal', 'give'), |
| 66 | ]; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @since 2.24.0 |
| 71 | * |
| 72 | * @return string |
| 73 | */ |
| 74 | public function label(): string |
| 75 | { |
| 76 | return self::labels()[ $this->getValue() ]; |
| 77 | } |
| 78 | } |
| 79 |