Payment notification does not work with CBuilder

  • Posts: 22
  • Thank you received: 3
12 years 2 months ago #61902

I'm not sure why and I'm hoping that someone can help me.

With our site, we've been working with our payment provider to create a plugin for HikaSHop which is now complete.

For some reason though, the return nnotifications from the provider are not working on the site.

I've tested this on a "clean" site and it seemed to work ok, which I cant explain...

$pluginsClass = hikashop_get('class.plugins');
		$ppages = new HikashopPPages();
		
		$elements = $pluginsClass->getMethods('payment','securetradingppages');
		
		if(empty($elements) || !isset($elements[1])) {
			$ppages->createException(new Exception('The payment module class could not be retrieved correctly.'), __FILE__, __CLASS__, __LINE__);
		}
		
		$filter = &JFilterInput::getInstance();
		$paymentMethod = $elements[1];
		$postVars = array();
		
		foreach($_POST as $key => $value){
			$key = $filter->clean($key);
			$value = JRequest::getString($key);
			$postVars[$key]=$value;
		}
		
		if (!isset($postVars['errorcode'])) {
			$ppages->createException(new Exception('The errorcode has not been set.'), __FILE__, __CLASS__, __LINE__);
		}
		
		if (!isset($postVars['orderreference'])) {
			$ppages->createException(new Exception('The orderreference has not been set.'), __FILE__, __CLASS__, __LINE__);
		}
		
		if ($paymentMethod->payment_params->usenotificationhash && !isset($postVars['responsesitesecurity'])) {
			$ppages->createException(new Exception('The notification hash is enabled but the reponsesitesecurity was not posted to the notification script.'), __FILE__, __CLASS__, __LINE__);
		}
		
		if (isset($postVars['responsesitesecurity']) && $postVars['responsesitesecurity'] !== hash('sha256', $postVars['errorcode'] . $postVars['orderreference'] . $paymentMethod->payment_params->notificationhash)) {
			$ppages->createException(new Exception('The notification hash is enabled but the responsesitesecurity field did not match the regenerated hash.'), __FILE__, __CLASS__, __LINE__);
		}
		
		$orderClass = hikashop_get('class.order');
		$dbOrder = $orderClass->get($postVars['orderreference']);
		
		if(empty($dbOrder)){
			$ppages->createException(new Exception('Could not load order using orderreference: ' . $postVars['orderreference']), __FILE__, __CLASS__, __LINE__);
		}
		
		$order = NULL;
		$order->order_id = $dbOrder->order_id;
		$order->old_status->order_status=$dbOrder->order_status;
		
		if ($postVars['errorcode'] == 0) {
			$order->order_status = $paymentMethod->payment_params->verified_status;
		}
		else {
			$order->order_status = $paymentMethod->payment_params->invalid_status;
		}
		
		$order->history->history_notified = 1;
		$orderClass->save($order);
		
		exit('Notification Complete.');

Last edit: 12 years 2 months ago by philgsy.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
12 years 2 months ago #62006

Hi,

In which function does your code source came from ?
Does the notification url is right ?
Are you sure that the notification is called ?
What's "HikashopPPages" ? Does it right included and defined ?
Do you check your PHP log file ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.058 seconds
Powered by Kunena Forum