shop.balmet.com

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

alipay.php (6011B)


      1 <?php
      2 class ControllerExtensionPaymentAlipay extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/payment/alipay');
      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_alipay', $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['app_id'])) {
     27 			$data['error_app_id'] = $this->error['app_id'];
     28 		} else {
     29 			$data['error_app_id'] = '';
     30 		}
     31 
     32 		if (isset($this->error['merchant_private_key'])) {
     33 			$data['error_merchant_private_key'] = $this->error['merchant_private_key'];
     34 		} else {
     35 			$data['error_merchant_private_key'] = '';
     36 		}
     37 
     38 		if (isset($this->error['alipay_public_key'])) {
     39 			$data['error_alipay_public_key'] = $this->error['alipay_public_key'];
     40 		} else {
     41 			$data['error_alipay_public_key'] = '';
     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/alipay', 'user_token=' . $this->session->data['user_token'], true)
     59 		);
     60 
     61 		$data['action'] = $this->url->link('extension/payment/alipay', '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_alipay_app_id'])) {
     66 			$data['payment_alipay_app_id'] = $this->request->post['payment_alipay_app_id'];
     67 		} else {
     68 			$data['payment_alipay_app_id'] = $this->config->get('payment_alipay_app_id');
     69 		}
     70 
     71 		if (isset($this->request->post['payment_alipay_merchant_private_key'])) {
     72 			$data['payment_alipay_merchant_private_key'] = $this->request->post['payment_alipay_merchant_private_key'];
     73 		} else {
     74 			$data['payment_alipay_merchant_private_key'] = $this->config->get('payment_alipay_merchant_private_key');
     75 		}
     76 
     77 		if (isset($this->request->post['payment_alipay_alipay_public_key'])) {
     78 			$data['payment_alipay_alipay_public_key'] = $this->request->post['payment_alipay_alipay_public_key'];
     79 		} else {
     80 			$data['payment_alipay_alipay_public_key'] = $this->config->get('payment_alipay_alipay_public_key');
     81 		}
     82 
     83 		if (isset($this->request->post['payment_alipay_total'])) {
     84 			$data['payment_alipay_total'] = $this->request->post['payment_alipay_total'];
     85 		} else {
     86 			$data['payment_alipay_total'] = $this->config->get('payment_alipay_total');
     87 		}
     88 
     89 		if (isset($this->request->post['payment_alipay_order_status_id'])) {
     90 			$data['payment_alipay_order_status_id'] = $this->request->post['payment_alipay_order_status_id'];
     91 		} else {
     92 			$data['payment_alipay_order_status_id'] = $this->config->get('payment_alipay_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_alipay_geo_zone_id'])) {
    100 			$data['payment_alipay_geo_zone_id'] = $this->request->post['payment_alipay_geo_zone_id'];
    101 		} else {
    102 			$data['payment_alipay_geo_zone_id'] = $this->config->get('payment_alipay_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_alipay_test'])) {
    110 			$data['payment_alipay_test'] = $this->request->post['payment_alipay_test'];
    111 		} else {
    112 			$data['payment_alipay_test'] = $this->config->get('payment_alipay_test');
    113 		}
    114 
    115 		if (isset($this->request->post['payment_alipay_status'])) {
    116 			$data['payment_alipay_status'] = $this->request->post['payment_alipay_status'];
    117 		} else {
    118 			$data['payment_alipay_status'] = $this->config->get('payment_alipay_status');
    119 		}
    120 
    121 		if (isset($this->request->post['payment_alipay_sort_order'])) {
    122 			$data['payment_alipay_sort_order'] = $this->request->post['payment_alipay_sort_order'];
    123 		} else {
    124 			$data['payment_alipay_sort_order'] = $this->config->get('payment_alipay_sort_order');
    125 		}
    126 
    127 		$data['header'] = $this->load->controller('common/header');
    128 		$data['column_left'] = $this->load->controller('common/column_left');
    129 		$data['footer'] = $this->load->controller('common/footer');
    130 
    131 		$this->response->setOutput($this->load->view('extension/payment/alipay', $data));
    132 	}
    133 
    134 	private function validate() {
    135 		if (!$this->user->hasPermission('modify', 'extension/payment/alipay')) {
    136 			$this->error['warning'] = $this->language->get('error_permission');
    137 		}
    138 
    139 		if (!$this->request->post['payment_alipay_app_id']) {
    140 			$this->error['app_id'] = $this->language->get('error_app_id');
    141 		}
    142 
    143 		if (!$this->request->post['payment_alipay_merchant_private_key']) {
    144 			$this->error['merchant_private_key'] = $this->language->get('error_merchant_private_key');
    145 		}
    146 
    147 		if (!$this->request->post['payment_alipay_alipay_public_key']) {
    148 			$this->error['alipay_public_key'] = $this->language->get('error_alipay_public_key');
    149 		}
    150 
    151 		return !$this->error;
    152 	}
    153 }