|
| 1 | +<?php |
| 2 | +class ControllerExtensionPaymentCryptapi extends Controller { |
| 3 | + |
| 4 | + private $error = array(); |
| 5 | + |
| 6 | + public function index() { |
| 7 | + $this->load->language('extension/payment/cryptapi'); |
| 8 | + |
| 9 | + $this->document->setTitle($this->language->get('heading_title')); |
| 10 | + |
| 11 | + $this->load->model('setting/setting'); |
| 12 | + |
| 13 | + if (($this->request->server['REQUEST_METHOD'] == 'POST')) { |
| 14 | + $this->model_setting_setting->editSetting('payment_cryptapi', $this->request->post); |
| 15 | + |
| 16 | + $this->session->data['success'] = $this->language->get('text_success'); |
| 17 | + |
| 18 | + $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'].'&type=payment', true)); |
| 19 | + } |
| 20 | + |
| 21 | + $this->load->model('localisation/geo_zone'); |
| 22 | + |
| 23 | + $data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones(); |
| 24 | + |
| 25 | + $this->load->model('localisation/order_status'); |
| 26 | + |
| 27 | + $orderStatuses = $this->model_localisation_order_status->getOrderStatuses(); |
| 28 | + $orderStatusesFiltered = []; |
| 29 | + $orderStatusesIgnore = [ |
| 30 | + 'Canceled', |
| 31 | + 'Canceled Reversal', |
| 32 | + 'Chargeback', |
| 33 | + 'Complete', |
| 34 | + 'Denied', |
| 35 | + 'Expired', |
| 36 | + 'Failed', |
| 37 | + 'Processed', |
| 38 | + 'Processing', |
| 39 | + 'Refunded', |
| 40 | + 'Reversed', |
| 41 | + 'Shipped', |
| 42 | + 'Voided' |
| 43 | + ]; |
| 44 | + foreach ($orderStatuses as $orderStatus) { |
| 45 | + if (!in_array($orderStatus['name'], $orderStatusesIgnore)){ |
| 46 | + $orderStatusesFiltered[] = $orderStatus; |
| 47 | + } |
| 48 | + } |
| 49 | + $data['order_statuses'] = $orderStatusesFiltered; |
| 50 | + |
| 51 | + if (isset($this->error['warning'])) { |
| 52 | + $data['error_warning'] = $this->error['warning']; |
| 53 | + } else { |
| 54 | + $data['error_warning'] = ''; |
| 55 | + } |
| 56 | + |
| 57 | + $data['breadcrumbs'] = array(); |
| 58 | + |
| 59 | + $data['breadcrumbs'][] = array( |
| 60 | + 'text' => $this->language->get('text_home'), |
| 61 | + 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true) |
| 62 | + ); |
| 63 | + |
| 64 | + $data['breadcrumbs'][] = array( |
| 65 | + 'text' => $this->language->get('text_extension'), |
| 66 | + 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true) |
| 67 | + ); |
| 68 | + |
| 69 | + $data['breadcrumbs'][] = array( |
| 70 | + 'text' => $this->language->get('heading_title'), |
| 71 | + 'href' => $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true) |
| 72 | + ); |
| 73 | + |
| 74 | + $data['action'] = $this->url->link('extension/payment/cryptapi', 'user_token=' . $this->session->data['user_token'], true); |
| 75 | + $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'], true); |
| 76 | + |
| 77 | + if (isset($this->request->post['payment_cryptapi_btc_address'])) { |
| 78 | + $data['payment_cryptapi_btc_address'] = $this->request->post['payment_cryptapi_btc_address']; |
| 79 | + } else { |
| 80 | + $data['payment_cryptapi_btc_address'] = $this->config->get('payment_cryptapi_btc_address'); |
| 81 | + } |
| 82 | + |
| 83 | + if (isset($this->request->post['payment_cryptapi_bch_address'])) { |
| 84 | + $data['payment_cryptapi_bch_address'] = $this->request->post['payment_cryptapi_bch_address']; |
| 85 | + } else { |
| 86 | + $data['payment_cryptapi_bch_address'] = $this->config->get('payment_cryptapi_bch_address'); |
| 87 | + } |
| 88 | + |
| 89 | + if (isset($this->request->post['payment_cryptapi_ltc_address'])) { |
| 90 | + $data['payment_cryptapi_ltc_address'] = $this->request->post['payment_cryptapi_ltc_address']; |
| 91 | + } else { |
| 92 | + $data['payment_cryptapi_ltc_address'] = $this->config->get('payment_cryptapi_ltc_address'); |
| 93 | + } |
| 94 | + |
| 95 | + if (isset($this->request->post['payment_cryptapi_eth_address'])) { |
| 96 | + $data['payment_cryptapi_eth_address'] = $this->request->post['payment_cryptapi_eth_address']; |
| 97 | + } else { |
| 98 | + $data['payment_cryptapi_eth_address'] = $this->config->get('payment_cryptapi_eth_address'); |
| 99 | + } |
| 100 | + |
| 101 | + if (isset($this->request->post['payment_cryptapi_xmr_address'])) { |
| 102 | + $data['payment_cryptapi_xmr_address'] = $this->request->post['payment_cryptapi_xmr_address']; |
| 103 | + } else { |
| 104 | + $data['payment_cryptapi_xmr_address'] = $this->config->get('payment_cryptapi_xmr_address'); |
| 105 | + } |
| 106 | + |
| 107 | + if (isset($this->request->post['payment_cryptapi_iota_address'])) { |
| 108 | + $data['payment_cryptapi_iota_address'] = $this->request->post['payment_cryptapi_iota_address']; |
| 109 | + } else { |
| 110 | + $data['payment_cryptapi_iota_address'] = $this->config->get('payment_cryptapi_iota_address'); |
| 111 | + } |
| 112 | + |
| 113 | + if (isset($this->request->post['payment_cryptapi_cryptocurrencies'])) { |
| 114 | + $data['payment_cryptapi_cryptocurrencies'] = $this->request->post['payment_cryptapi_cryptocurrencies']; |
| 115 | + } else { |
| 116 | + $data['payment_cryptapi_cryptocurrencies'] = $this->config->get('payment_cryptapi_cryptocurrencies'); |
| 117 | + } |
| 118 | + |
| 119 | + if (isset($this->request->post['payment_cryptapi_standard_geo_zone_id'])) { |
| 120 | + $data['payment_cryptapi_standard_geo_zone_id'] = $this->request->post['payment_cryptapi_standard_geo_zone_id']; |
| 121 | + } else { |
| 122 | + $data['payment_cryptapi_standard_geo_zone_id'] = $this->config->get('payment_cryptapi_standard_geo_zone_id'); |
| 123 | + } |
| 124 | + |
| 125 | + if (isset($this->request->post['payment_cryptapi_order_status_id'])) { |
| 126 | + $data['payment_cryptapi_order_status_id'] = $this->request->post['payment_cryptapi_order_status_id']; |
| 127 | + } else { |
| 128 | + $data['payment_cryptapi_order_status_id'] = $this->config->get('payment_cryptapi_order_status_id'); |
| 129 | + if (!$data['payment_cryptapi_order_status_id']) { |
| 130 | + $data['payment_cryptapi_order_status_id'] = 1; |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + if (isset($this->request->post['payment_cryptapi_status'])) { |
| 135 | + $data['payment_cryptapi_status'] = $this->request->post['payment_cryptapi_status']; |
| 136 | + } else { |
| 137 | + $data['payment_cryptapi_status'] = $this->config->get('payment_cryptapi_status'); |
| 138 | + } |
| 139 | + |
| 140 | + if (isset($this->request->post['payment_cryptapi_sort_order'])) { |
| 141 | + $data['payment_cryptapi_sort_order'] = $this->request->post['payment_cryptapi_sort_order']; |
| 142 | + } else { |
| 143 | + $data['payment_cryptapi_sort_order'] = $this->config->get('payment_cryptapi_sort_order'); |
| 144 | + } |
| 145 | + |
| 146 | + $data['header'] = $this->load->controller('common/header'); |
| 147 | + $data['column_left'] = $this->load->controller('common/column_left'); |
| 148 | + $data['footer'] = $this->load->controller('common/footer'); |
| 149 | + |
| 150 | + $this->response->setOutput($this->load->view('extension/payment/cryptapi', $data)); |
| 151 | + } |
| 152 | + |
| 153 | + public function install() { |
| 154 | + $this->load->model('extension/payment/cryptapi'); |
| 155 | + $this->model_extension_payment_cryptapi->install(); |
| 156 | + } |
| 157 | + |
| 158 | + public function uninstall() { |
| 159 | + $this->load->model('extension/payment/cryptapi'); |
| 160 | + $this->model_extension_payment_cryptapi->uninstall(); |
| 161 | + } |
| 162 | + |
| 163 | + public function order_info(&$route, &$data, &$output) |
| 164 | + { |
| 165 | + $order_id = $this->request->get['order_id']; |
| 166 | + $this->load->model('extension/payment/cryptapi'); |
| 167 | + $order = $this->model_extension_payment_cryptapi->getOrder($order_id); |
| 168 | + if ($order) { |
| 169 | + $metaData = $order['response']; |
| 170 | + if (!empty($metaData)) { |
| 171 | + $metaData = json_decode($metaData, true); |
| 172 | + $fields = []; |
| 173 | + foreach ($metaData as $key => $val) { |
| 174 | + $field = ['name' => $key, 'value' => $val]; |
| 175 | + $fields[] = $field; |
| 176 | + } |
| 177 | + if (isset($data['payment_custom_fields']) && is_array($data['payment_custom_fields'])) { |
| 178 | + $data['payment_custom_fields'] = array_merge($data['payment_custom_fields'], $fields); |
| 179 | + } else { |
| 180 | + $data['payment_custom_fields'] = $fields; |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | +} |
0 commit comments