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