# give/4.18.0/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 50 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php
- Modified: 2025-07-09T13:09:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php#L10-L20`.

```php
<?php

namespace Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions;

use Give\Donations\ValueObjects\DonationStatus;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationAbandoned;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationCancelled;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationCompleted;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationFailed;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationPending;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationPreapproval;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationProcessing;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRefunded;
use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRevoked;

/**
 * @since 4.5.0
 */
class GetEventHandlerClassByDonationStatus
{
    /**
     * @since 4.5.0
     */
    public function __invoke(DonationStatus $status): string
    {
        switch ($status) {
            case $status->isAbandoned():
                return DonationAbandoned::class;
            case $status->isCancelled():
                return DonationCancelled::class;
            case $status->isComplete():
                return DonationCompleted::class;
            case $status->isFailed():
                return DonationFailed::class;
            case $status->isPending():
                return DonationPending::class;
            case $status->isPreapproval():
                return DonationPreapproval::class;
            case $status->isProcessing():
                return DonationProcessing::class;
            case $status->isRefunded():
                return DonationRefunded::class;
            case $status->isRevoked():
                return DonationRevoked::class;
            default:
                return '';
        }
    }
}

```
