twocheckout.php (5726B)
1 <?php 2 class ControllerExtensionPaymentTwoCheckout extends Controller { 3 private $error = array(); 4 5 public function index() { 6 $this->load->language('extension/payment/twocheckout'); 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_twocheckout', $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['account'])) { 27 $data['error_account'] = $this->error['account']; 28 } else { 29 $data['error_account'] = ''; 30 } 31 32 if (isset($this->error['secret'])) { 33 $data['error_secret'] = $this->error['secret']; 34 } else { 35 $data['error_secret'] = ''; 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/twocheckout', 'user_token=' . $this->session->data['user_token'], true) 53 ); 54 55 $data['action'] = $this->url->link('extension/payment/twocheckout', '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_twocheckout_account'])) { 60 $data['payment_twocheckout_account'] = $this->request->post['payment_twocheckout_account']; 61 } else { 62 $data['payment_twocheckout_account'] = $this->config->get('payment_twocheckout_account'); 63 } 64 65 if (isset($this->request->post['payment_twocheckout_secret'])) { 66 $data['payment_twocheckout_secret'] = $this->request->post['payment_twocheckout_secret']; 67 } else { 68 $data['payment_twocheckout_secret'] = $this->config->get('payment_twocheckout_secret'); 69 } 70 71 if (isset($this->request->post['payment_twocheckout_display'])) { 72 $data['payment_twocheckout_display'] = $this->request->post['payment_twocheckout_display']; 73 } else { 74 $data['payment_twocheckout_display'] = $this->config->get('payment_twocheckout_display'); 75 } 76 77 if (isset($this->request->post['payment_twocheckout_test'])) { 78 $data['payment_twocheckout_test'] = $this->request->post['payment_twocheckout_test']; 79 } else { 80 $data['payment_twocheckout_test'] = $this->config->get('payment_twocheckout_test'); 81 } 82 83 if (isset($this->request->post['payment_twocheckout_total'])) { 84 $data['payment_twocheckout_total'] = $this->request->post['payment_twocheckout_total']; 85 } else { 86 $data['payment_twocheckout_total'] = $this->config->get('payment_twocheckout_total'); 87 } 88 89 if (isset($this->request->post['payment_twocheckout_order_status_id'])) { 90 $data['payment_twocheckout_order_status_id'] = $this->request->post['payment_twocheckout_order_status_id']; 91 } else { 92 $data['payment_twocheckout_order_status_id'] = $this->config->get('payment_twocheckout_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_twocheckout_geo_zone_id'])) { 100 $data['payment_twocheckout_geo_zone_id'] = $this->request->post['payment_twocheckout_geo_zone_id']; 101 } else { 102 $data['payment_twocheckout_geo_zone_id'] = $this->config->get('payment_twocheckout_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_twocheckout_status'])) { 110 $data['payment_twocheckout_status'] = $this->request->post['payment_twocheckout_status']; 111 } else { 112 $data['payment_twocheckout_status'] = $this->config->get('payment_twocheckout_status'); 113 } 114 115 if (isset($this->request->post['payment_twocheckout_sort_order'])) { 116 $data['payment_twocheckout_sort_order'] = $this->request->post['payment_twocheckout_sort_order']; 117 } else { 118 $data['payment_twocheckout_sort_order'] = $this->config->get('payment_twocheckout_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/twocheckout', $data)); 126 } 127 128 protected function validate() { 129 if (!$this->user->hasPermission('modify', 'extension/payment/twocheckout')) { 130 $this->error['warning'] = $this->language->get('error_permission'); 131 } 132 133 if (!$this->request->post['payment_twocheckout_account']) { 134 $this->error['account'] = $this->language->get('error_account'); 135 } 136 137 if (!$this->request->post['payment_twocheckout_secret']) { 138 $this->error['secret'] = $this->language->get('error_secret'); 139 } 140 141 return !$this->error; 142 } 143 }