错误在付款插件

时间:2015-08-07 13:27:32

标签: php opencart payment-gateway payment opencart2.x

我已经在opencart上为支付网关设置了这个模块,但我收到了这个错误,我将$this->data更改为$data,我得到一个空白页面。如果我将其更改回$ this->数据,我会收到此error http://prntscr.com/832nd2

这是代码

                        <?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;
                }  
              }
            }
            ?>

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

您似乎正在使用最新版本的OpenCart。 data属性不再是Controller类的成员,您可以在version history中看到。

我还假设您正在使用Shop中的第三方扩展程序。搜索“stanbic”会显示one result,这与最近的任何OpenCart版本都不兼容。

在较旧的OpenCart版本上尝试使用相同的扩展程序。或者您可以尝试自己修复实现:

  • 在索引函数的开头
  • 创建一个局部变量$data = array();
  • 将所有对“$this->data”的引用替换为“$data
  • 将本地$数据传递给setOutput函数:$this->response->setOutput($this->load->view('foldername/filename.tpl', $data));

这未经过测试,您可能需要修改更多代码,因为OpenCart 2.x代码似乎与1.5.x代码库完全不同。使用recent controller作为参考。