public function execute()
    {

        $this->_orderFactory = $this->_objectManager->get('\Magento\Sales\Model\OrderFactory');
        $this->_checkoutSession = $this->_objectManager->get('\Magento\Checkout\Model\Session');
        /** @var \Magento\Sales\Model\Order $order */
        $order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load(
            $this->_checkoutSession->getLastRealOrderId());

        /** change payment status in magento */
        $order->addStatusToHistory('pagseguro_cancelada', null, true);
        /** save order */
        $order->save();

        return $this->_redirect('/');

    }
public function execute()
    {

        $this->_orderFactory = $this->_objectManager->get('\Magento\Sales\Model\OrderFactory');
        $this->_checkoutSession = $this->_objectManager->get('\Magento\Checkout\Model\Session');
        /** @var \Magento\Sales\Model\Order $order */
        $order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load(
            $this->_checkoutSession->getLastRealOrderId());

        /** change payment status in magento */
        $order->addStatusToHistory('pagseguro_cancelada', null, true);
        /** save order */
        $order->save();

        return $this->_redirect('/');

    }
public function execute ( ) { $ this -> _orderFactory = $ this -> _objectManager -> get ( '\Magento\Sales\Model\OrderFactory' ) ; $ this -> _checkoutSession = $ this -> _objectManager -> get ( '\Magento\Checkout\Model\Session' ) ; /** @var \Magento\Sales\Model\Order $order */ $ order = $ this -> _objectManager -> create ( '\Magento\Sales\Model\Order' ) -> load ( $ this -> _checkoutSession -> getLastRealOrderId ( ) ) ; /** change payment status in magento */ $ order -> addStatusToHistory ( 'pagseguro_cancelada' , null , true ) ; /** save order */ $ order -> save ( ) ; return $ this -> _redirect ( '/' ) ; }
Show cancel page

@return \Magento\Framework\View\Result\PageFactory
Show cancel page