getWebAssetManager error in payment process.

  • Posts: 19
  • Thank you received: 0
2 years 5 months ago #336378

-- HikaShop version -- : 4.4.4
-- Joomla version -- : 4.0.3
-- PHP version -- : 7.4

Hi
I get the following error when I return from the payment gateway. It does not matter if the payment is successful or unsuccessful. In any case, after returning from the bank, I encounter the following error.
0 Call to a member function getWebAssetManager() on null

I have provided the details of the reporting error below:

Call stack
#	Function	Location
1	()	JROOT/libraries/src/HTML/Helpers/FormBehavior.php:97
2	Joomla\CMS\HTML\Helpers\FormBehavior::chosen()	JROOT/libraries/src/HTML/HTMLHelper.php:322
3	Joomla\CMS\HTML\HTMLHelper::call()	JROOT/libraries/src/HTML/HTMLHelper.php:154
4	Joomla\CMS\HTML\HTMLHelper::_()	JROOT/administrator/components/com_hikashop/helpers/helper.php:2558
5	hikashopView->display()	JROOT/components/com_hikashop/views/address/view.html.php:21
6	addressViewAddress->display()	JROOT/administrator/components/com_hikashop/helpers/helper.php:860
7	hikashop_getLayout()	JROOT/administrator/components/com_hikashop/classes/address.php:139
8	hikashopAddressClass->displayAddress()	JROOT/media/com_hikashop/mail/order_status_notification.preload.php:500
9	include()	JROOT/administrator/components/com_hikashop/classes/mail.php:360
10	hikashopMailClass->loadEmail()	JROOT/administrator/components/com_hikashop/classes/mail.php:31
11	hikashopMailClass->get()	JROOT/administrator/components/com_hikashop/classes/order.php:1966
12	hikashopOrderClass->loadOrderNotification()	JROOT/administrator/components/com_hikashop/classes/order.php:490

Thank you.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 5 months ago #336380

Hi,

This is kind of a bug in Joomla. Joomla is trying to use WebAssetManager before it has been loaded. Of course, I suppose that it's because HikaShop is asking for chosen to be loaded at a place where it can't be loaded. Ideally, Joomla should check that WebAssetManager has been loaded, if not, throw an Execption that the code calling would then be able to catch to handle the situation gracefully.
Now of course, we can also fix the issue by not loading chosen in your case as it's probably not needed there, when trying to send an email. However, as the call stack provided is only a piece of the full callstack and you didn't give the URL of the page where the error happens, I'm not sure of the situation you're in when the error happens so I can't write a condition to avoid loading chosen. Thus, I'll need more information from you.
Could you provide the rest of the call stack debug ?
Could you also provide the URL of the address bar on your browser when you get that error ?
Also, which payment plugin are you using ?

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
2 years 5 months ago #336381

hi
Thank you for your explanation. I attached the full image of the debug.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 5 months ago #336384

Hi,

Thanks !

Add the line:
$this->chosen = false;
after the line:
public function address_template() {
in the file components/com_hikashop/views/address/view.html.php and that will prevent the issue.
We'll add that patch on our end too.

The following user(s) said Thank You: farzadfarzad

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
2 years 5 months ago #336404

Hi
I made the changes you announced, but now I have the following error!

0
You have not supplied a valid HTTP status code

Thank you for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 5 months ago #336405

Hi,

This looks like an error linked to your payment plugin.
I would recommend to activate the error reporting and debug system settings of the Joomla configuration if that's not already the case and do a screenshot of the page with the URL in the address bar.
That might help us better understand the situation.

The following user(s) said Thank You: farzadfarzad

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
2 years 5 months ago #336410

hi
There is a problem returning from the payment gateway, which encounters this error. The error is related to the $ app-> redirect section.

		$url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order_id;
		$order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', $dbOrder->order_number, HIKASHOP_LIVE);
		$order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url));

        $saleCode = $_POST['SaleOrderId'];
        $ResCode = $_POST['ResCode']; 
        $trnsID = $_POST['SaleReferenceId'];
        
        $lalaPayment_Get = lalaPaymentHika::getLala($ResCode,$this->payment_params->terminal_id,$this->payment_params->terminal_un,$this->payment_params->terminal_pw,$saleCode,$trnsID);
        
        if($lalaPayment_Get[0]){
            
            
                    $order = new stdClass();
                    $order->order_id = $dbOrder->order_id;
                    $order->old_status->order_status=$dbOrder->order_status;
                    $url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='.$order->order_id;
                    $order_text = "\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',$dbOrder->order_number,HIKASHOP_LIVE);
                    $order_text .= "\r\n".str_replace('<br/>',"\r\n",JText::sprintf('ACCESS_ORDER_WITH_LINK',$url));
                    /////////////////
                /////////////
                    echo 'Transation success. trnsID:'. $trnsID . "\r\n\r\n";
                    
                    $mailer = JFactory::getMailer();
                    $config =& hikashop_config();
                    $sender = array(
                    $config->get('from_email'),
                    $config->get('from_name')
                    );
                    $mailer->setSender($sender);
                    $mailer->addRecipient(explode(',',$config->get('payment_notification_email')));
                    $order->order_status = 'confirmed';
                    $order->history->history_data = "Tracking Code:: ".$trnsID;
                    $order->history->history_reason = JText::_('OK');
                    $order->history->history_notified=1;
                    $order->history->history_payment_id = $element->payment_id;
                    $order->history->history_payment_method =$element->payment_type;
                    $order->history->history_type = 'payment';

                    $order_status =  $order->order_status;
                    $order->mail_status = $statuses[$order->order_status];
                    $mailer->setSubject(JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','Lala',$order->mail_status,$dbOrder->order_number));
                    $body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','Lala',$order->mail_status)).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order->mail_status).' '.JText::sprintf('Transaction Code',$trnsID)."\r\n\r\n".$order_text;
                    $mailer->setBody($body);
                    $mailer->Send();
                    $orderClass->save($order);
                    $order_num = $dbOrder->order_number;
      
                    $app =& JFactory::getApplication();
                    $httpsHikashop = HIKASHOP_LIVE;
                    $return_url = $httpsHikashop.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$orderid.$this->url_itemid;
                    $app->redirect($return_url,"Thank you. Your Transaction:: $trnsID Your Order:: $order_num");
                    return true;
            
        }else{
            
            $order = new stdClass();
            $order->order_id = $dbOrder->order_id;
            $order->old_status->order_status=$dbOrder->order_status;
            $url = HIKASHOP_LIVE.'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id='.$order->order_id;
            $order_text = "\r\n".JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE',$dbOrder->order_number,HIKASHOP_LIVE);
            $order_text .= "\r\n".str_replace('<br/>',"\r\n",JText::sprintf('ACCESS_ORDER_WITH_LINK',$url));
            /////////////////
            $mailer = JFactory::getMailer();
            $config =& hikashop_config();
            $sender = array(
            $config->get('from_email'),
            $config->get('from_name')
            );
            $order_num = $dbOrder->order_number;
            $mailer->setSender($sender);
            $mailer->addRecipient(explode(',',$config->get('payment_notification_email')));
            $order->order_status = 'cancelled';
            $order->history->history_data = "Your Payment $order_num Canceled";
            $order->history->history_reason = JText::_($lalaPayment_Get[1]);
            $order->history->history_notified=1;
            $order->history->history_payment_id = $element->payment_id;
            $order->history->history_payment_method =$element->payment_type;
            $order->history->history_type = 'payment';

            $order_status =  $order->order_status;
            $order->mail_status=$statuses[$order->order_status];
            $mailer->setSubject(JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','lala',$order->mail_status,$dbOrder->order_number));
            $body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','lala',$order->mail_status)).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order->mail_status)."\r\n\r\n".$order_text;
            $mailer->setBody($body);
            $mailer->Send();
            $orderClass->save($order);
            $app =& JFactory::getApplication();
            $httpsHikashop = HIKASHOP_LIVE;
            $return_url = HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id='.$orderid.$this->url_itemid;

            $app->redirect($return_url,$lalaPayment_Get[1]);
            return false;
            
        }
        

	}
thank you.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13037
  • MODERATOR
2 years 5 months ago #336415

Hi,

The issue comes from the two calls to $app->redirect
On Joomla 4 you can't add the message to display as second parameter of the redirect function call as it now expects a HTTP status code instead.
So instead:

$app->redirect($return_url,$lalaPayment_Get[1]);
you should have:
$app->enqueueMessage($lalaPayment_Get[1]);
$app->redirect($return_url);
and it will work on both Joomla 3 and Joomla 4.
I recommend you report this to the developer of your payment plugin.

The following user(s) said Thank You: farzadfarzad

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum