/admin/controller/payment/authorizenet_aim.php

https://github.com/sansanwawa/e-commerse · PHP · 202 lines · 159 code · 43 blank · 0 comment · 39 complexity · 778febf1fde67684295195061b9139dc MD5 · raw file

  1. <?php
  2. class ControllerPaymentAuthorizenetAim extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->load->language('payment/authorizenet_aim');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('setting/setting');
  8. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  9. $this->model_setting_setting->editSetting('authorizenet_aim', $this->request->post);
  10. $this->session->data['success'] = $this->language->get('text_success');
  11. $this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
  12. }
  13. $this->data['heading_title'] = $this->language->get('heading_title');
  14. $this->data['text_enabled'] = $this->language->get('text_enabled');
  15. $this->data['text_disabled'] = $this->language->get('text_disabled');
  16. $this->data['text_all_zones'] = $this->language->get('text_all_zones');
  17. $this->data['text_test'] = $this->language->get('text_test');
  18. $this->data['text_live'] = $this->language->get('text_live');
  19. $this->data['text_authorization'] = $this->language->get('text_authorization');
  20. $this->data['text_capture'] = $this->language->get('text_capture');
  21. $this->data['entry_login'] = $this->language->get('entry_login');
  22. $this->data['entry_key'] = $this->language->get('entry_key');
  23. $this->data['entry_hash'] = $this->language->get('entry_hash');
  24. $this->data['entry_server'] = $this->language->get('entry_server');
  25. $this->data['entry_mode'] = $this->language->get('entry_mode');
  26. $this->data['entry_method'] = $this->language->get('entry_method');
  27. $this->data['entry_total'] = $this->language->get('entry_total');
  28. $this->data['entry_order_status'] = $this->language->get('entry_order_status');
  29. $this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
  30. $this->data['entry_status'] = $this->language->get('entry_status');
  31. $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
  32. $this->data['button_save'] = $this->language->get('button_save');
  33. $this->data['button_cancel'] = $this->language->get('button_cancel');
  34. $this->data['tab_general'] = $this->language->get('tab_general');
  35. if (isset($this->error['warning'])) {
  36. $this->data['error_warning'] = $this->error['warning'];
  37. } else {
  38. $this->data['error_warning'] = '';
  39. }
  40. if (isset($this->error['login'])) {
  41. $this->data['error_login'] = $this->error['login'];
  42. } else {
  43. $this->data['error_login'] = '';
  44. }
  45. if (isset($this->error['key'])) {
  46. $this->data['error_key'] = $this->error['key'];
  47. } else {
  48. $this->data['error_key'] = '';
  49. }
  50. if (isset($this->error['hash'])) {
  51. $this->data['error_hash'] = $this->error['hash'];
  52. } else {
  53. $this->data['error_hash'] = '';
  54. }
  55. $this->data['breadcrumbs'] = array();
  56. $this->data['breadcrumbs'][] = array(
  57. 'text' => $this->language->get('text_home'),
  58. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  59. 'separator' => false
  60. );
  61. $this->data['breadcrumbs'][] = array(
  62. 'text' => $this->language->get('text_payment'),
  63. 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
  64. 'separator' => ' :: '
  65. );
  66. $this->data['breadcrumbs'][] = array(
  67. 'text' => $this->language->get('heading_title'),
  68. 'href' => $this->url->link('payment/authorizenet_aim', 'token=' . $this->session->data['token'], 'SSL'),
  69. 'separator' => ' :: '
  70. );
  71. $this->data['action'] = $this->url->link('payment/authorizenet_aim', 'token=' . $this->session->data['token'], 'SSL');
  72. $this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');
  73. if (isset($this->request->post['authorizenet_aim_login'])) {
  74. $this->data['authorizenet_aim_login'] = $this->request->post['authorizenet_aim_login'];
  75. } else {
  76. $this->data['authorizenet_aim_login'] = $this->config->get('authorizenet_aim_login');
  77. }
  78. if (isset($this->request->post['authorizenet_aim_key'])) {
  79. $this->data['authorizenet_aim_key'] = $this->request->post['authorizenet_aim_key'];
  80. } else {
  81. $this->data['authorizenet_aim_key'] = $this->config->get('authorizenet_aim_key');
  82. }
  83. if (isset($this->request->post['authorizenet_aim_hash'])) {
  84. $this->data['authorizenet_aim_hash'] = $this->request->post['authorizenet_aim_hash'];
  85. } else {
  86. $this->data['authorizenet_aim_hash'] = $this->config->get('authorizenet_aim_hash');
  87. }
  88. if (isset($this->request->post['authorizenet_aim_server'])) {
  89. $this->data['authorizenet_aim_server'] = $this->request->post['authorizenet_aim_server'];
  90. } else {
  91. $this->data['authorizenet_aim_server'] = $this->config->get('authorizenet_aim_server');
  92. }
  93. if (isset($this->request->post['authorizenet_aim_mode'])) {
  94. $this->data['authorizenet_aim_mode'] = $this->request->post['authorizenet_aim_mode'];
  95. } else {
  96. $this->data['authorizenet_aim_mode'] = $this->config->get('authorizenet_aim_mode');
  97. }
  98. if (isset($this->request->post['authorizenet_aim_method'])) {
  99. $this->data['authorizenet_aim_method'] = $this->request->post['authorizenet_aim_method'];
  100. } else {
  101. $this->data['authorizenet_aim_method'] = $this->config->get('authorizenet_aim_method');
  102. }
  103. if (isset($this->request->post['authorizenet_aim_total'])) {
  104. $this->data['authorizenet_aim_total'] = $this->request->post['authorizenet_aim_total'];
  105. } else {
  106. $this->data['authorizenet_aim_total'] = $this->config->get('authorizenet_aim_total');
  107. }
  108. if (isset($this->request->post['authorizenet_aim_order_status_id'])) {
  109. $this->data['authorizenet_aim_order_status_id'] = $this->request->post['authorizenet_aim_order_status_id'];
  110. } else {
  111. $this->data['authorizenet_aim_order_status_id'] = $this->config->get('authorizenet_aim_order_status_id');
  112. }
  113. $this->load->model('localisation/order_status');
  114. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  115. if (isset($this->request->post['authorizenet_aim_geo_zone_id'])) {
  116. $this->data['authorizenet_aim_geo_zone_id'] = $this->request->post['authorizenet_aim_geo_zone_id'];
  117. } else {
  118. $this->data['authorizenet_aim_geo_zone_id'] = $this->config->get('authorizenet_aim_geo_zone_id');
  119. }
  120. $this->load->model('localisation/geo_zone');
  121. $this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
  122. if (isset($this->request->post['authorizenet_aim_status'])) {
  123. $this->data['authorizenet_aim_status'] = $this->request->post['authorizenet_aim_status'];
  124. } else {
  125. $this->data['authorizenet_aim_status'] = $this->config->get('authorizenet_aim_status');
  126. }
  127. if (isset($this->request->post['authorizenet_aim_sort_order'])) {
  128. $this->data['authorizenet_aim_sort_order'] = $this->request->post['authorizenet_aim_sort_order'];
  129. } else {
  130. $this->data['authorizenet_aim_sort_order'] = $this->config->get('authorizenet_aim_sort_order');
  131. }
  132. $this->template = 'payment/authorizenet_aim.tpl';
  133. $this->children = array(
  134. 'common/header',
  135. 'common/footer',
  136. );
  137. $this->response->setOutput($this->render());
  138. }
  139. private function validate() {
  140. if (!$this->user->hasPermission('modify', 'payment/authorizenet_aim')) {
  141. $this->error['warning'] = $this->language->get('error_permission');
  142. }
  143. if (!$this->request->post['authorizenet_aim_login']) {
  144. $this->error['login'] = $this->language->get('error_login');
  145. }
  146. if (!$this->request->post['authorizenet_aim_key']) {
  147. $this->error['key'] = $this->language->get('error_key');
  148. }
  149. if (!$this->request->post['authorizenet_aim_hash']) {
  150. $this->error['hash'] = $this->language->get('error_hash');
  151. }
  152. if (!$this->error) {
  153. return true;
  154. } else {
  155. return false;
  156. }
  157. }
  158. }
  159. ?>