Hi,
I am using Opencart 2.2.0.0. Full error is:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access protected method ControllerPaymentMobileMoney::index() in C:\wamp\www\opencart\system\engine\action.php on line 44
My controller code is
Code: Select all
<?php
class ControllerPaymentMobileMoney extends Controller {
protected function index() {
$this->load->language('payment/mobile_money');
$data['button_confirm'] = $this->language->get('button_confirm');
$data['action'] = "localhost/payments_test/process.php";
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
if ($order_info) {
$data['text_config_one'] = trim($this->config->get('text_config_one'));
$data['text_config_two'] = trim($this->config->get('text_config_two'));
$data['orderid'] = date('His') . $this->session->data['order_id'];
$data['callbackurl'] = $this->url->link('payment/mobile_money/callback');
$data['orderdate'] = date('YmdHis');
$data['currency'] = $order_info['currency_code'];
$data['orderamount'] = $this->currency->format($order_info['total'], $this->data['currency'] , false, false);
$data['billemail'] = $order_info['email'];
$data['billphone'] = html_entity_decode($order_info['telephone'], ENT_QUOTES, 'UTF-8');
$data['billaddress'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8');
$data['billcountry'] = html_entity_decode($order_info['payment_iso_code_2'], ENT_QUOTES, 'UTF-8');
$data['billprovince'] = html_entity_decode($order_info['payment_zone'], ENT_QUOTES, 'UTF-8');;
$data['billcity'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8');
$data['billpost'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8');
$data['deliveryname'] = html_entity_decode($order_info['shipping_firstname'] . $order_info['shipping_lastname'], ENT_QUOTES, 'UTF-8');
$data['deliveryaddress'] = html_entity_decode($order_info['shipping_address_1'], ENT_QUOTES, 'UTF-8');
$data['deliverycity'] = html_entity_decode($order_info['shipping_city'], ENT_QUOTES, 'UTF-8');
$data['deliverycountry'] = html_entity_decode($order_info['shipping_iso_code_2'], ENT_QUOTES, 'UTF-8');
$data['deliveryprovince'] = html_entity_decode($order_info['shipping_zone'], ENT_QUOTES, 'UTF-8');
$data['deliveryemail'] = $order_info['email'];
$data['deliveryphone'] = html_entity_decode($order_info['telephone'], ENT_QUOTES, 'UTF-8');
$data['deliverypost'] = html_entity_decode($order_info['shipping_postcode'], ENT_QUOTES, 'UTF-8');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mobile_money.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/payment/mobile_money.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/payment/mobile_money.tpl', $data));
}
}
}
public function callback() {
if (isset($this->request->post['orderid'])) {
$order_id = trim(substr(($this->request->post['orderid']), 6));
} else {
die('Illegal Access');
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$data = array_merge($this->request->post,$this->request->get);
$curl = curl_init( "localhost/payments_test/process.php");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$feedback = curl_exec($curl);
if(!$response)
{
/* ERROR MESSAGE*/
}
else{
if (isset($this->request->post['payment_status'])) {
$order_status_id = $this->config->get('config_order_status_id');
switch($this->request->post['payment_status']) {
case 'SUCCESSFUL':
$order_status_id = $this->config->get('pp_standard_refunded_status_id');
break;
case 'UNSCUCCESSFUL':
$order_status_id = $this->config->get('pp_standard_reversed_status_id');
break;
}
$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
}else {
$this->model_checkout_order->addOrderHistory($order_id, $this->config->get('config_order_status_id'));
}
curl_close($curl);
}
}
}
}
?>