<?php

namespace Oney\ThreeByFour\Controller\Index;

use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;

/**
 * Payment Controller
 * 
 * Handles payment response display for Oney ThreeByFour module.
 * Retrieves and displays the Oney response from checkout session.
 * 
 * @package Oney\ThreeByFour\Controller\Index
 * @version 1.0.0
 * @author Oney
 * @since 1.0.0
 */
class Payment extends Action
{
    /**
     * Checkout session instance
     * 
     * @var Session
     * @version 1.0.0
     */
    protected $_checkoutSession;

    /**
     * Constructor
     * 
     * @param Context $context Action context
     * @param Session $checkoutSession Checkout session
     * @version 1.0.0
     */
    public function __construct(
        Context $context,
        Session $checkoutSession
    ) {
        $this->_checkoutSession = $checkoutSession;
        parent::__construct($context);
    }

    /**
     * Execute action
     * 
     * Retrieves and displays the Oney response from checkout session.
     * 
     * @return void
     * @version 1.0.0
     */
    public function execute(): void
    {
        $returned_url = $this->_checkoutSession->getData('oney_response', false);
        echo $returned_url;
    }
}
