<?php

namespace Magento\Billdesk\Controller\Payment;

use Magento\Framework\View\Result\PageFactory;
use Magento\Billdesk\Model\Config;
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Request\InvalidRequestException;

class BilldeskAutoclose extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
// class BilldeskAutoclose extends \Magento\Billdesk\Controller\BaseControllerBD
{
    protected $_pageFactory;
    protected $_config;
    protected $checkoutSession;
    protected $customerSession;
    protected $_directory;
    protected $log;

    public function __construct(
        Context $context,
        PageFactory $pageFactory,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Checkout\Model\Session $checkoutSession
    ) {
        parent::__construct($context);
        $this->_pageFactory = $pageFactory;
        $this->checkoutSession = $checkoutSession;
        $this->customerSession = $customerSession;
        $this->_directory = \Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\Filesystem\DirectoryList');
        $this->log = new \Monolog\Logger('name');
        $this->log->pushHandler(new \Monolog\Handler\StreamHandler($this->_directory->getPath('log') . '/BillDesk/magento_billdesk_' . Date('Y_m_d') . '.log'));
    }
    public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
    {
        return null;
    }

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

        <head>
            <script>
                function closeWindow() {
                    window.close();
                }
            </script>
        </head>

        <body onload="closeWindow()">
        </body>

        </html>
<?php

    }
}
