shop.balmet.com

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

liqpay.php (5386B)


      1 <?php
      2 class ControllerExtensionPaymentLiqPay extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/payment/liqpay');
      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_liqpay', $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['merchant'])) {
     27 			$data['error_merchant'] = $this->error['merchant'];
     28 		} else {
     29 			$data['error_merchant'] = '';
     30 		}
     31 
     32 		if (isset($this->error['signature'])) {
     33 			$data['error_signature'] = $this->error['signature'];
     34 		} else {
     35 			$data['error_signature'] = '';
     36 		}
     37 
     38 		if (isset($this->error['type'])) {
     39 			$data['error_type'] = $this->error['type'];
     40 		} else {
     41 			$data['error_type'] = '';
     42 		}
     43 
     44 		$data['breadcrumbs'] = array();
     45 
     46 		$data['breadcrumbs'][] = array(
     47 			'text' => $this->language->get('text_home'),
     48 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     49 		);
     50 
     51 		$data['breadcrumbs'][] = array(
     52 			'text' => $this->language->get('text_extension'),
     53 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true)
     54 		);
     55 
     56 		$data['breadcrumbs'][] = array(
     57 			'text' => $this->language->get('heading_title'),
     58 			'href' => $this->url->link('extension/payment/liqpay', 'user_token=' . $this->session->data['user_token'], true)
     59 		);
     60 
     61 		$data['action'] = $this->url->link('extension/payment/liqpay', 'user_token=' . $this->session->data['user_token'], true);
     62 
     63 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true);
     64 
     65 		if (isset($this->request->post['payment_liqpay_merchant'])) {
     66 			$data['payment_liqpay_merchant'] = $this->request->post['payment_liqpay_merchant'];
     67 		} else {
     68 			$data['payment_liqpay_merchant'] = $this->config->get('payment_liqpay_merchant');
     69 		}
     70 
     71 		if (isset($this->request->post['payment_liqpay_signature'])) {
     72 			$data['payment_liqpay_signature'] = $this->request->post['payment_liqpay_signature'];
     73 		} else {
     74 			$data['payment_liqpay_signature'] = $this->config->get('payment_liqpay_signature');
     75 		}
     76 
     77 		if (isset($this->request->post['payment_liqpay_type'])) {
     78 			$data['payment_liqpay_type'] = $this->request->post['payment_liqpay_type'];
     79 		} else {
     80 			$data['payment_liqpay_type'] = $this->config->get('payment_liqpay_type');
     81 		}
     82 
     83 		if (isset($this->request->post['payment_liqpay_total'])) {
     84 			$data['payment_liqpay_total'] = $this->request->post['payment_liqpay_total'];
     85 		} else {
     86 			$data['payment_liqpay_total'] = $this->config->get('payment_liqpay_total');
     87 		}
     88 
     89 		if (isset($this->request->post['payment_liqpay_order_status_id'])) {
     90 			$data['payment_liqpay_order_status_id'] = $this->request->post['payment_liqpay_order_status_id'];
     91 		} else {
     92 			$data['payment_liqpay_order_status_id'] = $this->config->get('payment_liqpay_order_status_id');
     93 		}
     94 
     95 		$this->load->model('localisation/order_status');
     96 
     97 		$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
     98 
     99 		if (isset($this->request->post['payment_liqpay_geo_zone_id'])) {
    100 			$data['payment_liqpay_geo_zone_id'] = $this->request->post['payment_liqpay_geo_zone_id'];
    101 		} else {
    102 			$data['payment_liqpay_geo_zone_id'] = $this->config->get('payment_liqpay_geo_zone_id');
    103 		}
    104 
    105 		$this->load->model('localisation/geo_zone');
    106 
    107 		$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
    108 
    109 		if (isset($this->request->post['payment_liqpay_status'])) {
    110 			$data['payment_liqpay_status'] = $this->request->post['payment_liqpay_status'];
    111 		} else {
    112 			$data['payment_liqpay_status'] = $this->config->get('payment_liqpay_status');
    113 		}
    114 
    115 		if (isset($this->request->post['payment_liqpay_sort_order'])) {
    116 			$data['payment_liqpay_sort_order'] = $this->request->post['payment_liqpay_sort_order'];
    117 		} else {
    118 			$data['payment_liqpay_sort_order'] = $this->config->get('payment_liqpay_sort_order');
    119 		}
    120 
    121 		$data['header'] = $this->load->controller('common/header');
    122 		$data['column_left'] = $this->load->controller('common/column_left');
    123 		$data['footer'] = $this->load->controller('common/footer');
    124 
    125 		$this->response->setOutput($this->load->view('extension/payment/liqpay', $data));
    126 	}
    127 
    128 	protected function validate() {
    129 		if (!$this->user->hasPermission('modify', 'extension/payment/liqpay')) {
    130 			$this->error['warning'] = $this->language->get('error_permission');
    131 		}
    132 
    133 		if (!$this->request->post['payment_liqpay_merchant']) {
    134 			$this->error['merchant'] = $this->language->get('error_merchant');
    135 		}
    136 
    137 		if (!$this->request->post['payment_liqpay_signature']) {
    138 			$this->error['signature'] = $this->language->get('error_signature');
    139 		}
    140 
    141 		return !$this->error;
    142 	}
    143 }