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.');