cancel
Showing results for 
Search instead for 
Did you mean: 

Page Blank on module controller

Page Blank on module controller

I'm developing a payment form to magento2, everything works except controllers return me a blank page; I followed several guides were saying the same thing but I did not reach any results.

Routes XML:

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="cartasixpay" frontName="cartasixpay">
            <module name="CartaSi_XPay" />
        </route>
    </router>
</config>

 

Controller file Annullo.php in app/code/CartaSi/XPay/Controller/Payment:

<?php

namespace CartaSi\XPay\Controller\Payment; 

use Magento\Framework\Controller\ResultFactory;

class Annullo extends \Magento\Framework\App\Action\Action
{
    /**
     * Customer session model
     *
     * @var \Magento\Customer\Model\Session
     */
    protected $_customerSession;
    protected $resultPageFactory;
    protected $checkoutSession;
    protected $orderRepository;

    /**
     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Customer\Model\Session $customerSession
     */
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
        \Magento\Checkout\Model\Session $checkoutSession
    ) {
        $this->_customerSession = $customerSession;
        $this->checkoutSession = $checkoutSession;
        $this->orderRepository = $orderRepository;
        parent::__construct($context);
    }

    public function execute()
    {
        $this->messageManager->addError(__('Payment has been cancelled.'));
        
        //change order status to cancel
        $order = $this->orderRepository->get($this->checkoutSession->getLastOrderId());
        if ($order) {
            $order->cancel();
            $order->addStatusToHistory(\Magento\Sales\Model\Order::STATE_CANCELED, __('Canceled by customer'));
            $order->save();
        }
        
        $resultRedirect = $this->resultRedirectFactory->create();
        $resultRedirect->setPath('checkout/cart');
        return $resultRedirect;
    }
}

calling the url HOSTNAME/cartasixpay/payment/annullo/ shows a blank page and nothing more.

In debug.log there:

main.DEBUG: cache_invalidate:  {"method":"GET","url":"https://magento-xpay.iplusservice.it/cartasixpay/payment/annullo/","invalidateInfo":{"tags":["interception","CONFIG"],"mode":"matchingTag"},"is_exception":false} []

thanks in advance

 

Filippo