src/Page/CheckoutPageController.php
public function PaymentErrorMessage()
    {
        $order = $this->Cart();
        if (!$order) {
            return false;
        }

        $lastPayment = $order->Payments()->sort('Created', 'DESC')->first();
        if (!$lastPayment) {
            return false;
        }

        $errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
        $lastErrorMessage = null;
        foreach ($errorMessages as $errorMessage) {
            if ($errorMessage instanceof GatewayErrorMessage) {
                $lastErrorMessage = $errorMessage;
                break;
            }
        }
        if (!$lastErrorMessage) {
            return false;
        }

        return $lastErrorMessage->Message;
    }
public function PaymentErrorMessage()
    {
        $order = $this->Cart();
        if (!$order) {
            return false;
        }

        $lastPayment = $order->Payments()->sort('Created', 'DESC')->first();
        if (!$lastPayment) {
            return false;
        }

        $errorMessages = $lastPayment->Messages()->exclude('Message', '')->sort('Created', 'DESC');
        $lastErrorMessage = null;
        foreach ($errorMessages as $errorMessage) {
            if ($errorMessage instanceof GatewayErrorMessage) {
                $lastErrorMessage = $errorMessage;
                break;
            }
        }
        if (!$lastErrorMessage) {
            return false;
        }

        return $lastErrorMessage->Message;
    }
Retrieves error messages for the latest payment (if existing).
This can originate e.g. from an earlier offsite gateway API response.

@return string