shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

authorizenet_aim.php (6516B)


      1 <?php
      2 class ControllerExtensionPaymentAuthorizenetAim extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/payment/authorizenet_aim');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('setting/setting');
     11 
     12 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     13 			$this->model_setting_setting->editSetting('payment_authorizenet_aim', $this->request->post);
     14 
     15 			$this->session->data['success'] = $this->language->get('text_success');
     16 
     17 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true));
     18 		}
     19 
     20 		if (isset($this->error['warning'])) {
     21 			$data['error_warning'] = $this->error['warning'];
     22 		} else {
     23 			$data['error_warning'] = '';
     24 		}
     25 
     26 		if (isset($this->error['login'])) {
     27 			$data['error_login'] = $this->error['login'];
     28 		} else {
     29 			$data['error_login'] = '';
     30 		}
     31 
     32 		if (isset($this->error['key'])) {
     33 			$data['error_key'] = $this->error['key'];
     34 		} else {
     35 			$data['error_key'] = '';
     36 		}
     37 
     38 		$data['breadcrumbs'] = array();
     39 
     40 		$data['breadcrumbs'][] = array(
     41 			'text' => $this->language->get('text_home'),
     42 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     43 		);
     44 
     45 		$data['breadcrumbs'][] = array(
     46 			'text' => $this->language->get('text_extension'),
     47 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
     48 		);
     49 
     50 		$data['breadcrumbs'][] = array(
     51 			'text' => $this->language->get('heading_title'),
     52 			'href' => $this->url->link('extension/payment/authorizenet_aim', 'user_token=' . $this->session->data['user_token'], true)
     53 		);
     54 
     55 		$data['action'] = $this->url->link('extension/payment/authorizenet_aim', 'user_token=' . $this->session->data['user_token'], true);
     56 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
     57 
     58 		if (isset($this->request->post['payment_authorizenet_aim_login'])) {
     59 			$data['payment_authorizenet_aim_login'] = $this->request->post['payment_authorizenet_aim_login'];
     60 		} else {
     61 			$data['payment_authorizenet_aim_login'] = $this->config->get('payment_authorizenet_aim_login');
     62 		}
     63 
     64 		if (isset($this->request->post['payment_authorizenet_aim_key'])) {
     65 			$data['payment_authorizenet_aim_key'] = $this->request->post['payment_authorizenet_aim_key'];
     66 		} else {
     67 			$data['payment_authorizenet_aim_key'] = $this->config->get('payment_authorizenet_aim_key');
     68 		}
     69 
     70 		if (isset($this->request->post['payment_authorizenet_aim_hash'])) {
     71 			$data['payment_authorizenet_aim_hash'] = $this->request->post['payment_authorizenet_aim_hash'];
     72 		} else {
     73 			$data['payment_authorizenet_aim_hash'] = $this->config->get('payment_authorizenet_aim_hash');
     74 		}
     75 
     76 		if (isset($this->request->post['payment_authorizenet_aim_server'])) {
     77 			$data['payment_authorizenet_aim_server'] = $this->request->post['payment_authorizenet_aim_server'];
     78 		} else {
     79 			$data['payment_authorizenet_aim_server'] = $this->config->get('payment_authorizenet_aim_server');
     80 		}
     81 
     82 		if (isset($this->request->post['payment_authorizenet_aim_mode'])) {
     83 			$data['payment_authorizenet_aim_mode'] = $this->request->post['payment_authorizenet_aim_mode'];
     84 		} else {
     85 			$data['payment_authorizenet_aim_mode'] = $this->config->get('payment_authorizenet_aim_mode');
     86 		}
     87 
     88 		if (isset($this->request->post['payment_authorizenet_aim_method'])) {
     89 			$data['payment_authorizenet_aim_method'] = $this->request->post['payment_authorizenet_aim_method'];
     90 		} else {
     91 			$data['payment_authorizenet_aim_method'] = $this->config->get('payment_authorizenet_aim_method');
     92 		}
     93 
     94 		if (isset($this->request->post['payment_authorizenet_aim_total'])) {
     95 			$data['payment_authorizenet_aim_total'] = $this->request->post['payment_authorizenet_aim_total'];
     96 		} else {
     97 			$data['payment_authorizenet_aim_total'] = $this->config->get('payment_authorizenet_aim_total');
     98 		}
     99 
    100 		if (isset($this->request->post['payment_authorizenet_aim_order_status_id'])) {
    101 			$data['payment_authorizenet_aim_order_status_id'] = $this->request->post['payment_authorizenet_aim_order_status_id'];
    102 		} else {
    103 			$data['payment_authorizenet_aim_order_status_id'] = $this->config->get('payment_authorizenet_aim_order_status_id');
    104 		}
    105 
    106 		$this->load->model('localisation/order_status');
    107 
    108 		$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
    109 
    110 		if (isset($this->request->post['payment_authorizenet_aim_geo_zone_id'])) {
    111 			$data['payment_authorizenet_aim_geo_zone_id'] = $this->request->post['payment_authorizenet_aim_geo_zone_id'];
    112 		} else {
    113 			$data['payment_authorizenet_aim_geo_zone_id'] = $this->config->get('payment_authorizenet_aim_geo_zone_id');
    114 		}
    115 
    116 		$this->load->model('localisation/geo_zone');
    117 
    118 		$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
    119 
    120 		if (isset($this->request->post['payment_authorizenet_aim_status'])) {
    121 			$data['payment_authorizenet_aim_status'] = $this->request->post['payment_authorizenet_aim_status'];
    122 		} else {
    123 			$data['payment_authorizenet_aim_status'] = $this->config->get('payment_authorizenet_aim_status');
    124 		}
    125 
    126 		if (isset($this->request->post['payment_authorizenet_aim_sort_order'])) {
    127 			$data['payment_authorizenet_aim_sort_order'] = $this->request->post['payment_authorizenet_aim_sort_order'];
    128 		} else {
    129 			$data['payment_authorizenet_aim_sort_order'] = $this->config->get('payment_authorizenet_aim_sort_order');
    130 		}
    131 
    132 		$data['header'] = $this->load->controller('common/header');
    133 		$data['column_left'] = $this->load->controller('common/column_left');
    134 		$data['footer'] = $this->load->controller('common/footer');
    135 
    136 		$this->response->setOutput($this->load->view('extension/payment/authorizenet_aim', $data));
    137 	}
    138 
    139 	protected function validate() {
    140 		if (!$this->user->hasPermission('modify', 'extension/payment/authorizenet_aim')) {
    141 			$this->error['warning'] = $this->language->get('error_permission');
    142 		}
    143 
    144 		if (!$this->request->post['payment_authorizenet_aim_login']) {
    145 			$this->error['login'] = $this->language->get('error_login');
    146 		}
    147 
    148 		if (!$this->request->post['payment_authorizenet_aim_key']) {
    149 			$this->error['key'] = $this->language->get('error_key');
    150 		}
    151 
    152 		return !$this->error;
    153 	}
    154 }