<?php
namespace Webkul\MpPayPal\Controller\Order;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Customer\Model\Session;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\Request\InvalidRequestException;

class Cancel extends Action implements CsrfAwareActionInterface
{

    protected $_publicActions = ['cancel'];

    public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
    {
        return null;
    }

    public function validateForCsrf(RequestInterface $request): ?bool
    {
        return true;
    }

    public function execute()
    {
        $this->messageManager->addError(__('Payment Cancelled by Customer'));
        /** @var \Magento\Framework\View\Result\Page $resultPage */
        $resultPage = $this->resultRedirectFactory->create();
        $resultPage->setPath('checkout/cart', ['_current' => true]);
        return $resultPage;
    }
}
