Total Complexity | 56 |
Total Lines | 707 |
Duplicated Lines | 0 % |
Changes | 16 | ||
Bugs | 0 | Features | 0 |
Complex classes like pagantis often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use pagantis, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class pagantis |
||
15 | { |
||
16 | /** @var String $is_guest */ |
||
17 | public $is_guest; |
||
18 | |||
19 | /** @var Array $extraConfig */ |
||
20 | public $extraConfig; |
||
21 | |||
22 | /** @var String $form_action_url */ |
||
23 | public $form_action_url; |
||
24 | |||
25 | /** @var String $base_url */ |
||
26 | public $base_url; |
||
27 | |||
28 | /** @var String $os_order_reference */ |
||
29 | public $os_order_reference; |
||
30 | |||
31 | /** @var notifyController $pgNotify */ |
||
32 | public $pgNotify; |
||
33 | |||
34 | /** @var string $langCode */ |
||
35 | public $langCode = null; |
||
36 | |||
37 | public $defaultConfigs = array('PAGANTIS_TITLE'=>'Instant Financing', |
||
38 | 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'=>'pgSDK.simulator.types.SIMPLE', |
||
39 | 'PAGANTIS_SIMULATOR_DISPLAY_SKIN'=>'pgSDK.simulator.skins.BLUE', |
||
40 | 'PAGANTIS_SIMULATOR_DISPLAY_POSITION'=>'hookDisplayProductButtons', |
||
41 | 'PAGANTIS_SIMULATOR_START_INSTALLMENTS'=>3, |
||
42 | 'PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'=>12, |
||
43 | 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR'=>'default', |
||
44 | 'PAGANTIS_SIMULATOR_DISPLAY_CSS_POSITION'=>'pgSDK.simulator.positions.INNER', |
||
45 | 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'=>'default', |
||
46 | 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'=>'default', |
||
47 | 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR_CHECKOUT'=>'default', |
||
48 | 'PAGANTIS_FORM_DISPLAY_TYPE'=>0, |
||
49 | 'PAGANTIS_DISPLAY_MIN_AMOUNT'=>1, |
||
50 | 'PAGANTIS_URL_OK'=>'', |
||
51 | 'PAGANTIS_URL_KO'=>'', |
||
52 | 'PAGANTIS_TITLE_EXTRA' => 'Paga hasta en 12 cómodas cuotas con Paga+Tarde. Solicitud totalmente online y sin papeleos,¡y la respuesta es inmediata!', |
||
53 | 'PAGANTIS_PROMOTION' => '', |
||
54 | 'PAGANTIS_PROMOTED_PRODUCT_CODE' => '<p>PRODUCTO PROMOCIONADO CON<img style="height: 40px; vertical-align: middle;" src="/ext/modules/payment/pagantis/img/logo_pagantis.png"/>AL 0%' |
||
55 | ); |
||
56 | |||
57 | /** |
||
58 | * Constructor |
||
59 | */ |
||
60 | public function __construct() |
||
61 | { |
||
62 | $this->version = '8.0.0'; |
||
|
|||
63 | $this->code = 'pagantis'; |
||
64 | $this->sort_order = 0; |
||
65 | $this->description = $this->getDescription(); |
||
66 | $this->extraConfig = $this->getExtraConfig(); |
||
67 | |||
68 | if (strpos($_SERVER[REQUEST_URI], "checkout_payment.php") <= 0) { |
||
69 | $this->title = MODULE_PAYMENT_PAGANTIS_TEXT_ADMIN_TITLE; // Payment module title in Admin |
||
70 | } else { |
||
71 | $this->title = $this->extraConfig['PAGANTIS_TITLE'] .'<br/><br/><div class="buttonSet" style="display:none"></div><br/>'; // Payment module title in Catalog |
||
72 | } |
||
73 | |||
74 | $this->enabled = ((MODULE_PAYMENT_PAGANTIS_STATUS == 'True') ? true : false); |
||
75 | |||
76 | $this->base_url = dirname( |
||
77 | sprintf( |
||
78 | "%s://%s%s%s", |
||
79 | isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http', |
||
80 | $_SERVER['SERVER_NAME'], |
||
81 | isset($_SERVER['SERVER_PORT']) ? ":" . $_SERVER['SERVER_PORT'] : '', |
||
82 | $_SERVER['REQUEST_URI'] |
||
83 | ) |
||
84 | ); |
||
85 | |||
86 | $this->form_action_url = $this->base_url . '/ext/modules/payment/pagantis/bypass.php'; |
||
87 | |||
88 | if (defined('MODULE_PAYMENT_PAGANTIS_LANG_CODE')) { |
||
89 | $this->langCode = MODULE_PAYMENT_PAGANTIS_LANG_CODE; |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /*************** |
||
94 | * |
||
95 | * CLASS METHODS |
||
96 | * |
||
97 | **************/ |
||
98 | /** |
||
99 | * Here you can implement using payment zones (refer to standard PayPal module as reference) |
||
100 | */ |
||
101 | public function update_status() |
||
102 | { |
||
103 | |||
104 | } |
||
105 | |||
106 | /* |
||
107 | * Here you may define client side javascript that will verify any input fields you use in the payment method |
||
108 | * selection page. Refer to standard cc module as reference (cc.php). |
||
109 | */ |
||
110 | public function javascript_validation() |
||
111 | { |
||
112 | return false; |
||
113 | } |
||
114 | |||
115 | /* |
||
116 | * Llamada cuando el usuario esta en la pantalla de eleccion de tipo de pago |
||
117 | * This function outputs the payment method title/text and if required, the input fields. |
||
118 | * |
||
119 | * Si hay un pedido generado previamente y no confirmado, se borra |
||
120 | * Caso de uso: |
||
121 | * - el usuario llega a la pantalla de confirmacion |
||
122 | * - se genera el pedido (pero no se genera entrada en orders_status_history) |
||
123 | * - el usuario decide realizar algun cambio en su compra antes de pasar a pagantis |
||
124 | * - entra de nuevo en la pantalla de seleccion de tipo de pago (puede elegir otra forma de pago) |
||
125 | * - se comprueba que no exista el pedido generado anteriormente |
||
126 | * - se borra el pedido que se habia generado inicialmente. Ya no es valido |
||
127 | * |
||
128 | */ |
||
129 | public function selection() |
||
130 | { |
||
131 | return array('id' => $this->code, 'module' => $this->title); |
||
132 | } |
||
133 | |||
134 | /* |
||
135 | * Use this function implement any checks of any conditions after payment method has been selected. You most probably |
||
136 | * don't need to implement anything here. |
||
137 | */ |
||
138 | public function pre_confirmation_check() |
||
139 | { |
||
140 | return false; |
||
141 | } |
||
142 | |||
143 | /* |
||
144 | * Implement any checks or processing on the order information before proceeding to payment confirmation. You most |
||
145 | probably don't need to implement anything here. |
||
146 | * Llamada cuando el usuario entra en la pantalla de confirmacion |
||
147 | * |
||
148 | * Se genera el pedido: |
||
149 | * - con el estado predefinido para el modulo pagantis |
||
150 | * - sin notificacion a cliente ni administrador |
||
151 | * - no se borra el carrito asociado al pedido |
||
152 | * |
||
153 | */ |
||
154 | public function confirmation() |
||
155 | { |
||
156 | return false; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Build the data and actions to process when the "Submit" button is pressed on the order-confirmation screen. |
||
161 | * This sends the data to the payment gateway for processing. |
||
162 | * (These are hidden fields on the checkout confirmation page) |
||
163 | */ |
||
164 | public function process_button() |
||
165 | { |
||
166 | try { |
||
167 | include_once('./ext/modules/payment/pagantis/vendor/autoload.php'); |
||
168 | global $order, $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, |
||
169 | $payment, $comments, $customer_default_address_id, $cartID; |
||
170 | $global_vars = array(); |
||
171 | $global_vars['customer_id'] = serialize($customer_id); |
||
172 | $global_vars['sendTo'] = serialize($sendto); |
||
173 | $global_vars['billTo'] = serialize($billto); |
||
174 | $global_vars['cart'] = serialize($cart); |
||
175 | $global_vars['languages_id'] = serialize($languages_id); |
||
176 | $global_vars['currency'] = serialize($currency); |
||
177 | $global_vars['currencies'] = serialize($currencies); |
||
178 | $global_vars['shipping'] = serialize($shipping); |
||
179 | $global_vars['payment'] = serialize($payment); |
||
180 | $global_vars['comments'] = serialize($comments); |
||
181 | $global_vars['$customer_default_address_id'] = serialize($customer_default_address_id); |
||
182 | $global_vars['cartID'] = serialize($cartID); |
||
183 | $global_vars['sessiontoken'] = serialize($_SESSION['sessiontoken']); |
||
184 | |||
185 | if (!isset($order)) { |
||
186 | throw new UnknownException("Order not found"); |
||
187 | } |
||
188 | |||
189 | $id_hash = time() . serialize($order->products) . '' . serialize($order->customer) . '' . serialize($order->delivery); |
||
190 | $this->os_order_reference = md5($id_hash); |
||
191 | $_SESSION['order_id'] = $this->os_order_reference; |
||
192 | |||
193 | $userAddress = new Address(); |
||
194 | $userAddress |
||
195 | ->setZipCode($order->billing['postcode']) |
||
196 | ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
||
197 | ->setCountryCode('ES') |
||
198 | ->setCity($order->billing['city']) |
||
199 | ->setAddress($order->billing['street_address']) |
||
200 | ->setFixPhone($order->customer['telephone']) |
||
201 | ->setMobilePhone($order->customer['telephone']); |
||
202 | |||
203 | $orderBillingAddress = $userAddress; |
||
204 | |||
205 | $orderShippingAddress = new Address(); |
||
206 | $orderShippingAddress |
||
207 | ->setZipCode($order->delivery['postcode']) |
||
208 | ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
||
209 | ->setCountryCode('ES') |
||
210 | ->setCity($order->delivery['city']) |
||
211 | ->setAddress($order->delivery['street_address']) |
||
212 | ->setFixPhone($order->customer['telephone']) |
||
213 | ->setMobilePhone($order->customer['telephone']); |
||
214 | |||
215 | $orderUser = new \Pagantis\OrdersApiClient\Model\Order\User(); |
||
216 | $orderUser |
||
217 | ->setAddress($userAddress) |
||
218 | ->setFullName($order->billing['firstname'] . ' ' . $order->billing['lastname']) |
||
219 | ->setBillingAddress($orderBillingAddress) |
||
220 | ->setEmail($order->customer['email_address']) |
||
221 | ->setFixPhone($order->customer['telephone']) |
||
222 | ->setMobilePhone($order->customer['telephone']) |
||
223 | ->setShippingAddress($orderShippingAddress); |
||
224 | |||
225 | $previousOrders = $this->getOrders(); |
||
226 | foreach ((array)$previousOrders as $k => $previousOrder) { |
||
227 | $orderHistory = new \Pagantis\OrdersApiClient\Model\Order\User\OrderHistory(); |
||
228 | $orderHistory |
||
229 | ->setAmount(intval(100 * $previousOrder['value'])) |
||
230 | ->setDate(new \DateTime($previousOrder['date_purchased'])); |
||
231 | $orderUser->addOrderHistory($orderHistory); |
||
232 | } |
||
233 | |||
234 | $details = new \Pagantis\OrdersApiClient\Model\Order\ShoppingCart\Details(); |
||
235 | $shippingCost = number_format($order->info['shipping_cost'], 2, '.', ''); |
||
236 | $details->setShippingCost(intval(strval(100 * $shippingCost))); |
||
237 | |||
238 | $metadataOrder = new \Pagantis\OrdersApiClient\Model\Order\Metadata(); |
||
239 | $metadata = array( |
||
240 | 'oscommerce' => PROJECT_VERSION, |
||
241 | 'pagantis' => $this->version, |
||
242 | 'php' => phpversion() |
||
243 | ); |
||
244 | foreach ($metadata as $key => $metadatum) { |
||
245 | $metadataOrder->addMetadata($key, $metadatum); |
||
246 | } |
||
247 | |||
248 | $promotedAmount = 0; |
||
249 | foreach ($order->products as $item) { |
||
250 | $promotedProduct = $this->isPromoted($item); |
||
251 | $product = new \Pagantis\OrdersApiClient\Model\Order\ShoppingCart\Details\Product(); |
||
252 | $product |
||
253 | ->setAmount(intval(100 * number_format(($item['final_price'] * $item['qty']), 2))) |
||
254 | ->setQuantity(intval($item['qty'])) |
||
255 | ->setDescription($item['name']); |
||
256 | if ($promotedProduct) { |
||
257 | $promotedAmount+=$product->getAmount(); |
||
258 | $promotedMessage = $product->getDescription()."-Price:".$item['final_price']."-Qty:".$product->getQuantity(); |
||
259 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
||
260 | } |
||
261 | $details->addProduct($product); |
||
262 | } |
||
263 | |||
264 | $orderShoppingCart = new \Pagantis\OrdersApiClient\Model\Order\ShoppingCart(); |
||
265 | $orderShoppingCart |
||
266 | ->setDetails($details) |
||
267 | ->setOrderReference($this->os_order_reference) |
||
268 | ->setTotalAmount(intval($order->info['total'] * 100)); |
||
269 | //->setPromotedAmount($promotedAmount); |
||
270 | |||
271 | $callback_url = $this->base_url.'/ext/modules/payment/pagantis/notify.php'; |
||
272 | $checkoutProcessUrl = htmlspecialchars_decode( |
||
273 | tep_href_link(FILENAME_CHECKOUT_PROCESS, "order_id=$this->os_order_reference&from=order", 'SSL', true) |
||
274 | ); |
||
275 | |||
276 | $cancelUrl = trim(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL', false)); |
||
277 | if ($this->extraConfig['PAGANTIS_URL_KO']!='') { |
||
278 | $koUrl = $this->extraConfig['PAGANTIS_URL_KO']; |
||
279 | } else { |
||
280 | $koUrl = $cancelUrl; |
||
281 | } |
||
282 | |||
283 | $orderConfigurationUrls = new \Pagantis\OrdersApiClient\Model\Order\Configuration\Urls(); |
||
284 | $orderConfigurationUrls |
||
285 | ->setCancel($cancelUrl) |
||
286 | ->setKo($koUrl) |
||
287 | ->setAuthorizedNotificationCallback($callback_url) |
||
288 | ->setRejectedNotificationCallback($callback_url) |
||
289 | ->setOk($checkoutProcessUrl); |
||
290 | |||
291 | |||
292 | $orderChannel = new \Pagantis\OrdersApiClient\Model\Order\Configuration\Channel(); |
||
293 | $orderChannel |
||
294 | ->setAssistedSale(false) |
||
295 | ->setType(\Pagantis\OrdersApiClient\Model\Order\Configuration\Channel::ONLINE); |
||
296 | $orderConfiguration = new \Pagantis\OrdersApiClient\Model\Order\Configuration(); |
||
297 | $orderConfiguration |
||
298 | ->setChannel($orderChannel) |
||
299 | ->setUrls($orderConfigurationUrls); |
||
300 | |||
301 | $orderApiClient = new \Pagantis\OrdersApiClient\Model\Order(); |
||
302 | $orderApiClient |
||
303 | ->setConfiguration($orderConfiguration) |
||
304 | ->setMetadata($metadataOrder) |
||
305 | ->setShoppingCart($orderShoppingCart) |
||
306 | ->setUser($orderUser); |
||
307 | |||
308 | $publicKey = trim(MODULE_PAYMENT_PAGANTIS_PK); |
||
309 | $secretKey = trim(MODULE_PAYMENT_PAGANTIS_SK); |
||
310 | $orderClient = new \Pagantis\OrdersApiClient\Client($publicKey, $secretKey); |
||
311 | $pagantisOrder = $orderClient->createOrder($orderApiClient); |
||
312 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
||
313 | $url = $pagantisOrder->getActionUrls()->getForm(); |
||
314 | $this->insertRow($this->os_order_reference, $pagantisOrder->getId(), serialize($global_vars)); |
||
315 | } else { |
||
316 | throw new OrderNotFoundException(); |
||
317 | } |
||
318 | |||
319 | if ($url == "") { |
||
320 | throw new UnknownException(_("No ha sido posible obtener una respuesta de Pagantis")); |
||
321 | } else { |
||
322 | $output = "\n"; |
||
323 | $output .= tep_draw_hidden_field("formUrl", $url) . "\n"; |
||
324 | $output .= tep_draw_hidden_field("cancelUrl", $cancelUrl) . "\n"; |
||
325 | return $output; |
||
326 | |||
327 | } //TODO IFRAME |
||
328 | } catch (\Exception $exception) { |
||
329 | tep_redirect($cancelUrl); |
||
330 | return; |
||
331 | } |
||
332 | } |
||
333 | |||
334 | /** |
||
335 | * @throws Exception |
||
336 | */ |
||
337 | public function before_process() |
||
338 | { |
||
339 | include_once('./ext/modules/payment/pagantis/notifyController.php'); |
||
340 | $this->pgNotify = new notifyController(); |
||
341 | $this->pgNotify->setOscommerceOrderId($_GET['order_id']); |
||
342 | $this->pgNotify->setOrigin(isset($_GET['from']) ? ($_GET['from']) : 'order'); |
||
343 | $this->pgNotify->processInformation(); |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Post-processing activities |
||
348 | * |
||
349 | * @return boolean |
||
350 | */ |
||
351 | public function after_process() |
||
352 | { |
||
353 | $this->pgNotify->confirmInformation(); |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * @return bool |
||
358 | */ |
||
359 | public function output_error() |
||
360 | { |
||
361 | return false; |
||
362 | } |
||
363 | |||
364 | /** |
||
365 | * @return mixed |
||
366 | */ |
||
367 | public function check() |
||
368 | { |
||
369 | if (!isset($this->_check)) { |
||
370 | $query = "select * from ".TABLE_CONFIGURATION." where configuration_key = 'MODULE_PAYMENT_PAGANTIS_STATUS'"; |
||
371 | $check_query = tep_db_query($query); |
||
372 | $this->_check = tep_db_num_rows($check_query); |
||
373 | } |
||
374 | $this->installPagantisTables(); |
||
375 | return $this->_check; |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * This is where you define module's configurations (displayed in admin). |
||
380 | */ |
||
381 | public function install() |
||
478 | } |
||
479 | |||
480 | /** |
||
481 | * Create the neccesary tables for the module |
||
482 | */ |
||
483 | private function installPagantisTables() |
||
484 | { |
||
485 | $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_LOG . " ( |
||
486 | id int NOT NULL AUTO_INCREMENT, |
||
487 | log text NOT NULL, |
||
488 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, |
||
489 | UNIQUE KEY id (id))"; |
||
490 | tep_db_query($sql); |
||
491 | |||
492 | $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONFIG . " ( |
||
493 | id int NOT NULL AUTO_INCREMENT, |
||
494 | config varchar(60) NOT NULL, |
||
495 | value varchar(200) NOT NULL, |
||
496 | UNIQUE KEY id(id))"; |
||
497 | tep_db_query($sql); |
||
498 | |||
499 | // check if table has records |
||
500 | $check_query = tep_db_query("select value from " . TABLE_PAGANTIS_CONFIG); |
||
501 | if (tep_db_num_rows($check_query) === 0) { |
||
502 | foreach ((array)$this->defaultConfigs as $configKey => $configValue) { |
||
503 | $query = "INSERT INTO " . TABLE_PAGANTIS_CONFIG . " |
||
504 | ( |
||
505 | config, |
||
506 | value |
||
507 | ) |
||
508 | values |
||
509 | ( |
||
510 | '$configKey', |
||
511 | '$configValue' |
||
512 | )"; |
||
513 | tep_db_query($query); |
||
514 | } |
||
515 | } |
||
516 | |||
517 | $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_ORDERS . " ( |
||
518 | id int NOT NULL AUTO_INCREMENT, |
||
519 | os_order_id varchar(50), |
||
520 | os_order_reference varchar(50) NOT NULL, |
||
521 | pagantis_order_id varchar(50) NOT NULL, |
||
522 | globals text, |
||
523 | UNIQUE KEY id(id))"; |
||
524 | tep_db_query($sql); |
||
525 | |||
526 | $sql = "CREATE TABLE IF NOT EXISTS " . TABLE_PAGANTIS_CONCURRENCY . " ( |
||
527 | id varchar(50) NOT NULL, |
||
528 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
||
529 | UNIQUE KEY id(id))"; |
||
530 | tep_db_query($sql); |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * Standard functionality to uninstall the module. |
||
535 | */ |
||
536 | public function remove() |
||
537 | { |
||
538 | $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_LOG . "'"); |
||
539 | if (tep_db_num_rows($checkTable) > 0) { |
||
540 | tep_db_query("drop table " . TABLE_PAGANTIS_LOG); |
||
541 | } |
||
542 | |||
543 | $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONFIG . "'"); |
||
544 | if (tep_db_num_rows($checkTable) > 0) { |
||
545 | tep_db_query("drop table " . TABLE_PAGANTIS_CONFIG); |
||
546 | } |
||
547 | |||
548 | $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_ORDERS . "'"); |
||
549 | if (tep_db_num_rows($checkTable) > 0) { |
||
550 | tep_db_query("drop table " . TABLE_PAGANTIS_ORDERS); |
||
551 | } |
||
552 | |||
553 | $checkTable = tep_db_query("SHOW TABLES LIKE '" . TABLE_PAGANTIS_CONCURRENCY . "'"); |
||
554 | if (tep_db_num_rows($checkTable) > 0) { |
||
555 | tep_db_query("drop table " . TABLE_PAGANTIS_CONCURRENCY); |
||
556 | } |
||
557 | |||
558 | tep_db_query("DELETE FROM ". TABLE_CONFIGURATION ." where configuration_key in ('MODULE_PAYMENT_PAGANTIS_STATUS','MODULE_PAYMENT_PAGANTIS_PK','MODULE_PAYMENT_PAGANTIS_SK')"); |
||
559 | |||
560 | $query = "delete from " . TABLE_CONFIGURATION . " where configuration_key like '%_PAGANTIS_%'"; |
||
561 | tep_db_query($query); |
||
562 | |||
563 | $this->uninstallSimulator(); |
||
564 | } |
||
565 | |||
566 | /** |
||
567 | * Internal list of configuration keys used for configuration of the module |
||
568 | * |
||
569 | * @return array |
||
570 | */ |
||
571 | public function keys() |
||
572 | { |
||
573 | return array( |
||
574 | 'MODULE_PAYMENT_PAGANTIS_STATUS', |
||
575 | 'MODULE_PAYMENT_PAGANTIS_PK', |
||
576 | 'MODULE_PAYMENT_PAGANTIS_SK', |
||
577 | 'MODULE_PAYMENT_PAGANTIS_SIMULATOR' |
||
578 | ); |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * @return array |
||
583 | */ |
||
584 | private function getOrders() |
||
585 | { |
||
586 | $this->is_guest = 'true'; |
||
587 | if (trim($_SESSION['customer_id']) != '') { |
||
588 | $this->is_guest = 'false'; |
||
589 | $query = sprintf( |
||
590 | "select orders_total.value, orders.date_purchased from orders |
||
591 | JOIN orders_status_history ON orders.orders_id=orders_status_history.orders_id |
||
592 | JOIN orders_total ON orders.orders_id=orders_total.orders_id |
||
593 | where orders.customers_id='%s' and orders_status_history.orders_status_id in ('2','3') |
||
594 | and orders_total.class='ot_total'", |
||
595 | $_SESSION['customer_id'] |
||
596 | ); |
||
597 | |||
598 | $response = array(); |
||
599 | $resultsSelect = tep_db_query($query); |
||
600 | while ($orderRow = tep_db_fetch_array($resultsSelect)) { |
||
601 | $response[] = $orderRow; |
||
602 | } |
||
603 | } |
||
604 | |||
605 | return $response; |
||
606 | } |
||
607 | |||
608 | /** |
||
609 | * @param $orderId |
||
610 | * @param $pagantisOrderId |
||
611 | * @param $globalVars |
||
612 | */ |
||
613 | private function insertRow($orderId, $pagantisOrderId, $globalVars) |
||
626 | } |
||
627 | |||
628 | /** |
||
629 | * @return array |
||
630 | */ |
||
631 | private function getExtraConfig() |
||
645 | } |
||
646 | |||
647 | /** |
||
648 | * @param $item |
||
649 | * |
||
650 | * @return bool |
||
651 | */ |
||
652 | private function isPromoted($item) |
||
653 | { |
||
654 | //HOOK WHILE PROMOTED AMOUNT IS NOT WORKING |
||
655 | return false; |
||
656 | |||
657 | $productId = explode('{', $item['id'], 1); |
||
658 | $productId = $productId['0']; |
||
659 | |||
660 | if ($this->extraConfig['PAGANTIS_PROMOTION'] == '') { |
||
661 | $promotedProducts = array(); |
||
662 | } else { |
||
663 | $promotedProducts = array_values((array)unserialize($this->extraConfig['PAGANTIS_PROMOTION'])); |
||
664 | } |
||
665 | |||
666 | return (in_array($productId, $promotedProducts)); |
||
667 | } |
||
668 | |||
669 | /** |
||
670 | * @return string |
||
671 | */ |
||
672 | private function getDescription() |
||
685 | } |
||
686 | |||
687 | /** |
||
688 | * @return bool |
||
689 | */ |
||
690 | private function installSimulator() |
||
691 | { |
||
692 | $checkSimulator = tep_db_query("select configuration_key, configuration_value from " .TABLE_CONFIGURATION ." |
||
693 | where configuration_key like 'MODULE_HEADER_TAGS_INSTALLED' |
||
704 | } |
||
705 | |||
706 | private function uninstallSimulator() |
||
723 |