Jahswey
Jahswey

Reputation: 11

error Call to undefined method ControllerPaymentStanbic:: render() in Payment plugin

I've set up this module for a payment gateway on opencart but i got this error which i changed $this->data to $data, I get a blank page. If i change it back to $this->data i get this error http://prntscr.com/832nd2

here is the code

                        <?php 
            class ControllerPaymentCipgSim extends Controller {
              private $error = array(); 
              public function index() { 
                $this->load->language('payment/cipg_sim');
                $this->data['heading_title'] = $this->language->get('heading_title');
                $this->load->model('setting/setting');
                if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validate())) {
                  $this->load->model('setting/setting');
                  $this->model_setting_setting->editSetting('cipg_sim', $this->request->post);
                  $this->session->data['success'] = $this->language->get('text_success');
                  $this->redirect(HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token']);
                }
                $this->data['heading_title']     = $this->language->get('heading_title');
                $this->data['text_enabled']     = $this->language->get('text_enabled');
                $this->data['text_disabled']     = $this->language->get('text_disabled');
                $this->data['text_all_zones']     = $this->language->get('text_all_zones');
                $this->data['text_yes']       = $this->language->get('text_yes');
                $this->data['text_no']         = $this->language->get('text_no');
                $this->data['text_test']       = $this->language->get('text_test');
                $this->data['text_live']       = $this->language->get('text_live');
                $this->data['button_save']       = $this->language->get('button_save');
                $this->data['button_cancel']     = $this->language->get('button_cancel');
                $this->data['tab_general']       = $this->language->get('tab_general');
                $this->data['get_from_aznet']     = $this->language->get('text_get_from_aznet');
                $this->data['set_at_aznet']     = $this->language->get('text_set_at_aznet');
                $this->data['optional_aznet']     = $this->language->get('text_optional_aznet');
                $this->data['text_min_amount']    = $this->language->get('text_min_amount');
                $this->data['text_order_status']  = $this->language->get('text_order_status');
                $this->data['text_custom_html']    = $this->language->get('text_custom_html');
                $this->data['text_custom_html_help']= $this->language->get('text_custom_html_help');
                $this->data['entry_status']     = $this->language->get('entry_status');
                $this->data['entry_login_id']     = $this->language->get('entry_login_id');
                $this->data['entry_transaction_key']= $this->language->get('entry_transaction_key');
                $this->data['entry_response_key']   = $this->language->get('entry_response_key');
                $this->data['entry_minimum_amt']   = $this->language->get('entry_minimum_amt');
                $this->data['entry_server']     = $this->language->get('entry_server');
                $this->data['entry_test']       = $this->language->get('entry_test');
                $this->data['entry_geo_zone']     = $this->language->get('entry_geo_zone');
                $this->data['entry_order_status']   = $this->language->get('entry_order_status');
                $this->data['entry_sort_order']   = $this->language->get('entry_sort_order');
                $this->data['entry_custom_header']   = $this->language->get('entry_custom_header');
                $this->data['entry_custom_footer']   = $this->language->get('entry_custom_footer');
                $this->load->model('localisation/order_status');
                $this->data['order_statuses']     = $this->model_localisation_order_status->getOrderStatuses();
                $this->load->model('localisation/geo_zone');
                $this->data['geo_zones']       = $this->model_localisation_geo_zone->getGeoZones();

                if (isset($this->request->post['cipg_sim_login_id'])) {
                  $this->data['cipg_sim_login_id'] = $this->request->post['cipg_sim_login_id'];
                } else {
                  $this->data['cipg_sim_login_id'] = $this->config->get('cipg_sim_login_id');
                }

                if (isset($this->request->post['cipg_sim_transaction_key'])) {
                  $this->data['cipg_sim_transaction_key'] = $this->request->post['cipg_sim_transaction_key'];
                } else {
                  $this->data['cipg_sim_transaction_key'] = $this->config->get('cipg_sim_transaction_key');
                }

                if (isset($this->request->post['cipg_sim_response_key'])) {
                  $this->data['cipg_sim_response_key'] = $this->request->post['cipg_sim_response_key'];
                } else {
                  $this->data['cipg_sim_response_key'] = $this->config->get('cipg_sim_response_key');
                }

                if (isset($this->request->post['cipg_sim_total'])) {
                  $this->data['cipg_sim_total'] = $this->request->post['cipg_sim_total'];
                } else {
                  $this->data['cipg_sim_total'] = $this->config->get('cipg_sim_total'); 
                }

                if (isset($this->request->post['cipg_sim_server'])) {
                  $this->data['cipg_sim_server'] = $this->request->post['cipg_sim_server'];
                } else {
                  $this->data['cipg_sim_server'] = $this->config->get('cipg_sim_server');
                }

                if (isset($this->request->post['cipg_sim_test'])) {
                  $this->data['cipg_sim_test'] = $this->request->post['cipg_sim_test'];
                } else {
                  $this->data['cipg_sim_test'] = $this->config->get('cipg_sim_test');
                }

                if (isset($this->request->post['cipg_sim_status'])) {
                  $this->data['cipg_sim_status'] = $this->request->post['cipg_sim_status'];
                } else {
                  $this->data['cipg_sim_status'] = $this->config->get('cipg_sim_status');
                }

                if (isset($this->request->post['cipg_sim_geo_zone_id'])) {
                  $this->data['cipg_sim_geo_zone_id'] = $this->request->post['cipg_sim_geo_zone_id'];
                } else {
                  $this->data['cipg_sim_geo_zone_id'] = $this->config->get('cipg_sim_geo_zone_id'); 
                } 

                if (isset($this->request->post['cipg_sim_sort_order'])) {
                  $this->data['cipg_sim_sort_order'] = $this->request->post['cipg_sim_sort_order'];
                } else {
                  $this->data['cipg_sim_sort_order'] = $this->config->get('cipg_sim_sort_order'); 
                } 

                if (isset($this->request->post['cipg_sim_order_status_id'])) {
                  $this->data['cipg_sim_order_status_id'] = $this->request->post['cipg_sim_order_status_id'];
                } else {
                  $this->data['cipg_sim_order_status_id'] = $this->config->get('cipg_sim_order_status_id'); 
                } 

                if (isset($this->request->post['cipg_sim_custom_header'])) {
                  $this->data['cipg_sim_custom_header'] = $this->request->post['cipg_sim_custom_header'];
                } else {
                  $this->data['cipg_sim_custom_header'] = $this->config->get('cipg_sim_custom_header'); 
                } 

                if (isset($this->request->post['cipg_sim_custom_footer'])) {
                  $this->data['cipg_sim_custom_footer'] = $this->request->post['cipg_sim_custom_footer'];
                } else {
                  $this->data['cipg_sim_custom_footer'] = $this->config->get('cipg_sim_custom_footer'); 
                } 

                if (isset($this->error['warning'])) {
                  $this->data['error_warning'] = $this->error['warning'];
                } else {
                  $this->data['error_warning'] = '';
                }

                  if (isset($this->error['login_id'])) {
                  $this->data['error_login_id'] = $this->error['login_id'];
                } else {
                  $this->data['error_login_id'] = '';
                }

                if (isset($this->error['transaction_key'])) {
                  $this->data['error_transaction_key'] = $this->error['transaction_key'];
                } else {
                  $this->data['error_transaction_key'] = '';
                }

                if (isset($this->error['response_key'])) {
                  $this->data['error_response_key'] = $this->error['response_key'];
                } else {
                  $this->data['error_response_key'] = '';
                }

                  $this->data['breadcrumbs'] = array();
                   $this->data['breadcrumbs'][] = array(
                       'text'      => $this->language->get('text_home'),
                  'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
                      'separator' => false
                   );
                   $this->data['breadcrumbs'][] = array(
                       'text'      => $this->language->get('text_payment'),
                  'href'      => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
                      'separator' => ' :: '
                   );
                   $this->data['breadcrumbs'][] = array(
                       'text'      => $this->language->get('heading_title'),
                  'href'      => $this->url->link('payment/cipg_sim', 'token=' . $this->session->data['token'], 'SSL'),
                      'separator' => ' :: '
                   );
                $this->data['action'] = HTTPS_SERVER .'index.php?route=payment/cipg_sim&token=' . $this->session->data['token'];
                $this->data['cancel'] = HTTPS_SERVER .'index.php?route=extension/payment&token=' . $this->session->data['token'];  
                $this->template = 'payment/cipg_sim.tpl';
                $this->children = array(
                  'common/header',
                  'common/footer'
                );
                $this->response->setOutput($this->render());
              }

              private function validate() {
                /*if (!$this->user->hasPermission('modify', 'payment/cipg_sim')){
                  $this->error['warning'] = $this->language->get('error_permission');
                }
                if (!$this->request->post['cipg_sim_login_id']) {
                  $this->error['login_id'] = $this->language->get('error_login_id');
                }
                if (!$this->request->post['cipg_sim_transaction_key']) {
                  $this->error['transaction_key'] = $this->language->get('error_transaction_key');
                }
                if (!$this->request->post['cipg_sim_response_key']) {
                  $this->error['response_key'] = $this->language->get('error_response_key');
                } elseif(isset($this->request->post['cipg_sim_response_key']) && (strlen(preg_replace( '/\s+/', ' ', $this->request->post['cipg_sim_response_key'])) > 20)) {
                  $this->error['response_key'] = $this->language->get('error_response_key');
                }*/
                if (!$this->error) {
                  return TRUE;
                } else {
                  return FALSE;
                }  
              }
            }
            ?>

Can someone please assist?

Upvotes: 0

Views: 1485

Answers (1)

ckonig
ckonig

Reputation: 1234

It seems like you are using a very recent version of OpenCart. The data attribute is no longer a member of the Controller class, as you can see in the version history.

I also assume you are using a third-party extension from the Shop. Searching for "stanbic" brings up one result, which isn't compatible with any recent OpenCart version.

Try the same extension on an older OpenCart version. Or you can try to fix the implementation yourself:

  • Create a local variable $data = array(); right at the beginning of the index function
  • Replace all references to "$this->data" with "$data"
  • Pass the local $data to the setOutput function: $this->response->setOutput($this->load->view('foldername/filename.tpl', $data));

This isnt tested and it is likely that you will have to modify more code, because it appears that the OpenCart 2.x code is quite different from the 1.5.x codebase. Use a recent controller as reference.

Upvotes: 1

Related Questions