<?php
function onPaymentNotification(&$statuses)
{
$filter = JFilterInput::getInstance();
$dbOrder = $this->getOrder($_POST['trans_id']);
$this->loadPaymentParams($dbOrder);
if(empty($this->payment_params))
return false;
$this->loadOrderData($dbOrder);
if(empty($dbOrder))
{
echo 'Could not load any order for your notification ' . $_POST['trans_id'];
return false;
}
$order_id = $dbOrder->order_id;
$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));
$trans_id = isset($_POST['trans_id'])?$_POST['trans_id']:'';
$id_get = isset($_POST['id_get'])?$_POST['id_get']:'';
$api = $this->payment_params->api;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,'my bank url');
curl_setopt($ch,CURLOPT_POSTFIELDS,"api=$api&id_get=$id_get&trans_id=$trans_id");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$result = curl_exec($ch);
curl_close($ch);
if ($result == '') {
$order_status = $this->payment_params->pending_status;
$order_text = JText::sprintf('CHECK_DOCUMENTATION',HIKASHOP_HELPURL.'payment-MyBank-error#verify')."\r\n\r\n".$order_text;
} else {
if ($result == '1') {
echo 'MyBank transaction id: '.$_POST['trans_id'] . "\r\n\r\n";
$history = new stdClass();
$history->notified = 0;
$history->amount = round($dbOrder->order_full_price, (int)$this->currency->currency_locale['int_frac_digits']);
$history->data = ob_get_clean();
$order_status = $this->payment_params->verified_status;
if($dbOrder->order_status == $order_status)
return true;
$config =& hikashop_config();
if($config->get('order_confirmed_status', 'confirmed') == $order_status)
{
$history->notified = 1;
}
$email = new stdClass();
$email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER','MyBank',$order_status,$dbOrder->order_number);
$email->body = str_replace('<br/>',"\r\n",JText::sprintf('PAYMENT_NOTIFICATION_STATUS','MyBank',$order_status)).' '.JText::sprintf('ORDER_STATUS_CHANGED',$order_status)."\r\n\r\n".$order_text;
$this->modifyOrder($order_id, $order_status, $history, $email);
}else {
$order_status = $this->payment_params->invalid_status;
$email = new stdClass();
$email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER','MyBank').'invalid transaction';
$email->body = JText::sprintf("Hello,\r\n A MyBank notification was refused because it could not be verified by the MyBank server (or pay cenceled)")."\r\n\r\n".JText::sprintf('CHECK_DOCUMENTATION',HIKASHOP_HELPURL.'payment-MyBank-error#invalidtnx');
$action = false;
$this->modifyOrder($order_id, $order_status, null, $email);
}
}
header('location: ' . HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=order&task=after_end&order_id='.$order_id . $this->url_itemid );
exit;
}
?>
I checked my order report from backend and it's empty. Please help me thank you.