@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <script> |
2 | 2 | function findPriceSelector() |
3 | 3 | { |
4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>; |
|
4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>; |
|
5 | 5 | return priceSelectors.find(function(candidateSelector) { |
6 | 6 | var priceDOM = document.querySelector(candidateSelector); |
7 | 7 | return (priceDOM != null ); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function findQuantitySelector() |
13 | 13 | { |
14 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
14 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
15 | 15 | return quantitySelectors.find(function(candidateSelector) { |
16 | 16 | var priceDOM = document.querySelector(candidateSelector); |
17 | 17 | return (priceDOM != null ); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return finishInterval(); |
52 | 52 | } |
53 | 53 | |
54 | - var price = '<?php echo $total;?>'; |
|
54 | + var price = '<?php echo $total; ?>'; |
|
55 | 55 | |
56 | 56 | var locale = '<?php echo $locale; ?>'; |
57 | 57 | if (locale == 'es' || locale == '') { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | var sdk = pgSDK; |
61 | 61 | } |
62 | 62 | |
63 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
63 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
64 | 64 | if (positionSelector === 'default') { |
65 | 65 | positionSelector = '.pagantisSimulator'; |
66 | 66 | } |
@@ -53,37 +53,37 @@ discard block |
||
53 | 53 | $this->method_title = ucfirst($this->id); |
54 | 54 | |
55 | 55 | //Useful vars |
56 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
56 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
57 | 57 | $this->allowed_currencies = array("EUR"); |
58 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
58 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
59 | 59 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
60 | 60 | $this->language = strstr(get_locale(), '_', true); |
61 | 61 | |
62 | - if ($this->language == 'es' || $this->language == '') { |
|
62 | + if ($this->language=='es' || $this->language=='') { |
|
63 | 63 | $this->icon = esc_url(plugins_url('../assets/images/logopagamastarde.png', __FILE__)); |
64 | 64 | } else { |
65 | 65 | $this->icon = esc_url(plugins_url('../assets/images/logo.png', __FILE__)); |
66 | 66 | } |
67 | 67 | |
68 | 68 | //Panel form fields |
69 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
69 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
70 | 70 | $this->init_settings(); |
71 | 71 | |
72 | 72 | $this->extraConfig = $this->getExtraConfig(); |
73 | 73 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
74 | 74 | |
75 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
76 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
75 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
76 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
77 | 77 | foreach ($this->settings as $setting_key => $setting_value) { |
78 | 78 | $this->$setting_key = $setting_value; |
79 | 79 | } |
80 | 80 | |
81 | 81 | //Hooks |
82 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
83 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
84 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
85 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
86 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
82 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
83 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
84 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
85 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
86 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
87 | 87 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
88 | 88 | } |
89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function loadPagantisTranslation($mofile, $domain) |
97 | 97 | { |
98 | - if ('pagantis' === $domain) { |
|
99 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
98 | + if ('pagantis'===$domain) { |
|
99 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
100 | 100 | } |
101 | 101 | return $mofile; |
102 | 102 | } |
@@ -129,24 +129,24 @@ discard block |
||
129 | 129 | public function pagantisCheckFields() |
130 | 130 | { |
131 | 131 | $error_string = ''; |
132 | - if ($this->settings['enabled'] !== 'yes') { |
|
132 | + if ($this->settings['enabled']!=='yes') { |
|
133 | 133 | return; |
134 | 134 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
135 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
135 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
136 | 136 | $this->settings['enabled'] = 'no'; |
137 | 137 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") { |
138 | 138 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
139 | 139 | $this->settings['enabled'] = 'no'; |
140 | 140 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
141 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
141 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
142 | 142 | $this->settings['enabled'] = 'no'; |
143 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
144 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
143 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
144 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
145 | 145 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
146 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
147 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
146 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
147 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
148 | 148 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
149 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
149 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
150 | 150 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
151 | 151 | } |
152 | 152 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $shippingAddress = $order->get_address('shipping'); |
182 | 182 | $billingAddress = $order->get_address('billing'); |
183 | - if ($shippingAddress['address_1'] == '') { |
|
183 | + if ($shippingAddress['address_1']=='') { |
|
184 | 184 | $shippingAddress = $billingAddress; |
185 | 185 | } |
186 | 186 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ->setNationalId($national_id) |
208 | 208 | ->setTaxId($tax_id) |
209 | 209 | ; |
210 | - $orderBillingAddress = new Address(); |
|
210 | + $orderBillingAddress = new Address(); |
|
211 | 211 | $orderBillingAddress |
212 | 212 | ->setZipCode($billingAddress['postcode']) |
213 | 213 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
339 | 339 | } |
340 | 340 | } catch (\Exception $exception) { |
341 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
341 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
342 | 342 | $this->insertLog($exception); |
343 | 343 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
344 | 344 | wp_redirect($checkout_url); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function pagantisNotification() |
353 | 353 | { |
354 | 354 | try { |
355 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
355 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
356 | 356 | |
357 | 357 | include_once('notifyController.php'); |
358 | 358 | $notify = new WcPagantisNotify(); |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function pagantisCompleteStatus($status, $order_id, $order) |
393 | 393 | { |
394 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
395 | - if ($order->get_status() == 'failed') { |
|
394 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
395 | + if ($order->get_status()=='failed') { |
|
396 | 396 | $status = 'processing'; |
397 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
397 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
398 | 398 | $status = 'processing'; |
399 | 399 | } |
400 | 400 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
419 | 419 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
420 | 420 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
421 | - (int)$this->get_order_total()>$this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
421 | + (int) $this->get_order_total() > $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
422 | 422 | return true; |
423 | 423 | } |
424 | 424 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
448 | 448 | if (strpos($redirectUrl, 'order-pay=')===false) { |
449 | - $redirectUrl.="&order-pay=".$order_id; |
|
449 | + $redirectUrl .= "&order-pay=".$order_id; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return array( |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | ); |
456 | 456 | |
457 | 457 | } catch (Exception $e) { |
458 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
458 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
459 | 459 | return array(); |
460 | 460 | } |
461 | 461 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | private function generateUrl($url) |
515 | 515 | { |
516 | 516 | $parsed_url = parse_url($url); |
517 | - if ($parsed_url !== false) { |
|
517 | + if ($parsed_url!==false) { |
|
518 | 518 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
519 | 519 | parse_str($parsed_url['query'], $arrayParams); |
520 | 520 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -562,11 +562,10 @@ discard block |
||
562 | 562 | private function getKeysUrl($order, $url) |
563 | 563 | { |
564 | 564 | $defaultFields = (get_class($order)=='WC_Order') ? |
565 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
566 | - array(); |
|
565 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
567 | 566 | |
568 | 567 | $parsedUrl = parse_url($url); |
569 | - if ($parsedUrl !== false) { |
|
568 | + if ($parsedUrl!==false) { |
|
570 | 569 | //Replace parameters from url |
571 | 570 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
572 | 571 | |
@@ -611,7 +610,7 @@ discard block |
||
611 | 610 | foreach ($arrayParams as $keyParam => $valueParam) { |
612 | 611 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
613 | 612 | if (count($match)) { |
614 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
613 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
615 | 614 | $arrayParams[$keyParam] = $defaultFields[$key]; |
616 | 615 | } |
617 | 616 | } |
@@ -626,13 +625,13 @@ discard block |
||
626 | 625 | */ |
627 | 626 | private function unparseUrl($parsed_url) |
628 | 627 | { |
629 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
628 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
630 | 629 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
631 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
632 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
633 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
630 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
631 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
632 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
634 | 633 | $path = $parsed_url['path']; |
635 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
634 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
636 | 635 | } |
637 | 636 | |
638 | 637 | /** |
@@ -654,20 +653,20 @@ discard block |
||
654 | 653 | $is_guest = "false"; |
655 | 654 | $sign_up = substr($current_user->user_registered, 0, 10); |
656 | 655 | $customer_orders = get_posts(array( |
657 | - 'numberposts' => - 1, |
|
656 | + 'numberposts' => -1, |
|
658 | 657 | 'meta_key' => '_customer_user', |
659 | 658 | 'meta_value' => $current_user->ID, |
660 | - 'post_type' => array( 'shop_order' ), |
|
661 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
659 | + 'post_type' => array('shop_order'), |
|
660 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
662 | 661 | )); |
663 | 662 | } else { |
664 | 663 | $is_guest = "true"; |
665 | 664 | $customer_orders = get_posts(array( |
666 | - 'numberposts' => - 1, |
|
665 | + 'numberposts' => -1, |
|
667 | 666 | 'meta_key' => '_billing_email', |
668 | 667 | 'meta_value' => $billingEmail, |
669 | - 'post_type' => array( 'shop_order' ), |
|
670 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
668 | + 'post_type' => array('shop_order'), |
|
669 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
671 | 670 | )); |
672 | 671 | foreach ($customer_orders as $customer_order) { |
673 | 672 | if (trim($sign_up)=='' || |
@@ -696,7 +695,7 @@ discard block |
||
696 | 695 | //Check if id exists |
697 | 696 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
698 | 697 | $countResults = count($resultsSelect); |
699 | - if ($countResults == 0) { |
|
698 | + if ($countResults==0) { |
|
700 | 699 | $wpdb->insert( |
701 | 700 | $tableName, |
702 | 701 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -721,7 +720,7 @@ discard block |
||
721 | 720 | global $wpdb; |
722 | 721 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
723 | 722 | |
724 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
723 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
725 | 724 | $charset_collate = $wpdb->get_charset_collate(); |
726 | 725 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
727 | 726 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -754,9 +753,9 @@ discard block |
||
754 | 753 | */ |
755 | 754 | private function getNationalId($order) |
756 | 755 | { |
757 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
756 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
758 | 757 | $data = $mdObject->get_data(); |
759 | - if ($data['key'] == 'vat_number') { |
|
758 | + if ($data['key']=='vat_number') { |
|
760 | 759 | return $data['value']; |
761 | 760 | } |
762 | 761 | } |
@@ -771,9 +770,9 @@ discard block |
||
771 | 770 | */ |
772 | 771 | private function getTaxId($order) |
773 | 772 | { |
774 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
773 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
775 | 774 | $data = $mdObject->get_data(); |
776 | - if ($data['key'] == 'billing_cfpiva') { |
|
775 | + if ($data['key']=='billing_cfpiva') { |
|
777 | 776 | return $data['value']; |
778 | 777 | } |
779 | 778 | } |
@@ -803,7 +802,7 @@ discard block |
||
803 | 802 | { |
804 | 803 | global $wpdb; |
805 | 804 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
806 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
805 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
807 | 806 | $charset_collate = $wpdb->get_charset_collate(); |
808 | 807 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
809 | 808 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -192,10 +192,10 @@ |
||
192 | 192 | |
193 | 193 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
194 | 194 | $logMessage = "WARNING checkMerchantOrderStatus." . |
195 | - " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
196 | - " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
197 | - " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
198 | - " Pagantis order status:".$this->pagantisOrder->getId(); |
|
195 | + " Merchant order id:".$this->woocommerceOrder->get_id(). |
|
196 | + " Merchant order status:".$this->woocommerceOrder->get_status(). |
|
197 | + " Pagantis order id:".$this->pagantisOrder->getStatus(). |
|
198 | + " Pagantis order status:".$this->pagantisOrder->getId(); |
|
199 | 199 | |
200 | 200 | $this->insertLog(null, $logMessage); |
201 | 201 | $this->woocommerceOrder->add_order_note($logMessage); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | private function checkConcurrency() |
105 | 105 | { |
106 | 106 | $this->woocommerceOrderId = $_GET['order-received']; |
107 | - if ($this->woocommerceOrderId == '') { |
|
107 | + if ($this->woocommerceOrderId=='') { |
|
108 | 108 | throw new QuoteNotFoundException(); |
109 | 109 | } |
110 | 110 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); |
137 | 137 | $this->pagantisOrderId = $queryResult->order_id; |
138 | 138 | |
139 | - if ($this->pagantisOrderId == '') { |
|
139 | + if ($this->pagantisOrderId=='') { |
|
140 | 140 | throw new NoIdentificationException(); |
141 | 141 | } |
142 | 142 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $status = '-'; |
171 | 171 | } |
172 | 172 | |
173 | - if ($status === Order::STATUS_CONFIRMED) { |
|
173 | + if ($status===Order::STATUS_CONFIRMED) { |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | throw new WrongStatusException($status); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ); |
192 | 192 | |
193 | 193 | if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM |
194 | - $logMessage = "WARNING checkMerchantOrderStatus." . |
|
194 | + $logMessage = "WARNING checkMerchantOrderStatus.". |
|
195 | 195 | " Merchant order id:".$this->woocommerceOrder->get_id(). |
196 | 196 | " Merchant order status:".$this->woocommerceOrder->get_status(). |
197 | 197 | " Pagantis order id:".$this->pagantisOrder->getStatus(). |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | { |
214 | 214 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
215 | 215 | $wcAmount = (string) floor(100 * $this->woocommerceOrder->get_total()); |
216 | - if ($pagantisAmount != $wcAmount) { |
|
216 | + if ($pagantisAmount!=$wcAmount) { |
|
217 | 217 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
218 | 218 | } |
219 | 219 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId); |
238 | 238 | } catch (\Exception $e) { |
239 | 239 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId); |
240 | - if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { |
|
240 | + if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { |
|
241 | 241 | throw new UnknownException($e->getMessage()); |
242 | 242 | } else { |
243 | 243 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process'; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | global $wpdb; |
262 | 262 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
263 | 263 | |
264 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
264 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
265 | 265 | $charset_collate = $wpdb->get_charset_collate(); |
266 | 266 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
267 | 267 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | global $wpdb; |
280 | 280 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
281 | 281 | |
282 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
282 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
283 | 283 | $charset_collate = $wpdb->get_charset_collate(); |
284 | 284 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
285 | 285 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | { |
400 | 400 | global $wpdb; |
401 | 401 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
402 | - if ($orderId == null) { |
|
402 | + if ($orderId==null) { |
|
403 | 403 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)"; |
404 | 404 | } else { |
405 | 405 | $query = "DELETE FROM $tableName WHERE order_id = $orderId"; |
406 | 406 | } |
407 | 407 | $resultDelete = $wpdb->query($query); |
408 | - if ($resultDelete === false) { |
|
408 | + if ($resultDelete===false) { |
|
409 | 409 | throw new ConcurrencyException(); |
410 | 410 | } |
411 | 411 | } |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | global $wpdb; |
419 | 419 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
420 | 420 | $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); |
421 | - if ($insertResult === false) { |
|
422 | - if ($this->getOrigin() == 'Notify') { |
|
421 | + if ($insertResult===false) { |
|
422 | + if ($this->getOrigin()=='Notify') { |
|
423 | 423 | throw new ConcurrencyException(); |
424 | 424 | } else { |
425 | 425 | $query = sprintf( |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | ); |
431 | 431 | $resultSeconds = $wpdb->get_row($query); |
432 | 432 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0; |
433 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
434 | - sleep($secondsToExpire+1); |
|
433 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds; |
|
434 | + sleep($secondsToExpire + 1); |
|
435 | 435 | |
436 | 436 | $logMessage = sprintf( |
437 | 437 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds", |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | { |
457 | 457 | $this->unblockConcurrency($this->woocommerceOrderId); |
458 | 458 | |
459 | - if ($exception == null) { |
|
459 | + if ($exception==null) { |
|
460 | 460 | $jsonResponse = new JsonSuccessResponse(); |
461 | 461 | } else { |
462 | 462 | $jsonResponse = new JsonExceptionResponse(); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId); |
467 | 467 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId); |
468 | 468 | |
469 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
469 | + if ($_SERVER['REQUEST_METHOD']=='POST') { |
|
470 | 470 | $jsonResponse->printResponse(); |
471 | 471 | } else { |
472 | 472 | return $jsonResponse; |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function loadPagantisTranslation($mofile, $domain) |
85 | 85 | { |
86 | - if ('pagantis' === $domain) { |
|
87 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
86 | + if ('pagantis'===$domain) { |
|
87 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
88 | 88 | } |
89 | 89 | return $mofile; |
90 | 90 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | global $wpdb; |
98 | 98 | |
99 | 99 | $tableName = $wpdb->prefix.self::CONCURRENCY_TABLE; |
100 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
100 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
101 | 101 | $charset_collate = $wpdb->get_charset_collate(); |
102 | 102 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL, |
103 | 103 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate"; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
109 | 109 | |
110 | 110 | //Check if table exists |
111 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
111 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
112 | 112 | if ($tableExists) { |
113 | 113 | $charset_collate = $wpdb->get_charset_collate(); |
114 | 114 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | $locale = strtolower(strstr(get_locale(), '_', true)); |
163 | 163 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
164 | 164 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
165 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
166 | - $cfg['simulator'] !== 'yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
167 | - !$allowedCountry ) { |
|
165 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
166 | + $cfg['simulator']!=='yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
167 | + !$allowedCountry) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function addPagantisGateway($methods) |
194 | 194 | { |
195 | - if (! class_exists('WC_Payment_Gateway')) { |
|
195 | + if (!class_exists('WC_Payment_Gateway')) { |
|
196 | 196 | return $methods; |
197 | 197 | } |
198 | 198 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function pagantisRowMeta($links, $file) |
249 | 249 | { |
250 | - if ($file == plugin_basename(__FILE__)) { |
|
250 | + if ($file==plugin_basename(__FILE__)) { |
|
251 | 251 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
252 | 252 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
253 | 253 | __('API documentation', 'pagantis').'</a>'; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
276 | 276 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
277 | 277 | $results = $wpdb->get_results($query); |
278 | - if (isset($results) && $privateKey == $secretKey) { |
|
278 | + if (isset($results) && $privateKey==$secretKey) { |
|
279 | 279 | foreach ($results as $key => $result) { |
280 | 280 | $response[$key]['timestamp'] = $result->createdAt; |
281 | 281 | $response[$key]['log'] = json_decode($result->log); |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | |
303 | 303 | $filters = ($data->get_params()); |
304 | 304 | $secretKey = $filters['secret']; |
305 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
305 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
306 | 306 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
307 | - if ($privateKey != $secretKey) { |
|
307 | + if ($privateKey!=$secretKey) { |
|
308 | 308 | $response['status'] = 401; |
309 | 309 | $response['result'] = 'Unauthorized'; |
310 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
310 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
311 | 311 | if (count($_POST)) { |
312 | 312 | foreach ($_POST as $config => $value) { |
313 | 313 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | where tn.post_type='shop_order' and tn.post_date>'".$from->format("Y-m-d")."' and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; |
368 | 368 | $results = $wpdb->get_results($query); |
369 | 369 | |
370 | - if (isset($results) && $privateKey == $secretKey) { |
|
370 | + if (isset($results) && $privateKey==$secretKey) { |
|
371 | 371 | foreach ($results as $result) { |
372 | 372 | $key = $result->ID; |
373 | 373 | $response['message'][$key]['timestamp'] = $result->post_date; |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | private function prepareQuantitySelector() |
451 | 451 | { |
452 | 452 | $css_quantity_selector = $this->extraConfig['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
453 | - if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { |
|
453 | + if ($css_quantity_selector=='default' || $css_quantity_selector=='') { |
|
454 | 454 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR']; |
455 | 455 | } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it |
456 | 456 | $css_quantity_selector = serialize(array($css_quantity_selector)); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | private function preparePriceSelector() |
466 | 466 | { |
467 | 467 | $css_price_selector = $this->extraConfig['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
468 | - if ($css_price_selector == 'default' || $css_price_selector == '') { |
|
468 | + if ($css_price_selector=='default' || $css_price_selector=='') { |
|
469 | 469 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR']; |
470 | 470 | } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it |
471 | 471 | $css_price_selector = serialize(array($css_price_selector)); |