<?php
 
 
 

namespace PhpWA\Protocol\Proto\PaymentInfo;

use UnexpectedValueException;




class TxnStatus
{
    


    const UNKNOWN = 0;
    


    const PENDING_SETUP = 1;
    


    const PENDING_RECEIVER_SETUP = 2;
    


    const INIT = 3;
    


    const SUCCESS = 4;
    


    const COMPLETED = 5;
    


    const FAILED = 6;
    


    const FAILED_RISK = 7;
    


    const FAILED_PROCESSING = 8;
    


    const FAILED_RECEIVER_PROCESSING = 9;
    


    const FAILED_DA = 10;
    


    const FAILED_DA_FINAL = 11;
    


    const REFUNDED_TXN = 12;
    


    const REFUND_FAILED = 13;
    


    const REFUND_FAILED_PROCESSING = 14;
    


    const REFUND_FAILED_DA = 15;
    


    const EXPIRED_TXN = 16;
    


    const AUTH_CANCELED = 17;
    


    const AUTH_CANCEL_FAILED_PROCESSING = 18;
    


    const AUTH_CANCEL_FAILED = 19;
    


    const COLLECT_INIT = 20;
    


    const COLLECT_SUCCESS = 21;
    


    const COLLECT_FAILED = 22;
    


    const COLLECT_FAILED_RISK = 23;
    


    const COLLECT_REJECTED = 24;
    


    const COLLECT_EXPIRED = 25;
    


    const COLLECT_CANCELED = 26;
    


    const COLLECT_CANCELLING = 27;
    


    const IN_REVIEW = 28;
    


    const REVERSAL_SUCCESS = 29;
    


    const REVERSAL_PENDING = 30;
    


    const REFUND_PENDING = 31;

    private static $valueToName = [
        self::UNKNOWN => 'UNKNOWN',
        self::PENDING_SETUP => 'PENDING_SETUP',
        self::PENDING_RECEIVER_SETUP => 'PENDING_RECEIVER_SETUP',
        self::INIT => 'INIT',
        self::SUCCESS => 'SUCCESS',
        self::COMPLETED => 'COMPLETED',
        self::FAILED => 'FAILED',
        self::FAILED_RISK => 'FAILED_RISK',
        self::FAILED_PROCESSING => 'FAILED_PROCESSING',
        self::FAILED_RECEIVER_PROCESSING => 'FAILED_RECEIVER_PROCESSING',
        self::FAILED_DA => 'FAILED_DA',
        self::FAILED_DA_FINAL => 'FAILED_DA_FINAL',
        self::REFUNDED_TXN => 'REFUNDED_TXN',
        self::REFUND_FAILED => 'REFUND_FAILED',
        self::REFUND_FAILED_PROCESSING => 'REFUND_FAILED_PROCESSING',
        self::REFUND_FAILED_DA => 'REFUND_FAILED_DA',
        self::EXPIRED_TXN => 'EXPIRED_TXN',
        self::AUTH_CANCELED => 'AUTH_CANCELED',
        self::AUTH_CANCEL_FAILED_PROCESSING => 'AUTH_CANCEL_FAILED_PROCESSING',
        self::AUTH_CANCEL_FAILED => 'AUTH_CANCEL_FAILED',
        self::COLLECT_INIT => 'COLLECT_INIT',
        self::COLLECT_SUCCESS => 'COLLECT_SUCCESS',
        self::COLLECT_FAILED => 'COLLECT_FAILED',
        self::COLLECT_FAILED_RISK => 'COLLECT_FAILED_RISK',
        self::COLLECT_REJECTED => 'COLLECT_REJECTED',
        self::COLLECT_EXPIRED => 'COLLECT_EXPIRED',
        self::COLLECT_CANCELED => 'COLLECT_CANCELED',
        self::COLLECT_CANCELLING => 'COLLECT_CANCELLING',
        self::IN_REVIEW => 'IN_REVIEW',
        self::REVERSAL_SUCCESS => 'REVERSAL_SUCCESS',
        self::REVERSAL_PENDING => 'REVERSAL_PENDING',
        self::REFUND_PENDING => 'REFUND_PENDING',
    ];

    public static function name($value)
    {
        if (!isset(self::$valueToName[$value])) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no name defined for value %s', __CLASS__, $value));
        }
        return self::$valueToName[$value];
    }


    public static function value($name)
    {
        $const = __CLASS__ . '::' . strtoupper($name);
        if (!defined($const)) {
            throw new UnexpectedValueException(sprintf(
                    'Enum %s has no value defined for name %s', __CLASS__, $name));
        }
        return constant($const);
    }
}

