payza.php (5049B)
1 <?php 2 class ControllerExtensionPaymentPayza extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/payment/payza'); 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_payza', $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['security'])) { 33 $data['error_security'] = $this->error['security']; 34 } else { 35 $data['error_security'] = ''; 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/payza', 'user_token=' . $this->session->data['user_token'], true) 53 ); 54 55 $data['action'] = $this->url->link('extension/payment/payza', 'user_token=' . $this->session->data['user_token'], true); 56 57 $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=payment', true); 58 59 if (isset($this->request->post['payment_payza_merchant'])) { 60 $data['payment_payza_merchant'] = $this->request->post['payment_payza_merchant']; 61 } else { 62 $data['payment_payza_merchant'] = $this->config->get('payment_payza_merchant'); 63 } 64 65 if (isset($this->request->post['payment_payza_security'])) { 66 $data['payment_payza_security'] = $this->request->post['payment_payza_security']; 67 } else { 68 $data['payment_payza_security'] = $this->config->get('payment_payza_security'); 69 } 70 71 $data['callback'] = HTTP_CATALOG . 'index.php?route=extension/payment/payza/callback'; 72 73 if (isset($this->request->post['payment_payza_total'])) { 74 $data['payment_payza_total'] = $this->request->post['payment_payza_total']; 75 } else { 76 $data['payment_payza_total'] = $this->config->get('payment_payza_total'); 77 } 78 79 if (isset($this->request->post['payment_payza_order_status_id'])) { 80 $data['payment_payza_order_status_id'] = $this->request->post['payment_payza_order_status_id']; 81 } else { 82 $data['payment_payza_order_status_id'] = $this->config->get('payment_payza_order_status_id'); 83 } 84 85 $this->load->model('localisation/order_status'); 86 87 $data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses(); 88 89 if (isset($this->request->post['payment_payza_geo_zone_id'])) { 90 $data['payment_payza_geo_zone_id'] = $this->request->post['payment_payza_geo_zone_id']; 91 } else { 92 $data['payment_payza_geo_zone_id'] = $this->config->get('payment_payza_geo_zone_id'); 93 } 94 95 $this->load->model('localisation/geo_zone'); 96 97 $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); 98 99 if (isset($this->request->post['payment_payza_status'])) { 100 $data['payment_payza_status'] = $this->request->post['payment_payza_status']; 101 } else { 102 $data['payment_payza_status'] = $this->config->get('payment_payza_status'); 103 } 104 105 if (isset($this->request->post['payment_payza_sort_order'])) { 106 $data['payment_payza_sort_order'] = $this->request->post['payment_payza_sort_order']; 107 } else { 108 $data['payment_payza_sort_order'] = $this->config->get('payment_payza_sort_order'); 109 } 110 111 $data['header'] = $this->load->controller('common/header'); 112 $data['column_left'] = $this->load->controller('common/column_left'); 113 $data['footer'] = $this->load->controller('common/footer'); 114 115 $this->response->setOutput($this->load->view('extension/payment/payza', $data)); 116 } 117 118 protected function validate() { 119 if (!$this->user->hasPermission('modify', 'extension/payment/payza')) { 120 $this->error['warning'] = $this->language->get('error_permission'); 121 } 122 123 if (!$this->request->post['payment_payza_merchant']) { 124 $this->error['merchant'] = $this->language->get('error_merchant'); 125 } 126 127 if (!$this->request->post['payment_payza_security']) { 128 $this->error['security'] = $this->language->get('error_security'); 129 } 130 131 return !$this->error; 132 } 133 }