public function getPaymentErrorMessage()
    {
        /** @var Payment $lastPayment */
        // Get the last payment
        if (!$lastPayment = $this->reservation->Payments()->first()) {
            return false;
        }

        // Find the gateway error
        $lastErrorMessage = null;
        $errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
        foreach ($errorMessages as $errorMessage) {
            if ($errorMessage instanceof GatewayErrorMessage) {
                $lastErrorMessage = $errorMessage;
                break;
            }
        }

        // If no error is found return
        if (!$lastErrorMessage) {
            return false;
        }

        return _t("{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}", $lastErrorMessage->Message);
    }
public function getPaymentErrorMessage()
    {
        /** @var Payment $lastPayment */
        // Get the last payment
        if (!$lastPayment = $this->reservation->Payments()->first()) {
            return false;
        }

        // Find the gateway error
        $lastErrorMessage = null;
        $errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
        foreach ($errorMessages as $errorMessage) {
            if ($errorMessage instanceof GatewayErrorMessage) {
                $lastErrorMessage = $errorMessage;
                break;
            }
        }

        // If no error is found return
        if (!$lastErrorMessage) {
            return false;
        }

        return _t("{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}", $lastErrorMessage->Message);
    }
public function getPaymentErrorMessage ( ) { /** @var Payment $lastPayment */ // Get the last payment if ( ! $ lastPayment = $ this -> reservation -> Payments ( ) -> first ( ) ) { return false ; } // Find the gateway error $ lastErrorMessage = null ; $ errorMessages = $ lastPayment -> Messages ( ) -> exclude ( 'Message' , '' ) -> sort ( 'Created' , 'DESC' ) ; foreach ( $ errorMessages as $ errorMessage ) { if ( $ errorMessage instanceof GatewayErrorMessage ) { $ lastErrorMessage = $ errorMessage ; break ; } } // If no error is found return if ( ! $ lastErrorMessage ) { return false ; } return _t ( "{$lastErrorMessage->Gateway}.{$lastErrorMessage->Code}" , $ lastErrorMessage -> Message ) ; }
Get the last error message from the payment attempts

@return bool|string
Get the last error message from the payment attempts