shop.balmet.com

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

pp_payflow.php (6902B)


      1 <?php
      2 class ControllerExtensionPaymentPPPayflow extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/payment/pp_payflow');
      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_pp_payflow', $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['vendor'])) {
     27 			$data['error_vendor'] = $this->error['vendor'];
     28 		} else {
     29 			$data['error_vendor'] = '';
     30 		}
     31 
     32 		if (isset($this->error['user'])) {
     33 			$data['error_user'] = $this->error['user'];
     34 		} else {
     35 			$data['error_user'] = '';
     36 		}
     37 
     38 		if (isset($this->error['password'])) {
     39 			$data['error_password'] = $this->error['password'];
     40 		} else {
     41 			$data['error_password'] = '';
     42 		}
     43 
     44 		if (isset($this->error['partner'])) {
     45 			$data['error_partner'] = $this->error['partner'];
     46 		} else {
     47 			$data['error_partner'] = '';
     48 		}
     49 
     50 		$data['breadcrumbs'] = array();
     51 
     52 		$data['breadcrumbs'][] = array(
     53 			'text' => $this->language->get('text_home'),
     54 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
     55 		);
     56 
     57 		$data['breadcrumbs'][] = array(
     58 			'text' => $this->language->get('text_pp_express'),
     59 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true),
     60 		);
     61 
     62 		$data['breadcrumbs'][] = array(
     63 			'text' => $this->language->get('heading_title'),
     64 			'href' => $this->url->link('extension/payment/pp_payflow', 'user_token=' . $this->session->data['user_token'], true),
     65 		);
     66 
     67 		$data['action'] = $this->url->link('extension/payment/pp_payflow', 'user_token=' . $this->session->data['user_token'], true);
     68 
     69 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
     70 
     71 		if (isset($this->request->post['payment_pp_payflow_vendor'])) {
     72 			$data['payment_pp_payflow_vendor'] = $this->request->post['payment_pp_payflow_vendor'];
     73 		} else {
     74 			$data['payment_pp_payflow_vendor'] = $this->config->get('payment_pp_payflow_vendor');
     75 		}
     76 
     77 		if (isset($this->request->post['payment_pp_payflow_user'])) {
     78 			$data['payment_pp_payflow_user'] = $this->request->post['payment_pp_payflow_user'];
     79 		} else {
     80 			$data['payment_pp_payflow_user'] = $this->config->get('payment_pp_payflow_user');
     81 		}
     82 
     83 		if (isset($this->request->post['payment_pp_payflow_password'])) {
     84 			$data['payment_pp_payflow_password'] = $this->request->post['payment_pp_payflow_password'];
     85 		} else {
     86 			$data['payment_pp_payflow_password'] = $this->config->get('payment_pp_payflow_password');
     87 		}
     88 
     89 		if (isset($this->request->post['payment_pp_payflow_partner'])) {
     90 			$data['payment_pp_payflow_partner'] = $this->request->post['payment_pp_payflow_partner'];
     91 		} elseif ($this->config->has('payment_pp_payflow_partner')) {
     92 			$data['payment_pp_payflow_partner'] = $this->config->get('payment_pp_payflow_partner');
     93 		} else {
     94 			$data['payment_pp_payflow_partner'] = 'PayPal';
     95 		}
     96 
     97 		if (isset($this->request->post['payment_pp_payflow_test'])) {
     98 			$data['payment_pp_payflow_test'] = $this->request->post['payment_pp_payflow_test'];
     99 		} else {
    100 			$data['payment_pp_payflow_test'] = $this->config->get('payment_pp_payflow_test');
    101 		}
    102 
    103 		if (isset($this->request->post['payment_pp_payflow_transaction'])) {
    104 			$data['payment_pp_payflow_transaction'] = $this->request->post['payment_pp_payflow_transaction'];
    105 		} else {
    106 			$data['payment_pp_payflow_transaction'] = $this->config->get('payment_pp_payflow_transaction');
    107 		}
    108 
    109 		if (isset($this->request->post['payment_pp_payflow_total'])) {
    110 			$data['payment_pp_payflow_total'] = $this->request->post['payment_pp_payflow_total'];
    111 		} else {
    112 			$data['payment_pp_payflow_total'] = $this->config->get('payment_pp_payflow_total');
    113 		}
    114 
    115 		if (isset($this->request->post['payment_pp_payflow_order_status_id'])) {
    116 			$data['payment_pp_payflow_order_status_id'] = $this->request->post['payment_pp_payflow_order_status_id'];
    117 		} else {
    118 			$data['payment_pp_payflow_order_status_id'] = $this->config->get('payment_pp_payflow_order_status_id');
    119 		}
    120 
    121 		$this->load->model('localisation/order_status');
    122 
    123 		$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
    124 
    125 		if (isset($this->request->post['payment_pp_payflow_geo_zone_id'])) {
    126 			$data['payment_pp_payflow_geo_zone_id'] = $this->request->post['payment_pp_payflow_geo_zone_id'];
    127 		} else {
    128 			$data['payment_pp_payflow_geo_zone_id'] = $this->config->get('payment_pp_payflow_geo_zone_id');
    129 		}
    130 
    131 		$this->load->model('localisation/geo_zone');
    132 
    133 		$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
    134 
    135 		if (isset($this->request->post['payment_pp_payflow_status'])) {
    136 			$data['payment_pp_payflow_status'] = $this->request->post['payment_pp_payflow_status'];
    137 		} else {
    138 			$data['payment_pp_payflow_status'] = $this->config->get('payment_pp_payflow_status');
    139 		}
    140 
    141 		if (isset($this->request->post['payment_pp_payflow_sort_order'])) {
    142 			$data['payment_pp_payflow_sort_order'] = $this->request->post['payment_pp_payflow_sort_order'];
    143 		} else {
    144 			$data['payment_pp_payflow_sort_order'] = $this->config->get('payment_pp_payflow_sort_order');
    145 		}
    146 
    147 		$data['header'] = $this->load->controller('common/header');
    148 		$data['column_left'] = $this->load->controller('common/column_left');
    149 		$data['footer'] = $this->load->controller('common/footer');
    150 
    151 		$this->response->setOutput($this->load->view('extension/payment/pp_payflow', $data));
    152 	}
    153 
    154 	private function validate() {
    155 		if (!$this->user->hasPermission('modify', 'extension/payment/pp_payflow')) {
    156 			$this->error['warning'] = $this->language->get('error_permission');
    157 		}
    158 
    159 		if (!$this->request->post['payment_pp_payflow_vendor']) {
    160 			$this->error['vendor'] = $this->language->get('error_vendor');
    161 		}
    162 
    163 		if (!$this->request->post['payment_pp_payflow_user']) {
    164 			$this->error['user'] = $this->language->get('error_user');
    165 		}
    166 
    167 		if (!$this->request->post['payment_pp_payflow_password']) {
    168 			$this->error['password'] = $this->language->get('error_password');
    169 		}
    170 
    171 		if (!$this->request->post['payment_pp_payflow_partner']) {
    172 			$this->error['partner'] = $this->language->get('error_partner');
    173 		}
    174 
    175 		return !$this->error;
    176 	}
    177 }