How can I print a message from onPaymentNotificati

  • Posts: 4
  • Thank you received: 0
8 years 2 months ago #249535

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.6.2
-- Browser(s) name and version -- : Firefox 48.0.2
-- Error-message(debug-mod must be tuned on) -- : None

As a requirement of a custom payment plugin I am develping for Hikahop, I need to print a message from onPaymentNotification function to the default cancel url.
I placed the following code in the onPaymentNotification function of Hikashop. The codes in the two conditions work fine as required, but the echoed message in line 15 does not display of the cancel_url when condition for cancel is met. I am using the defualt cancel url as shown in line 15

if ($Response_Code==="00")
{
	if ($Amount==$amt)
	{
		$this->modifyOrder($order_id, $this->payment_params->verified_status, true, true);
		$this->app->redirect($return_url);
		return true;
	}
}
elseif ($Response_Code!=="00")
{
	//This function modifies the order with the id $order_id, to attribute it the status invalid_status.
	$this->modifyOrder($order_id, $this->payment_params->invalid_status, true, true); 
	echo "The response code is: ".$Response_Code;
	$this->app->redirect($cancel_url); // $cancel_url = HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id='.$order_id.$this->url_itemid;
	return false;			
}

Last edit: 8 years 2 months ago by Jerome. Reason: [code] is nice

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

  • Posts: 82864
  • Thank you received: 13372
  • MODERATOR
8 years 2 months ago #249548

Hi,

I see two issues with your code:
1. You do a redirect after displaying the message. So even though that message is added to the display buffer of PHP, the buffer is dumped by PHP when it does the redirect. Thus, it's normal nothing is displayed.
2. The onPaymentNotification function's displayed elements are automatically retrieved from the display buffer and stored in the payment log file (that you can access in the HikaShop configuration) when the onPaymentNotification function returns, so even if you remove the redirect, your message would only go in the payment log file. You would have to create a new buffer with the ob_start(); function before returning.
3. The onPaymentNotification function is usually called by the payment gateway, and in that case what you'll display in it will returned to the payment gateway, not the customer, and thus he won't see the message. That however, is not always the case (even thought it is for most payment gateways).

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

Time to create page: 0.056 seconds
Powered by Kunena Forum