J2Store4 / j2store4

J2Store 4 - Open Source eCommerce extension for Joomla
https://www.j2store.org
GNU General Public License v3.0
15 stars 7 forks source link

Error JRequest #13

Closed mehdininja closed 1 year ago

mehdininja commented 1 year ago

hello This part of my plugin code does not work in Joomla 4. Please help to solve the problem

function _postPayment( $data ) { // Process the payment $paction = JRequest::getVar('paction');

    $vars = new JObject();

    switch ($paction)
    {
        case "display_message":
            $vars->message = JText::_('J2STORE_bank_MESSAGE_PAYMENT_ACCEPTED_FOR_VALIDATION');
            $html = $this->_getLayout('message', $vars);
            $html .= $this->_displayArticle();
          break;
        case "process":
            $vars->message = $this->_process();
            //$html = $this->_getLayout('message', $vars);
            //echo $html; // TODO Remove this
            //$app = JFactory::getApplication();
            //$app->close();
            if ($vars->message=='')
            {
                header('location: '. JURI::root()."index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=".$_REQUEST['orderpayment_type']."&paction=display_message");
                exit;die;
            }
            else
            {
                header('location: '. JURI::root()."index.php?option=com_j2store&view=checkout&task=confirmPayment&orderpayment_type=".$_REQUEST['orderpayment_type']."&paction=cancel");
                exit;die;
            }

          break;
        case "cancel":
            $vars->message = JText::_( 'J2STORE_bank_MESSAGE_CANCEL' );
            $html = $this->_getLayout('message', $vars);
          break;
        default:
            $vars->message = JText::_( 'J2STORE_bank_MESSAGE_INVALID_ACTION' );
            $html = $this->_getLayout('message', $vars);
          break;
    }

    return $html;
}
alagesanbe08 commented 1 year ago

In the realm of Joomla, the 'JRequest' class, once present and utilized in the second version, has been gracefully phased out. In the current iteration, the following enlightened code pattern finds its place

in latest,

    $app = \Joomla\CMS\Factory::getApplication();
    $paction = $app->input->getString('paction',''); 

For a deeper understanding, consider consulting the J2Store 4 PayPal plugin.