Payment/Model/PaymentTransitions.php
static function getAvailableTransitions(PaymentInterface $payment, $admin = false)
    {
        // TODO use payum to select gateway's supported requests/actions.

        $transitions = [];

        $method = $payment->getMethod();
        $state = $payment->getState();

        if ($admin) {
            if ($method->isManual()) {
                switch ($state) {
                    case PaymentStates::STATE_PENDING:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                    case PaymentStates::STATE_CAPTURED:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_REFUND;
                        break;
                    case PaymentStates::STATE_REFUNDED:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                    case PaymentStates::STATE_CANCELED:
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                }
            } elseif ($method->isOutstanding() || $method->isManual()) {
                if ($state === PaymentStates::STATE_CAPTURED) {
                    $transitions[] = static::TRANSITION_CANCEL;
                } else {
                    $transitions[] = static::TRANSITION_ACCEPT;
                }
            } else {
                if ($state === PaymentStates::STATE_CAPTURED) {
                    $transitions[] = static::TRANSITION_REFUND;
                }
                if ($state === PaymentStates::STATE_PENDING) {
                    $diff = $payment->getUpdatedAt()->diff(new \DateTime());
                    if (0 < $diff->days && !$diff->invert) {
                        $transitions[] = static::TRANSITION_CANCEL;
                    }
                }
            }
        } else {
            if ($method->isManual() && $state === PaymentStates::STATE_PENDING) {
                $transitions[] = static::TRANSITION_CANCEL;
            }
        }

        return $transitions;
    }
static function getAvailableTransitions(PaymentInterface $payment, $admin = false)
    {
        // TODO use payum to select gateway's supported requests/actions.

        $transitions = [];

        $method = $payment->getMethod();
        $state = $payment->getState();

        if ($admin) {
            if ($method->isManual()) {
                switch ($state) {
                    case PaymentStates::STATE_PENDING:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                    case PaymentStates::STATE_CAPTURED:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_REFUND;
                        break;
                    case PaymentStates::STATE_REFUNDED:
                        $transitions[] = static::TRANSITION_CANCEL;
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                    case PaymentStates::STATE_CANCELED:
                        $transitions[] = static::TRANSITION_HANG;
                        $transitions[] = static::TRANSITION_ACCEPT;
                        break;
                }
            } elseif ($method->isOutstanding() || $method->isManual()) {
                if ($state === PaymentStates::STATE_CAPTURED) {
                    $transitions[] = static::TRANSITION_CANCEL;
                } else {
                    $transitions[] = static::TRANSITION_ACCEPT;
                }
            } else {
                if ($state === PaymentStates::STATE_CAPTURED) {
                    $transitions[] = static::TRANSITION_REFUND;
                }
                if ($state === PaymentStates::STATE_PENDING) {
                    $diff = $payment->getUpdatedAt()->diff(new \DateTime());
                    if (0 < $diff->days && !$diff->invert) {
                        $transitions[] = static::TRANSITION_CANCEL;
                    }
                }
            }
        } else {
            if ($method->isManual() && $state === PaymentStates::STATE_PENDING) {
                $transitions[] = static::TRANSITION_CANCEL;
            }
        }

        return $transitions;
    }
static function getAvailableTransitions ( PaymentInterface $ payment , $ admin = false ) { // TODO use payum to select gateway's supported requests/actions. $ transitions = [ ] ; $ method = $ payment -> getMethod ( ) ; $ state = $ payment -> getState ( ) ; if ( $ admin ) { if ( $ method -> isManual ( ) ) { switch ( $ state ) { case PaymentStates :: STATE_PENDING : $ transitions [ ] = static :: TRANSITION_CANCEL ; $ transitions [ ] = static :: TRANSITION_ACCEPT ; break ; case PaymentStates :: STATE_CAPTURED : $ transitions [ ] = static :: TRANSITION_CANCEL ; $ transitions [ ] = static :: TRANSITION_HANG ; $ transitions [ ] = static :: TRANSITION_REFUND ; break ; case PaymentStates :: STATE_REFUNDED : $ transitions [ ] = static :: TRANSITION_CANCEL ; $ transitions [ ] = static :: TRANSITION_HANG ; $ transitions [ ] = static :: TRANSITION_ACCEPT ; break ; case PaymentStates :: STATE_CANCELED : $ transitions [ ] = static :: TRANSITION_HANG ; $ transitions [ ] = static :: TRANSITION_ACCEPT ; break ; } } elseif ( $ method -> isOutstanding ( ) || $ method -> isManual ( ) ) { if ( $ state === PaymentStates :: STATE_CAPTURED ) { $ transitions [ ] = static :: TRANSITION_CANCEL ; } else { $ transitions [ ] = static :: TRANSITION_ACCEPT ; } } else { if ( $ state === PaymentStates :: STATE_CAPTURED ) { $ transitions [ ] = static :: TRANSITION_REFUND ; } if ( $ state === PaymentStates :: STATE_PENDING ) { $ diff = $ payment -> getUpdatedAt ( ) -> diff ( new \ DateTime ( ) ) ; if ( 0 < $ diff -> days && ! $ diff -> invert ) { $ transitions [ ] = static :: TRANSITION_CANCEL ; } } } } else { if ( $ method -> isManual ( ) && $ state === PaymentStates :: STATE_PENDING ) { $ transitions [ ] = static :: TRANSITION_CANCEL ; } } return $ transitions ; }
Returns the available payment transitions.

@param PaymentInterface $payment
@param bool             $admin

@return array
Returns the available payment transitions .