@@ -299,9 +299,9 @@  | 
                                                    ||
| 299 | 299 |                  if ($promotedProduct == 'true') { | 
                                                        
| 300 | 300 | $promotedAmount+=$product->getAmount();  | 
                                                        
| 301 | 301 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .  | 
                                                        
| 302 | - ' - Price: ' . $item->get_total() .  | 
                                                        |
| 303 | - ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 304 | - ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 302 | + ' - Price: ' . $item->get_total() .  | 
                                                        |
| 303 | + ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 304 | + ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 305 | 305 | $promotedMessage = substr($promotedMessage, 0, 999);  | 
                                                        
| 306 | 306 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 307 | 307 | }  | 
                                                        
@@ -56,7 +56,7 @@ discard block  | 
                                                    ||
| 56 | 56 | $this->method_title = ucfirst($this->id);  | 
                                                        
| 57 | 57 | |
| 58 | 58 | //Useful vars  | 
                                                        
| 59 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/';  | 
                                                        |
| 59 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/';  | 
                                                        |
| 60 | 60 | $this->allowed_currencies = getAllowedCurrencies();  | 
                                                        
| 61 | 61 | $this->language = strstr(get_locale(), '_', true);  | 
                                                        
| 62 | 62 |          if ($this->language=='') { | 
                                                        
@@ -65,25 +65,25 @@ discard block  | 
                                                    ||
| 65 | 65 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';  | 
                                                        
| 66 | 66 | |
| 67 | 67 | //Panel form fields  | 
                                                        
| 68 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options  | 
                                                        |
| 68 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options  | 
                                                        |
| 69 | 69 | $this->init_settings();  | 
                                                        
| 70 | 70 | |
| 71 | 71 | $this->extraConfig = getExtraConfig();  | 
                                                        
| 72 | 72 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis');  | 
                                                        
| 73 | 73 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with 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 | }  | 
                                                        
@@ -130,24 +130,24 @@ discard block  | 
                                                    ||
| 130 | 130 | public function pagantisCheckFields()  | 
                                                        
| 131 | 131 |      { | 
                                                        
| 132 | 132 | $error_string = '';  | 
                                                        
| 133 | -        if ($this->settings['enabled'] !== 'yes') { | 
                                                        |
| 133 | +        if ($this->settings['enabled']!=='yes') { | 
                                                        |
| 134 | 134 | return;  | 
                                                        
| 135 | 135 |          } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { | 
                                                        
| 136 | -            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis'); | 
                                                        |
| 136 | +            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); | 
                                                        |
| 137 | 137 | $this->settings['enabled'] = 'no';  | 
                                                        
| 138 | -        } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="")  && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { | 
                                                        |
| 138 | +        } elseif (($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") && (empty($this->settings['pagantis_public_key_4x']) || empty($this->settings['pagantis_private_key_4x']))) { | 
                                                        |
| 139 | 139 |              $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); | 
                                                        
| 140 | 140 | $this->settings['enabled'] = 'no';  | 
                                                        
| 141 | 141 |          } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { | 
                                                        
| 142 | -            $error_string =  __(' only can be used in Euros', 'pagantis'); | 
                                                        |
| 142 | +            $error_string = __(' only can be used in Euros', 'pagantis'); | 
                                                        |
| 143 | 143 | $this->settings['enabled'] = 'no';  | 
                                                        
| 144 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'  | 
                                                        |
| 145 | -                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { | 
                                                        |
| 144 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'  | 
                                                        |
| 145 | +                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { | 
                                                        |
| 146 | 146 |              $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); | 
                                                        
| 147 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'  | 
                                                        |
| 148 | -                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { | 
                                                        |
| 147 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'  | 
                                                        |
| 148 | +                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { | 
                                                        |
| 149 | 149 |              $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); | 
                                                        
| 150 | -        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { | 
                                                        |
| 150 | +        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { | 
                                                        |
| 151 | 151 |              $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); | 
                                                        
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
@@ -181,7 +181,7 @@ discard block  | 
                                                    ||
| 181 | 181 | |
| 182 | 182 |              $shippingAddress = $order->get_address('shipping'); | 
                                                        
| 183 | 183 |              $billingAddress = $order->get_address('billing'); | 
                                                        
| 184 | -            if ($shippingAddress['address_1'] == '') { | 
                                                        |
| 184 | +            if ($shippingAddress['address_1']=='') { | 
                                                        |
| 185 | 185 | $shippingAddress = $billingAddress;  | 
                                                        
| 186 | 186 | }  | 
                                                        
| 187 | 187 | |
@@ -208,7 +208,7 @@ discard block  | 
                                                    ||
| 208 | 208 | ->setNationalId($national_id)  | 
                                                        
| 209 | 209 | ->setTaxId($tax_id)  | 
                                                        
| 210 | 210 | ;  | 
                                                        
| 211 | - $orderBillingAddress = new Address();  | 
                                                        |
| 211 | + $orderBillingAddress = new Address();  | 
                                                        |
| 212 | 212 | $orderBillingAddress  | 
                                                        
| 213 | 213 | ->setZipCode($billingAddress['postcode'])  | 
                                                        
| 214 | 214 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])  | 
                                                        
@@ -281,12 +281,12 @@ discard block  | 
                                                    ||
| 281 | 281 | $details->addProduct($product);  | 
                                                        
| 282 | 282 | |
| 283 | 283 | $promotedProduct = isProductPromoted($item->get_product_id());  | 
                                                        
| 284 | -                if ($promotedProduct == 'true') { | 
                                                        |
| 285 | - $promotedAmount+=$product->getAmount();  | 
                                                        |
| 286 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .  | 
                                                        |
| 287 | - ' - Price: ' . $item->get_total() .  | 
                                                        |
| 288 | - ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 289 | - ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 284 | +                if ($promotedProduct=='true') { | 
                                                        |
| 285 | + $promotedAmount += $product->getAmount();  | 
                                                        |
| 286 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().  | 
                                                        |
| 287 | + ' - Price: '.$item->get_total().  | 
                                                        |
| 288 | + ' - Qty: '.$product->getQuantity().  | 
                                                        |
| 289 | + ' - Item ID: '.$item['id_product'];  | 
                                                        |
| 290 | 290 | $promotedMessage = substr($promotedMessage, 0, 999);  | 
                                                        
| 291 | 291 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 292 | 292 | }  | 
                                                        
@@ -332,9 +332,7 @@ discard block  | 
                                                    ||
| 332 | 332 | |
| 333 | 333 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);  | 
                                                        
| 334 | 334 | $purchaseCountry =  | 
                                                        
| 335 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language :  | 
                                                        |
| 336 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :  | 
                                                        |
| 337 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;  | 
                                                        |
| 335 | + in_array(strtolower($this->language), $allowedCountries) ? $this->language : in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;  | 
                                                        |
| 338 | 336 | |
| 339 | 337 | $orderConfiguration = new Configuration();  | 
                                                        
| 340 | 338 | $orderConfiguration  | 
                                                        
@@ -377,7 +375,7 @@ discard block  | 
                                                    ||
| 377 | 375 |                  wc_get_template('iframe.php', $template_fields, '', $this->template_path); | 
                                                        
| 378 | 376 | }  | 
                                                        
| 379 | 377 |          } catch (\Exception $exception) { | 
                                                        
| 380 | -            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); | 
                                                        |
| 378 | +            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); | 
                                                        |
| 381 | 379 | insertLogEntry($exception);  | 
                                                        
| 382 | 380 |              $checkout_url = get_permalink(wc_get_page_id('checkout')); | 
                                                        
| 383 | 381 | wp_redirect($checkout_url);  | 
                                                        
@@ -392,7 +390,7 @@ discard block  | 
                                                    ||
| 392 | 390 | public function pagantisNotification()  | 
                                                        
| 393 | 391 |      { | 
                                                        
| 394 | 392 |          try { | 
                                                        
| 395 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';  | 
                                                        |
| 393 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';  | 
                                                        |
| 396 | 394 | |
| 397 | 395 |              include_once('notifyController.php'); | 
                                                        
| 398 | 396 | $notify = new WcPagantisNotify();  | 
                                                        
@@ -431,10 +429,10 @@ discard block  | 
                                                    ||
| 431 | 429 | */  | 
                                                        
| 432 | 430 | public function pagantisCompleteStatus($status, $order_id, $order)  | 
                                                        
| 433 | 431 |      { | 
                                                        
| 434 | -        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { | 
                                                        |
| 435 | -            if ($order->get_status() == 'failed') { | 
                                                        |
| 432 | +        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { | 
                                                        |
| 433 | +            if ($order->get_status()=='failed') { | 
                                                        |
| 436 | 434 | $status = 'processing';  | 
                                                        
| 437 | -            } elseif ($order->get_status() == 'pending' && $status=='completed') { | 
                                                        |
| 435 | +            } elseif ($order->get_status()=='pending' && $status=='completed') { | 
                                                        |
| 438 | 436 | $status = 'processing';  | 
                                                        
| 439 | 437 | }  | 
                                                        
| 440 | 438 | }  | 
                                                        
@@ -460,8 +458,8 @@ discard block  | 
                                                    ||
| 460 | 458 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries));  | 
                                                        
| 461 | 459 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];  | 
                                                        
| 462 | 460 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];  | 
                                                        
| 463 | - $totalPrice = (int)$this->get_order_total();  | 
                                                        |
| 464 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));  | 
                                                        |
| 461 | + $totalPrice = (int) $this->get_order_total();  | 
                                                        |
| 462 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));  | 
                                                        |
| 465 | 463 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&  | 
                                                        
| 466 | 464 |              $validAmount && $allowedCountry) { | 
                                                        
| 467 | 465 | return true;  | 
                                                        
@@ -494,7 +492,7 @@ discard block  | 
                                                    ||
| 494 | 492 | |
| 495 | 493 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function  | 
                                                        
| 496 | 494 |              if (strpos($redirectUrl, 'order-pay=')===false) { | 
                                                        
| 497 | - $redirectUrl.="&order-pay=".$order_id;  | 
                                                        |
| 495 | + $redirectUrl .= "&order-pay=".$order_id;  | 
                                                        |
| 498 | 496 | }  | 
                                                        
| 499 | 497 | |
| 500 | 498 | return array(  | 
                                                        
@@ -502,7 +500,7 @@ discard block  | 
                                                    ||
| 502 | 500 | 'redirect' => $redirectUrl  | 
                                                        
| 503 | 501 | );  | 
                                                        
| 504 | 502 |          } catch (Exception $e) { | 
                                                        
| 505 | -            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); | 
                                                        |
| 503 | +            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); | 
                                                        |
| 506 | 504 | return array();  | 
                                                        
| 507 | 505 | }  | 
                                                        
| 508 | 506 | }  | 
                                                        
@@ -572,7 +570,7 @@ discard block  | 
                                                    ||
| 572 | 570 | private function generateUrl($url)  | 
                                                        
| 573 | 571 |      { | 
                                                        
| 574 | 572 | $parsed_url = parse_url($url);  | 
                                                        
| 575 | -        if ($parsed_url !== false) { | 
                                                        |
| 573 | +        if ($parsed_url!==false) { | 
                                                        |
| 576 | 574 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];  | 
                                                        
| 577 | 575 | parse_str($parsed_url['query'], $arrayParams);  | 
                                                        
| 578 | 576 |              foreach ($arrayParams as $keyParam => $valueParam) { | 
                                                        
@@ -620,11 +618,10 @@ discard block  | 
                                                    ||
| 620 | 618 | private function getKeysUrl($order, $url)  | 
                                                        
| 621 | 619 |      { | 
                                                        
| 622 | 620 | $defaultFields = (get_class($order)=='WC_Order') ?  | 
                                                        
| 623 | -            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : | 
                                                        |
| 624 | - array();  | 
                                                        |
| 621 | +            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); | 
                                                        |
| 625 | 622 | |
| 626 | 623 | $parsedUrl = parse_url($url);  | 
                                                        
| 627 | -        if ($parsedUrl !== false) { | 
                                                        |
| 624 | +        if ($parsedUrl!==false) { | 
                                                        |
| 628 | 625 | //Replace parameters from url  | 
                                                        
| 629 | 626 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);  | 
                                                        
| 630 | 627 | |
@@ -669,7 +666,7 @@ discard block  | 
                                                    ||
| 669 | 666 |          foreach ($arrayParams as $keyParam => $valueParam) { | 
                                                        
| 670 | 667 |              preg_match('#\{{.*?}\}#', $valueParam, $match); | 
                                                        
| 671 | 668 |              if (count($match)) { | 
                                                        
| 672 | -                $key = str_replace(array('{{','}}'), array('',''), $match[0]); | 
                                                        |
| 669 | +                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); | 
                                                        |
| 673 | 670 | $arrayParams[$keyParam] = $defaultFields[$key];  | 
                                                        
| 674 | 671 | }  | 
                                                        
| 675 | 672 | }  | 
                                                        
@@ -684,12 +681,12 @@ discard block  | 
                                                    ||
| 684 | 681 | */  | 
                                                        
| 685 | 682 | private function unparseUrl($parsed_url)  | 
                                                        
| 686 | 683 |      { | 
                                                        
| 687 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';  | 
                                                        |
| 684 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';  | 
                                                        |
| 688 | 685 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';  | 
                                                        
| 689 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';  | 
                                                        |
| 690 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';  | 
                                                        |
| 691 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';  | 
                                                        |
| 686 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';  | 
                                                        |
| 687 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';  | 
                                                        |
| 688 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';  | 
                                                        |
| 692 | 689 | $path = $parsed_url['path'];  | 
                                                        
| 693 | - return $scheme . $host . $port . $path . $query . $fragment;  | 
                                                        |
| 690 | + return $scheme.$host.$port.$path.$query.$fragment;  | 
                                                        |
| 694 | 691 | }  | 
                                                        
| 695 | 692 | }  | 
                                                        
@@ -198,10 +198,10 @@  | 
                                                    ||
| 198 | 198 | |
| 199 | 199 |          if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM | 
                                                        
| 200 | 200 | $logMessage = "WARNING checkMerchantOrderStatus." .  | 
                                                        
| 201 | - " Merchant order id:".$this->woocommerceOrder->get_id().  | 
                                                        |
| 202 | - " Merchant order status:".$this->woocommerceOrder->get_status().  | 
                                                        |
| 203 | - " Pagantis order id:".$this->pagantisOrder->getStatus().  | 
                                                        |
| 204 | - " Pagantis order status:".$this->pagantisOrder->getId();  | 
                                                        |
| 201 | + " Merchant order id:".$this->woocommerceOrder->get_id().  | 
                                                        |
| 202 | + " Merchant order status:".$this->woocommerceOrder->get_status().  | 
                                                        |
| 203 | + " Pagantis order id:".$this->pagantisOrder->getStatus().  | 
                                                        |
| 204 | + " Pagantis order status:".$this->pagantisOrder->getId();  | 
                                                        |
| 205 | 205 | |
| 206 | 206 | $this->insertLog(null, $logMessage);  | 
                                                        
| 207 | 207 | $this->woocommerceOrder->add_order_note($logMessage);  | 
                                                        
@@ -65,7 +65,7 @@ discard block  | 
                                                    ||
| 65 | 65 |          try { | 
                                                        
| 66 | 66 | require_once(__ROOT__.'/vendor/autoload.php');  | 
                                                        
| 67 | 67 |              try { | 
                                                        
| 68 | -                if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_GET['origin'] == 'notification') { | 
                                                        |
| 68 | +                if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['origin']=='notification') { | 
                                                        |
| 69 | 69 | return $this->buildResponse();  | 
                                                        
| 70 | 70 | }  | 
                                                        
| 71 | 71 | $this->checkConcurrency();  | 
                                                        
@@ -114,7 +114,7 @@ discard block  | 
                                                    ||
| 114 | 114 | private function checkConcurrency()  | 
                                                        
| 115 | 115 |      { | 
                                                        
| 116 | 116 | $this->woocommerceOrderId = $_GET['order-received'];  | 
                                                        
| 117 | -        if ($this->woocommerceOrderId == '') { | 
                                                        |
| 117 | +        if ($this->woocommerceOrderId=='') { | 
                                                        |
| 118 | 118 | throw new QuoteNotFoundException();  | 
                                                        
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
@@ -127,7 +127,7 @@ discard block  | 
                                                    ||
| 127 | 127 | */  | 
                                                        
| 128 | 128 | private function getProductType()  | 
                                                        
| 129 | 129 |      { | 
                                                        
| 130 | -        if ($_GET['product'] == '') { | 
                                                        |
| 130 | +        if ($_GET['product']=='') { | 
                                                        |
| 131 | 131 | $this->setProduct(WcPagantisGateway::METHOD_ID);  | 
                                                        
| 132 | 132 |          } else { | 
                                                        
| 133 | 133 | $this->setProduct($_GET['product']);  | 
                                                        
@@ -158,7 +158,7 @@ discard block  | 
                                                    ||
| 158 | 158 |          $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'"); | 
                                                        
| 159 | 159 | $this->pagantisOrderId = $queryResult->order_id;  | 
                                                        
| 160 | 160 | |
| 161 | -        if ($this->pagantisOrderId == '') { | 
                                                        |
| 161 | +        if ($this->pagantisOrderId=='') { | 
                                                        |
| 162 | 162 | throw new NoIdentificationException();  | 
                                                        
| 163 | 163 | }  | 
                                                        
| 164 | 164 | }  | 
                                                        
@@ -201,7 +201,7 @@ discard block  | 
                                                    ||
| 201 | 201 | $status = '-';  | 
                                                        
| 202 | 202 | }  | 
                                                        
| 203 | 203 | |
| 204 | -            if ($status === Order::STATUS_CONFIRMED) { | 
                                                        |
| 204 | +            if ($status===Order::STATUS_CONFIRMED) { | 
                                                        |
| 205 | 205 | return true;  | 
                                                        
| 206 | 206 | }  | 
                                                        
| 207 | 207 | throw new WrongStatusException($status);  | 
                                                        
@@ -222,7 +222,7 @@ discard block  | 
                                                    ||
| 222 | 222 | );  | 
                                                        
| 223 | 223 | |
| 224 | 224 |          if (!$this->woocommerceOrder->has_status($isValidStatus)) { // TO CONFIRM | 
                                                        
| 225 | - $logMessage = "WARNING checkMerchantOrderStatus." .  | 
                                                        |
| 225 | + $logMessage = "WARNING checkMerchantOrderStatus.".  | 
                                                        |
| 226 | 226 | " Merchant order id:".$this->woocommerceOrder->get_id().  | 
                                                        
| 227 | 227 | " Merchant order status:".$this->woocommerceOrder->get_status().  | 
                                                        
| 228 | 228 | " Pagantis order id:".$this->pagantisOrder->getStatus().  | 
                                                        
@@ -244,7 +244,7 @@ discard block  | 
                                                    ||
| 244 | 244 |      { | 
                                                        
| 245 | 245 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount();  | 
                                                        
| 246 | 246 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total()));  | 
                                                        
| 247 | -        if ($pagantisAmount != $wcAmount) { | 
                                                        |
| 247 | +        if ($pagantisAmount!=$wcAmount) { | 
                                                        |
| 248 | 248 | throw new AmountMismatchException($pagantisAmount, $wcAmount);  | 
                                                        
| 249 | 249 | }  | 
                                                        
| 250 | 250 | }  | 
                                                        
@@ -268,7 +268,7 @@ discard block  | 
                                                    ||
| 268 | 268 | $this->pagantisOrder = $this->orderClient->confirmOrder($this->pagantisOrderId);  | 
                                                        
| 269 | 269 |          } catch (\Exception $e) { | 
                                                        
| 270 | 270 | $this->pagantisOrder = $this->orderClient->getOrder($this->pagantisOrderId);  | 
                                                        
| 271 | -            if ($this->pagantisOrder->getStatus() !== Order::STATUS_CONFIRMED) { | 
                                                        |
| 271 | +            if ($this->pagantisOrder->getStatus()!==Order::STATUS_CONFIRMED) { | 
                                                        |
| 272 | 272 | throw new UnknownException($e->getMessage());  | 
                                                        
| 273 | 273 |              } else { | 
                                                        
| 274 | 274 | $logMessage = 'Concurrency issue: Order_id '.$this->pagantisOrderId.' was confirmed by other process';  | 
                                                        
@@ -292,7 +292,7 @@ discard block  | 
                                                    ||
| 292 | 292 | global $wpdb;  | 
                                                        
| 293 | 293 | $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;  | 
                                                        
| 294 | 294 | |
| 295 | -        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { | 
                                                        |
| 295 | +        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { | 
                                                        |
| 296 | 296 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 297 | 297 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50),  | 
                                                        
| 298 | 298 | UNIQUE KEY id (id)) $charset_collate";  | 
                                                        
@@ -310,7 +310,7 @@ discard block  | 
                                                    ||
| 310 | 310 | global $wpdb;  | 
                                                        
| 311 | 311 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;  | 
                                                        
| 312 | 312 | |
| 313 | -        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { | 
                                                        |
| 313 | +        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { | 
                                                        |
| 314 | 314 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 315 | 315 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL,  | 
                                                        
| 316 | 316 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate";  | 
                                                        
@@ -367,12 +367,12 @@ discard block  | 
                                                    ||
| 367 | 367 | $metadataOrder = $this->pagantisOrder->getMetadata();  | 
                                                        
| 368 | 368 | $metadataInfo = null;  | 
                                                        
| 369 | 369 |              foreach ($metadataOrder as $metadataKey => $metadataValue) { | 
                                                        
| 370 | -                if ($metadataKey == 'promotedProduct') { | 
                                                        |
| 371 | - $metadataInfo.= "/Producto promocionado = $metadataValue";  | 
                                                        |
| 370 | +                if ($metadataKey=='promotedProduct') { | 
                                                        |
| 371 | + $metadataInfo .= "/Producto promocionado = $metadataValue";  | 
                                                        |
| 372 | 372 | }  | 
                                                        
| 373 | 373 | }  | 
                                                        
| 374 | 374 | |
| 375 | -            if ($metadataInfo != null) { | 
                                                        |
| 375 | +            if ($metadataInfo!=null) { | 
                                                        |
| 376 | 376 | $this->woocommerceOrder->add_order_note($metadataInfo);  | 
                                                        
| 377 | 377 | }  | 
                                                        
| 378 | 378 | |
@@ -441,13 +441,13 @@ discard block  | 
                                                    ||
| 441 | 441 |      { | 
                                                        
| 442 | 442 | global $wpdb;  | 
                                                        
| 443 | 443 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;  | 
                                                        
| 444 | -        if ($orderId == null) { | 
                                                        |
| 444 | +        if ($orderId==null) { | 
                                                        |
| 445 | 445 | $query = "DELETE FROM $tableName WHERE createdAt<(NOW()- INTERVAL ".self::CONCURRENCY_TIMEOUT." SECOND)";  | 
                                                        
| 446 | 446 |          } else { | 
                                                        
| 447 | 447 | $query = "DELETE FROM $tableName WHERE order_id = $orderId";  | 
                                                        
| 448 | 448 | }  | 
                                                        
| 449 | 449 | $resultDelete = $wpdb->query($query);  | 
                                                        
| 450 | -        if ($resultDelete === false) { | 
                                                        |
| 450 | +        if ($resultDelete===false) { | 
                                                        |
| 451 | 451 | throw new ConcurrencyException();  | 
                                                        
| 452 | 452 | }  | 
                                                        
| 453 | 453 | }  | 
                                                        
@@ -462,8 +462,8 @@ discard block  | 
                                                    ||
| 462 | 462 | global $wpdb;  | 
                                                        
| 463 | 463 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;  | 
                                                        
| 464 | 464 |          $insertResult = $wpdb->insert($tableName, array('order_id' => $orderId)); | 
                                                        
| 465 | -        if ($insertResult === false) { | 
                                                        |
| 466 | -            if ($this->getOrigin() == 'Notify') { | 
                                                        |
| 465 | +        if ($insertResult===false) { | 
                                                        |
| 466 | +            if ($this->getOrigin()=='Notify') { | 
                                                        |
| 467 | 467 | throw new ConcurrencyException();  | 
                                                        
| 468 | 468 |              } else { | 
                                                        
| 469 | 469 | $query = sprintf(  | 
                                                        
@@ -474,8 +474,8 @@ discard block  | 
                                                    ||
| 474 | 474 | );  | 
                                                        
| 475 | 475 | $resultSeconds = $wpdb->get_row($query);  | 
                                                        
| 476 | 476 | $restSeconds = isset($resultSeconds) ? ($resultSeconds->rest) : 0;  | 
                                                        
| 477 | - $secondsToExpire = ($restSeconds>self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;  | 
                                                        |
| 478 | - sleep($secondsToExpire+1);  | 
                                                        |
| 477 | + $secondsToExpire = ($restSeconds > self::CONCURRENCY_TIMEOUT) ? self::CONCURRENCY_TIMEOUT : $restSeconds;  | 
                                                        |
| 478 | + sleep($secondsToExpire + 1);  | 
                                                        |
| 479 | 479 | |
| 480 | 480 | $logMessage = sprintf(  | 
                                                        
| 481 | 481 | "User waiting %s seconds, default seconds %s, bd time to expire %s seconds",  | 
                                                        
@@ -499,7 +499,7 @@ discard block  | 
                                                    ||
| 499 | 499 |      { | 
                                                        
| 500 | 500 | $this->unblockConcurrency($this->woocommerceOrderId);  | 
                                                        
| 501 | 501 | |
| 502 | -        if ($exception == null) { | 
                                                        |
| 502 | +        if ($exception==null) { | 
                                                        |
| 503 | 503 | $jsonResponse = new JsonSuccessResponse();  | 
                                                        
| 504 | 504 |          } else { | 
                                                        
| 505 | 505 | $jsonResponse = new JsonExceptionResponse();  | 
                                                        
@@ -509,7 +509,7 @@ discard block  | 
                                                    ||
| 509 | 509 | $jsonResponse->setMerchantOrderId($this->woocommerceOrderId);  | 
                                                        
| 510 | 510 | $jsonResponse->setPagantisOrderId($this->pagantisOrderId);  | 
                                                        
| 511 | 511 | |
| 512 | -        if ($_SERVER['REQUEST_METHOD'] == 'POST') { | 
                                                        |
| 512 | +        if ($_SERVER['REQUEST_METHOD']=='POST') { | 
                                                        |
| 513 | 513 | $jsonResponse->printResponse();  | 
                                                        
| 514 | 514 |          } else { | 
                                                        
| 515 | 515 | return $jsonResponse;  | 
                                                        
@@ -541,7 +541,7 @@ discard block  | 
                                                    ||
| 541 | 541 | */  | 
                                                        
| 542 | 542 | private function isProduct4x()  | 
                                                        
| 543 | 543 |      { | 
                                                        
| 544 | - return ($this->product === Ucfirst(WcPagantis4xGateway::METHOD_ID));  | 
                                                        |
| 544 | + return ($this->product===Ucfirst(WcPagantis4xGateway::METHOD_ID));  | 
                                                        |
| 545 | 545 | }  | 
                                                        
| 546 | 546 | |
| 547 | 547 | /**  | 
                                                        
@@ -613,7 +613,7 @@  | 
                                                    ||
| 613 | 613 |          if ($file == plugin_basename(__FILE__)) { | 
                                                        
| 614 | 614 |              $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; | 
                                                        
| 615 | 615 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.  | 
                                                        
| 616 | -                       __('API documentation', 'pagantis').'</a>'; | 
                                                        |
| 616 | +                        __('API documentation', 'pagantis').'</a>'; | 
                                                        |
| 617 | 617 |              $links[] = '<a href="'.WcPagantis::SUPPORT_EML.'">'.__('Support', 'pagantis').'</a>'; | 
                                                        
| 618 | 618 | |
| 619 | 619 | return $links;  | 
                                                        
@@ -19,7 +19,7 @@ discard block  | 
                                                    ||
| 19 | 19 | }  | 
                                                        
| 20 | 20 | |
| 21 | 21 | |
| 22 | -require_once(__DIR__ . '/includes/pg-functions.php');  | 
                                                        |
| 22 | +require_once(__DIR__.'/includes/pg-functions.php');  | 
                                                        |
| 23 | 23 | |
| 24 | 24 | /**  | 
                                                        
| 25 | 25 | * Required minimums and constants  | 
                                                        
@@ -81,7 +81,7 @@ discard block  | 
                                                    ||
| 81 | 81 | public function __construct()  | 
                                                        
| 82 | 82 |      { | 
                                                        
| 83 | 83 | require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php');  | 
                                                        
| 84 | - require_once(PG_ABSPATH . '/includes/pg-functions.php');  | 
                                                        |
| 84 | + require_once(PG_ABSPATH.'/includes/pg-functions.php');  | 
                                                        |
| 85 | 85 | |
| 86 | 86 | $this->template_path = plugin_dir_path(__FILE__).'/templates/';  | 
                                                        
| 87 | 87 | |
@@ -98,15 +98,15 @@ discard block  | 
                                                    ||
| 98 | 98 |          add_action('init', array($this, 'checkWcPriceSettings'), 10); | 
                                                        
| 99 | 99 |          add_action('woocommerce_after_template_part', array($this, 'pagantisAddSimulatorHtmlDiv'), 10); | 
                                                        
| 100 | 100 |          add_action('woocommerce_single_product_summary', array($this, 'pagantisInitProductSimulator'), 20); | 
                                                        
| 101 | -        add_action('woocommerce_single_variation', array($this,'pagantisAddProductSnippetForVariations'), 30); | 
                                                        |
| 101 | +        add_action('woocommerce_single_variation', array($this, 'pagantisAddProductSnippetForVariations'), 30); | 
                                                        |
| 102 | 102 |          add_action('wp_enqueue_scripts', 'add_pagantis_widget_js'); | 
                                                        
| 103 | 103 |          add_action('rest_api_init', array($this, 'pagantisRegisterEndpoint')); //Endpoint | 
                                                        
| 104 | 104 |          add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); | 
                                                        
| 105 | 105 | register_activation_hook(__FILE__, array($this, 'pagantisActivation'));  | 
                                                        
| 106 | 106 |          add_action('woocommerce_product_options_general_product_data', array($this, 'pagantisPromotedProductTpl')); | 
                                                        
| 107 | 107 |          add_action('woocommerce_process_product_meta', array($this, 'pagantisPromotedVarSave')); | 
                                                        
| 108 | -        add_action('woocommerce_product_bulk_edit_start', array($this,'pagantisPromotedBulkTemplate')); | 
                                                        |
| 109 | -        add_action('woocommerce_product_bulk_edit_save', array($this,'pagantisPromotedBulkTemplateSave')); | 
                                                        |
| 108 | +        add_action('woocommerce_product_bulk_edit_start', array($this, 'pagantisPromotedBulkTemplate')); | 
                                                        |
| 109 | +        add_action('woocommerce_product_bulk_edit_save', array($this, 'pagantisPromotedBulkTemplateSave')); | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | 111 | |
| 112 | 112 | /**  | 
                                                        
@@ -132,7 +132,7 @@ discard block  | 
                                                    ||
| 132 | 132 |      { | 
                                                        
| 133 | 133 | $post_id = $product->get_id();  | 
                                                        
| 134 | 134 | $pagantis_promoted_value = $_REQUEST['pagantis_promoted'];  | 
                                                        
| 135 | -        if ($pagantis_promoted_value === 'on') { | 
                                                        |
| 135 | +        if ($pagantis_promoted_value==='on') { | 
                                                        |
| 136 | 136 | $pagantis_promoted_value = 'yes';  | 
                                                        
| 137 | 137 |          } else { | 
                                                        
| 138 | 138 | $pagantis_promoted_value = 'no';  | 
                                                        
@@ -166,7 +166,7 @@ discard block  | 
                                                    ||
| 166 | 166 | public function pagantisPromotedVarSave($post_id)  | 
                                                        
| 167 | 167 |      { | 
                                                        
| 168 | 168 | $pagantis_promoted_value = $_POST['pagantis_promoted'];  | 
                                                        
| 169 | -        if ($pagantis_promoted_value !== 'yes') { | 
                                                        |
| 169 | +        if ($pagantis_promoted_value!=='yes') { | 
                                                        |
| 170 | 170 | $pagantis_promoted_value = 'no';  | 
                                                        
| 171 | 171 | }  | 
                                                        
| 172 | 172 | |
@@ -180,8 +180,8 @@ discard block  | 
                                                    ||
| 180 | 180 | */  | 
                                                        
| 181 | 181 | public function loadPagantisTranslation($mofile, $domain)  | 
                                                        
| 182 | 182 |      { | 
                                                        
| 183 | -        if ('pagantis' === $domain) { | 
                                                        |
| 184 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';  | 
                                                        |
| 183 | +        if ('pagantis'===$domain) { | 
                                                        |
| 184 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';  | 
                                                        |
| 185 | 185 | }  | 
                                                        
| 186 | 186 | return $mofile;  | 
                                                        
| 187 | 187 | }  | 
                                                        
@@ -194,7 +194,7 @@ discard block  | 
                                                    ||
| 194 | 194 | global $wpdb;  | 
                                                        
| 195 | 195 | |
| 196 | 196 | $tableName = $wpdb->prefix.PG_CONCURRENCY_TABLE_NAME;  | 
                                                        
| 197 | -        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { | 
                                                        |
| 197 | +        if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { | 
                                                        |
| 198 | 198 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 199 | 199 | $sql = "CREATE TABLE $tableName ( order_id int NOT NULL,  | 
                                                        
| 200 | 200 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (order_id)) $charset_collate";  | 
                                                        
@@ -205,7 +205,7 @@ discard block  | 
                                                    ||
| 205 | 205 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 206 | 206 | |
| 207 | 207 | //Check if table exists  | 
                                                        
| 208 | -        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; | 
                                                        |
| 208 | +        $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; | 
                                                        |
| 209 | 209 |          if ($tableExists) { | 
                                                        
| 210 | 210 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 211 | 211 | $sql = "CREATE TABLE IF NOT EXISTS $tableName (  | 
                                                        
@@ -220,7 +220,7 @@ discard block  | 
                                                    ||
| 220 | 220 | //Updated value field to adapt to new length < v8.0.1  | 
                                                        
| 221 | 221 | $query = "select COLUMN_TYPE FROM information_schema.COLUMNS where TABLE_NAME='$tableName' AND COLUMN_NAME='value'";  | 
                                                        
| 222 | 222 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 223 | -            if ($results['0']['COLUMN_TYPE'] == 'varchar(100)') { | 
                                                        |
| 223 | +            if ($results['0']['COLUMN_TYPE']=='varchar(100)') { | 
                                                        |
| 224 | 224 | $sql = "ALTER TABLE $tableName MODIFY value varchar(1000)";  | 
                                                        
| 225 | 225 | $wpdb->query($sql);  | 
                                                        
| 226 | 226 | }  | 
                                                        
@@ -230,9 +230,9 @@ discard block  | 
                                                    ||
| 230 | 230 | or config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";  | 
                                                        
| 231 | 231 | $dbCurrentConfig = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 232 | 232 |              foreach ($dbCurrentConfig as $item) { | 
                                                        
| 233 | -                if ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { | 
                                                        |
| 233 | +                if ($item['config']=='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR') { | 
                                                        |
| 234 | 234 | $css_price_selector = $this->preparePriceSelector($item['value']);  | 
                                                        
| 235 | -                    if ($item['value'] != $css_price_selector) { | 
                                                        |
| 235 | +                    if ($item['value']!=$css_price_selector) { | 
                                                        |
| 236 | 236 | $wpdb->update(  | 
                                                        
| 237 | 237 | $tableName,  | 
                                                        
| 238 | 238 |                              array('value' => stripslashes($css_price_selector)), | 
                                                        
@@ -241,9 +241,9 @@ discard block  | 
                                                    ||
| 241 | 241 |                              array('%s') | 
                                                        
| 242 | 242 | );  | 
                                                        
| 243 | 243 | }  | 
                                                        
| 244 | -                } elseif ($item['config'] == 'PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { | 
                                                        |
| 244 | +                } elseif ($item['config']=='PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR') { | 
                                                        |
| 245 | 245 | $css_quantity_selector = $this->prepareQuantitySelector($item['value']);  | 
                                                        
| 246 | -                    if ($item['value'] != $css_quantity_selector) { | 
                                                        |
| 246 | +                    if ($item['value']!=$css_quantity_selector) { | 
                                                        |
| 247 | 247 | $wpdb->update(  | 
                                                        
| 248 | 248 | $tableName,  | 
                                                        
| 249 | 249 |                              array('value' => stripslashes($css_quantity_selector)), | 
                                                        
@@ -257,7 +257,7 @@ discard block  | 
                                                    ||
| 257 | 257 | }  | 
                                                        
| 258 | 258 | |
| 259 | 259 | // Making sure DB tables are created < v8.6.9  | 
                                                        
| 260 | -        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)){ | 
                                                        |
| 260 | +        if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { | 
                                                        |
| 261 | 261 | createLogsTable();  | 
                                                        
| 262 | 262 | }  | 
                                                        
| 263 | 263 | checkCartProcessTable();  | 
                                                        
@@ -266,7 +266,7 @@ discard block  | 
                                                    ||
| 266 | 266 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 267 | 267 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";  | 
                                                        
| 268 | 268 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 269 | -        if (count($results) == 0) { | 
                                                        |
| 269 | +        if (count($results)==0) { | 
                                                        |
| 270 | 270 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR', 'value'  => '.'), array('%s', '%s')); | 
                                                        
| 271 | 271 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR', 'value'  => ','), array('%s', '%s')); | 
                                                        
| 272 | 272 | }  | 
                                                        
@@ -275,7 +275,7 @@ discard block  | 
                                                    ||
| 275 | 275 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 276 | 276 | $query = "select * from $tableName where config='PAGANTIS_DISPLAY_MAX_AMOUNT'";  | 
                                                        
| 277 | 277 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 278 | -        if (count($results) == 0) { | 
                                                        |
| 278 | +        if (count($results)==0) { | 
                                                        |
| 279 | 279 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT', 'value'  => '0'), array('%s', '%s')); | 
                                                        
| 280 | 280 | }  | 
                                                        
| 281 | 281 | |
@@ -283,7 +283,7 @@ discard block  | 
                                                    ||
| 283 | 283 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 284 | 284 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_SITUATION'";  | 
                                                        
| 285 | 285 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 286 | -        if (count($results) == 0) { | 
                                                        |
| 286 | +        if (count($results)==0) { | 
                                                        |
| 287 | 287 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_SITUATION', 'value'  => 'default'), array('%s', '%s')); | 
                                                        
| 288 | 288 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION', 'value'  => 'default'), array('%s', '%s')); | 
                                                        
| 289 | 289 | }  | 
                                                        
@@ -293,17 +293,17 @@ discard block  | 
                                                    ||
| 293 | 293 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 294 | 294 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT'";  | 
                                                        
| 295 | 295 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 296 | -        if (count($results) == 0) { | 
                                                        |
| 296 | +        if (count($results)==0) { | 
                                                        |
| 297 | 297 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE_CHECKOUT', 'value'  => 'sdk.simulator.types.CHECKOUT_PAGE'), array('%s', '%s')); | 
                                                        
| 298 | 298 |              $wpdb->update($tableName, array('value' => 'sdk.simulator.types.PRODUCT_PAGE'), array('config' => 'PAGANTIS_SIMULATOR_DISPLAY_TYPE'), array('%s'), array('%s')); | 
                                                        
| 299 | 299 | }  | 
                                                        
| 300 | 300 | |
| 301 | 301 | //Adapting to variable selector < v8.3.6  | 
                                                        
| 302 | - $variableSelector="div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";  | 
                                                        |
| 302 | + $variableSelector = "div.summary div.woocommerce-variation.single_variation > div.woocommerce-variation-price span.price";  | 
                                                        |
| 303 | 303 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 304 | 304 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_SELECTOR_VARIATION' and value='default'";  | 
                                                        
| 305 | 305 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 306 | -        if (count($results) == 0) { | 
                                                        |
| 306 | +        if (count($results)==0) { | 
                                                        |
| 307 | 307 |              $wpdb->update($tableName, array('value' => $variableSelector), array('config' => 'PAGANTIS_SIMULATOR_SELECTOR_VARIATION'), array('%s'), array('%s')); | 
                                                        
| 308 | 308 | }  | 
                                                        
| 309 | 309 | |
@@ -311,7 +311,7 @@ discard block  | 
                                                    ||
| 311 | 311 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 312 | 312 | $query = "select * from $tableName where config='PAGANTIS_TITLE_4x'";  | 
                                                        
| 313 | 313 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 314 | -        if (count($results) == 0) { | 
                                                        |
| 314 | +        if (count($results)==0) { | 
                                                        |
| 315 | 315 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_TITLE_4x', 'value'  => 'Until 4 installments, without fees'), array('%s', '%s')); | 
                                                        
| 316 | 316 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MIN_AMOUNT_4x', 'value'  => 1), array('%s', '%s')); | 
                                                        
| 317 | 317 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_DISPLAY_MAX_AMOUNT_4x', 'value'  => 800), array('%s', '%s')); | 
                                                        
@@ -324,7 +324,7 @@ discard block  | 
                                                    ||
| 324 | 324 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 325 | 325 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X'";  | 
                                                        
| 326 | 326 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 327 | -        if (count($results) == 0) { | 
                                                        |
| 327 | +        if (count($results)==0) { | 
                                                        |
| 328 | 328 |              $wpdb->insert($tableName, array('config' => 'PAGANTIS_SIMULATOR_CSS_POSITION_SELECTOR_4X', 'value'  => 'default'), array('%s', '%s')); | 
                                                        
| 329 | 329 | }  | 
                                                        
| 330 | 330 | |
@@ -340,7 +340,7 @@ discard block  | 
                                                    ||
| 340 | 340 | $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        
| 341 | 341 | $query = "select * from $tableName where config='PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'";  | 
                                                        
| 342 | 342 | $results = $wpdb->get_results($query, ARRAY_A);  | 
                                                        
| 343 | -        if (count($results) == 0) { | 
                                                        |
| 343 | +        if (count($results)==0) { | 
                                                        |
| 344 | 344 |              $wpdb->update($tableName, array('value' => 'a:4:{i:0;s:52:"div.summary *:not(del)>.woocommerce-Price-amount bdi";i:1;s:48:"div.summary *:not(del)>.woocommerce-Price-amount";i:2;s:54:"div.entry-summary *:not(del)>.woocommerce-Price-amount";i:3;s:36:"*:not(del)>.woocommerce-Price-amount";}'), array('config' => 'PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'), array('%s'), array('%s')); | 
                                                        
| 345 | 345 | }  | 
                                                        
| 346 | 346 | |
@@ -433,7 +433,7 @@ discard block  | 
                                                    ||
| 433 | 433 | $isAtcTplPresent = isTemplatePresent(  | 
                                                        
| 434 | 434 | $template_name,  | 
                                                        
| 435 | 435 |              array('single-product/add-to-cart/variation-add-to-cart-button.php', | 
                                                        
| 436 | - 'single-product/add-to-cart/variation.php','single-product/add-to-cart/simple.php')  | 
                                                        |
| 436 | + 'single-product/add-to-cart/variation.php', 'single-product/add-to-cart/simple.php')  | 
                                                        |
| 437 | 437 | );  | 
                                                        
| 438 | 438 | |
| 439 | 439 |          $html = apply_filters('pagantis_simulator_selector_html', '<div class="mainPagantisSimulator"></div><div class="pagantisSimulator"></div>'); | 
                                                        
@@ -445,10 +445,10 @@ discard block  | 
                                                    ||
| 445 | 445 | }  | 
                                                        
| 446 | 446 | |
| 447 | 447 | $pagantisSimulator4x = 'enabled';  | 
                                                        
| 448 | -        if (!isPluginEnabled4x() || !areMerchantKeysSet4x()  || !isCountryShopContextValid() || !isProductAmountValid4x()) { | 
                                                        |
| 448 | +        if (!isPluginEnabled4x() || !areMerchantKeysSet4x() || !isCountryShopContextValid() || !isProductAmountValid4x()) { | 
                                                        |
| 449 | 449 | $pagantisSimulator4x = 'disabled';  | 
                                                        
| 450 | 450 | }  | 
                                                        
| 451 | -        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { | 
                                                        |
| 451 | +        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { | 
                                                        |
| 452 | 452 | return;  | 
                                                        
| 453 | 453 | }  | 
                                                        
| 454 | 454 | |
@@ -504,12 +504,12 @@ discard block  | 
                                                    ||
| 504 | 504 | $pagantisSimulator4x = 'disabled';  | 
                                                        
| 505 | 505 | }  | 
                                                        
| 506 | 506 | |
| 507 | -        if ($pagantisSimulator === 'disabled' && $pagantisSimulator4x === 'disabled') { | 
                                                        |
| 507 | +        if ($pagantisSimulator==='disabled' && $pagantisSimulator4x==='disabled') { | 
                                                        |
| 508 | 508 | return;  | 
                                                        
| 509 | 509 | }  | 
                                                        
| 510 | 510 | |
| 511 | 511 | $totalPrice = $product->get_price();  | 
                                                        
| 512 | - $formattedInstallments = number_format($totalPrice/4, 2);  | 
                                                        |
| 512 | + $formattedInstallments = number_format($totalPrice / 4, 2);  | 
                                                        |
| 513 | 513 |          $simulatorMessage = sprintf(__('or 4 installments of %s€, without fees, with ', 'pagantis'), $formattedInstallments); | 
                                                        
| 514 | 514 | $post_id = $product->get_id();  | 
                                                        
| 515 | 515 | $simulatorData = array(  | 
                                                        
@@ -551,7 +551,7 @@ discard block  | 
                                                    ||
| 551 | 551 | */  | 
                                                        
| 552 | 552 | public function addPagantisGateway($methods)  | 
                                                        
| 553 | 553 |      { | 
                                                        
| 554 | -        if (! class_exists('WC_Payment_Gateway')) { | 
                                                        |
| 554 | +        if (!class_exists('WC_Payment_Gateway')) { | 
                                                        |
| 555 | 555 | return $methods;  | 
                                                        
| 556 | 556 | }  | 
                                                        
| 557 | 557 | |
@@ -616,7 +616,7 @@ discard block  | 
                                                    ||
| 616 | 616 | */  | 
                                                        
| 617 | 617 | public function pagantisRowMeta($links, $file)  | 
                                                        
| 618 | 618 |      { | 
                                                        
| 619 | -        if ($file == plugin_basename(__FILE__)) { | 
                                                        |
| 619 | +        if ($file==plugin_basename(__FILE__)) { | 
                                                        |
| 620 | 620 |              $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; | 
                                                        
| 621 | 621 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'.  | 
                                                        
| 622 | 622 |                         __('API documentation', 'pagantis').'</a>'; | 
                                                        
@@ -645,7 +645,7 @@ discard block  | 
                                                    ||
| 645 | 645 | $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;  | 
                                                        
| 646 | 646 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc";  | 
                                                        
| 647 | 647 | $results = $wpdb->get_results($query);  | 
                                                        
| 648 | -        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { | 
                                                        |
| 648 | +        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { | 
                                                        |
| 649 | 649 |              foreach ($results as $key => $result) { | 
                                                        
| 650 | 650 | $response[$key]['timestamp'] = $result->createdAt;  | 
                                                        
| 651 | 651 | $response[$key]['log'] = json_decode($result->log);  | 
                                                        
@@ -672,13 +672,13 @@ discard block  | 
                                                    ||
| 672 | 672 | |
| 673 | 673 | $filters = ($data->get_params());  | 
                                                        
| 674 | 674 | $secretKey = $filters['secret'];  | 
                                                        
| 675 | -        $cfg  = get_option('woocommerce_pagantis_settings'); | 
                                                        |
| 675 | +        $cfg = get_option('woocommerce_pagantis_settings'); | 
                                                        |
| 676 | 676 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null;  | 
                                                        
| 677 | 677 | $privateKey4x = isset($cfg['pagantis_private_key_4x']) ? $cfg['pagantis_private_key_4x'] : null;  | 
                                                        
| 678 | -        if ($privateKey != $secretKey && $privateKey4x != $secretKey) { | 
                                                        |
| 678 | +        if ($privateKey!=$secretKey && $privateKey4x!=$secretKey) { | 
                                                        |
| 679 | 679 | $response['status'] = 401;  | 
                                                        
| 680 | 680 | $response['result'] = 'Unauthorized';  | 
                                                        
| 681 | -        } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { | 
                                                        |
| 681 | +        } elseif ($_SERVER['REQUEST_METHOD']=='POST') { | 
                                                        |
| 682 | 682 |              if (count($_POST)) { | 
                                                        
| 683 | 683 |                  foreach ($_POST as $config => $value) { | 
                                                        
| 684 | 684 |                      if (isset($this->defaultConfigs[$config]) && $response['status']==null) { | 
                                                        
@@ -739,7 +739,7 @@ discard block  | 
                                                    ||
| 739 | 739 |                    and tn.post_date<'".$to->format("Y-m-d")."' order by tn.post_date desc"; | 
                                                        
| 740 | 740 | $results = $wpdb->get_results($query);  | 
                                                        
| 741 | 741 | |
| 742 | -        if (isset($results) && ($privateKey == $secretKey || $privateKey4x == $secretKey)) { | 
                                                        |
| 742 | +        if (isset($results) && ($privateKey==$secretKey || $privateKey4x==$secretKey)) { | 
                                                        |
| 743 | 743 |              foreach ($results as $result) { | 
                                                        
| 744 | 744 | $key = $result->ID;  | 
                                                        
| 745 | 745 | $response['message'][$key]['timestamp'] = $result->post_date;  | 
                                                        
@@ -812,7 +812,7 @@ discard block  | 
                                                    ||
| 812 | 812 | */  | 
                                                        
| 813 | 813 | private function prepareQuantitySelector($css_quantity_selector)  | 
                                                        
| 814 | 814 |      { | 
                                                        
| 815 | -        if ($css_quantity_selector == 'default' || $css_quantity_selector == '') { | 
                                                        |
| 815 | +        if ($css_quantity_selector=='default' || $css_quantity_selector=='') { | 
                                                        |
| 816 | 816 | $css_quantity_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_QUANTITY_SELECTOR'];  | 
                                                        
| 817 | 817 |          } elseif (!unserialize($css_quantity_selector)) { //in the case of a custom string selector, we keep it | 
                                                        
| 818 | 818 | $css_quantity_selector = serialize(array($css_quantity_selector));  | 
                                                        
@@ -828,7 +828,7 @@ discard block  | 
                                                    ||
| 828 | 828 | */  | 
                                                        
| 829 | 829 | private function preparePriceSelector($css_price_selector)  | 
                                                        
| 830 | 830 |      { | 
                                                        
| 831 | -        if ($css_price_selector == 'default' || $css_price_selector == '') { | 
                                                        |
| 831 | +        if ($css_price_selector=='default' || $css_price_selector=='') { | 
                                                        |
| 832 | 832 | $css_price_selector = $this->defaultConfigs['PAGANTIS_SIMULATOR_CSS_PRICE_SELECTOR'];  | 
                                                        
| 833 | 833 |          } elseif (!unserialize($css_price_selector)) { //in the case of a custom string selector, we keep it | 
                                                        
| 834 | 834 | $css_price_selector = serialize(array($css_price_selector));  | 
                                                        
@@ -846,7 +846,7 @@ discard block  | 
                                                    ||
| 846 | 846 |      { | 
                                                        
| 847 | 847 | $metaProduct = get_post_meta($product_id);  | 
                                                        
| 848 | 848 |          return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && | 
                                                        
| 849 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';  | 
                                                        |
| 849 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';  | 
                                                        |
| 850 | 850 | }  | 
                                                        
| 851 | 851 | |
| 852 | 852 | /**  | 
                                                        
@@ -245,9 +245,9 @@ discard block  | 
                                                    ||
| 245 | 245 |                  if ($promotedProduct == 'true') { | 
                                                        
| 246 | 246 | $promotedAmount+=$product->getAmount();  | 
                                                        
| 247 | 247 | $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .  | 
                                                        
| 248 | - ' - Price: ' . $item->get_total() .  | 
                                                        |
| 249 | - ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 250 | - ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 248 | + ' - Price: ' . $item->get_total() .  | 
                                                        |
| 249 | + ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 250 | + ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 251 | 251 | $promotedMessage = substr($promotedMessage, 0, 999);  | 
                                                        
| 252 | 252 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 253 | 253 | }  | 
                                                        
@@ -263,9 +263,9 @@ discard block  | 
                                                    ||
| 263 | 263 | $orderConfigurationUrls = new Urls();  | 
                                                        
| 264 | 264 | $cancelUrl = $this->getKoUrl($order);  | 
                                                        
| 265 | 265 |              $callback_arg = array('wc-api'=>'wcpagantisgateway', | 
                                                        
| 266 | - 'key'=>$order->get_order_key(),  | 
                                                        |
| 267 | - 'order-received'=>$order->get_id(),  | 
                                                        |
| 268 | - 'origin' => ''  | 
                                                        |
| 266 | + 'key'=>$order->get_order_key(),  | 
                                                        |
| 267 | + 'order-received'=>$order->get_id(),  | 
                                                        |
| 268 | + 'origin' => ''  | 
                                                        |
| 269 | 269 | );  | 
                                                        
| 270 | 270 | |
| 271 | 271 | $callback_arg_user = $callback_arg;  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | $this->method_title = ucfirst($this->id);  | 
                                                        
| 61 | 61 | |
| 62 | 62 | //Useful vars  | 
                                                        
| 63 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/';  | 
                                                        |
| 63 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/';  | 
                                                        |
| 64 | 64 | $this->allowed_currencies = getAllowedCurrencies();  | 
                                                        
| 65 | 65 | $this->language = strstr(get_locale(), '_', true);  | 
                                                        
| 66 | 66 |          if ($this->language=='') { | 
                                                        
@@ -69,24 +69,24 @@ discard block  | 
                                                    ||
| 69 | 69 | $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';  | 
                                                        
| 70 | 70 | |
| 71 | 71 | //Panel form fields  | 
                                                        
| 72 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options  | 
                                                        |
| 72 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options  | 
                                                        |
| 73 | 73 | $this->init_settings();  | 
                                                        
| 74 | 74 | |
| 75 | 75 | $this->extraConfig = getExtraConfig();  | 
                                                        
| 76 | 76 | $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis');  | 
                                                        
| 77 | 77 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";  | 
                                                        
| 78 | 78 | |
| 79 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();  | 
                                                        |
| 80 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();  | 
                                                        |
| 79 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();  | 
                                                        |
| 80 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();  | 
                                                        |
| 81 | 81 |          foreach ($this->settings as $setting_key => $setting_value) { | 
                                                        
| 82 | 82 | $this->$setting_key = $setting_value;  | 
                                                        
| 83 | 83 | }  | 
                                                        
| 84 | 84 | |
| 85 | 85 | //Hooks  | 
                                                        
| 86 | -        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options | 
                                                        |
| 87 | -        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form | 
                                                        |
| 88 | -        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification | 
                                                        |
| 89 | -        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); | 
                                                        |
| 86 | +        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options | 
                                                        |
| 87 | +        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form | 
                                                        |
| 88 | +        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification | 
                                                        |
| 89 | +        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); | 
                                                        |
| 90 | 90 |          add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); | 
                                                        
| 91 | 91 | }  | 
                                                        
| 92 | 92 | |
@@ -98,8 +98,8 @@ discard block  | 
                                                    ||
| 98 | 98 | */  | 
                                                        
| 99 | 99 | public function loadPagantisTranslation($mofile, $domain)  | 
                                                        
| 100 | 100 |      { | 
                                                        
| 101 | -        if ('pagantis' === $domain) { | 
                                                        |
| 102 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';  | 
                                                        |
| 101 | +        if ('pagantis'===$domain) { | 
                                                        |
| 102 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';  | 
                                                        |
| 103 | 103 | }  | 
                                                        
| 104 | 104 | return $mofile;  | 
                                                        
| 105 | 105 | }  | 
                                                        
@@ -148,7 +148,7 @@ discard block  | 
                                                    ||
| 148 | 148 | |
| 149 | 149 |              $shippingAddress = $order->get_address('shipping'); | 
                                                        
| 150 | 150 |              $billingAddress = $order->get_address('billing'); | 
                                                        
| 151 | -            if ($shippingAddress['address_1'] == '') { | 
                                                        |
| 151 | +            if ($shippingAddress['address_1']=='') { | 
                                                        |
| 152 | 152 | $shippingAddress = $billingAddress;  | 
                                                        
| 153 | 153 | }  | 
                                                        
| 154 | 154 | |
@@ -175,7 +175,7 @@ discard block  | 
                                                    ||
| 175 | 175 | ->setNationalId($national_id)  | 
                                                        
| 176 | 176 | ->setTaxId($tax_id)  | 
                                                        
| 177 | 177 | ;  | 
                                                        
| 178 | - $orderBillingAddress = new Address();  | 
                                                        |
| 178 | + $orderBillingAddress = new Address();  | 
                                                        |
| 179 | 179 | $orderBillingAddress  | 
                                                        
| 180 | 180 | ->setZipCode($billingAddress['postcode'])  | 
                                                        
| 181 | 181 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])  | 
                                                        
@@ -248,12 +248,12 @@ discard block  | 
                                                    ||
| 248 | 248 | $details->addProduct($product);  | 
                                                        
| 249 | 249 | |
| 250 | 250 | $promotedProduct = isProductPromoted($item->get_product_id());  | 
                                                        
| 251 | -                if ($promotedProduct == 'true') { | 
                                                        |
| 252 | - $promotedAmount+=$product->getAmount();  | 
                                                        |
| 253 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .  | 
                                                        |
| 254 | - ' - Price: ' . $item->get_total() .  | 
                                                        |
| 255 | - ' - Qty: ' . $product->getQuantity() .  | 
                                                        |
| 256 | - ' - Item ID: ' . $item['id_product'];  | 
                                                        |
| 251 | +                if ($promotedProduct=='true') { | 
                                                        |
| 252 | + $promotedAmount += $product->getAmount();  | 
                                                        |
| 253 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().  | 
                                                        |
| 254 | + ' - Price: '.$item->get_total().  | 
                                                        |
| 255 | + ' - Qty: '.$product->getQuantity().  | 
                                                        |
| 256 | + ' - Item ID: '.$item['id_product'];  | 
                                                        |
| 257 | 257 | $promotedMessage = substr($promotedMessage, 0, 999);  | 
                                                        
| 258 | 258 |                      $metadataOrder->addMetadata('promotedProduct', $promotedMessage); | 
                                                        
| 259 | 259 | }  | 
                                                        
@@ -299,9 +299,7 @@ discard block  | 
                                                    ||
| 299 | 299 | |
| 300 | 300 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);  | 
                                                        
| 301 | 301 | $purchaseCountry =  | 
                                                        
| 302 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language :  | 
                                                        |
| 303 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :  | 
                                                        |
| 304 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;  | 
                                                        |
| 302 | + in_array(strtolower($this->language), $allowedCountries) ? $this->language : in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;  | 
                                                        |
| 305 | 303 | |
| 306 | 304 | $orderConfiguration = new Configuration();  | 
                                                        
| 307 | 305 | $orderConfiguration  | 
                                                        
@@ -345,7 +343,7 @@ discard block  | 
                                                    ||
| 345 | 343 |                  wc_get_template('iframe.php', $template_fields, '', $this->template_path); | 
                                                        
| 346 | 344 | }  | 
                                                        
| 347 | 345 |          } catch (\Exception $exception) { | 
                                                        
| 348 | -            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); | 
                                                        |
| 346 | +            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); | 
                                                        |
| 349 | 347 | insertLogEntry($exception);  | 
                                                        
| 350 | 348 |              $checkout_url = get_permalink(wc_get_page_id('checkout')); | 
                                                        
| 351 | 349 | wp_redirect($checkout_url);  | 
                                                        
@@ -361,7 +359,7 @@ discard block  | 
                                                    ||
| 361 | 359 | public function pagantisNotification()  | 
                                                        
| 362 | 360 |      { | 
                                                        
| 363 | 361 |          try { | 
                                                        
| 364 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';  | 
                                                        |
| 362 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';  | 
                                                        |
| 365 | 363 | |
| 366 | 364 |              include_once('notifyController.php'); | 
                                                        
| 367 | 365 | $notify = new WcPagantisNotify();  | 
                                                        
@@ -400,10 +398,10 @@ discard block  | 
                                                    ||
| 400 | 398 | */  | 
                                                        
| 401 | 399 | public function pagantisCompleteStatus($status, $order_id, $order)  | 
                                                        
| 402 | 400 |      { | 
                                                        
| 403 | -        if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { | 
                                                        |
| 404 | -            if ($order->get_status() == 'failed') { | 
                                                        |
| 401 | +        if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { | 
                                                        |
| 402 | +            if ($order->get_status()=='failed') { | 
                                                        |
| 405 | 403 | $status = 'processing';  | 
                                                        
| 406 | -            } elseif ($order->get_status() == 'pending' && $status=='completed') { | 
                                                        |
| 404 | +            } elseif ($order->get_status()=='pending' && $status=='completed') { | 
                                                        |
| 407 | 405 | $status = 'processing';  | 
                                                        
| 408 | 406 | }  | 
                                                        
| 409 | 407 | }  | 
                                                        
@@ -432,8 +430,8 @@ discard block  | 
                                                    ||
| 432 | 430 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries));  | 
                                                        
| 433 | 431 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x'];  | 
                                                        
| 434 | 432 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x'];  | 
                                                        
| 435 | - $totalPrice = (int)$this->get_order_total();  | 
                                                        |
| 436 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));  | 
                                                        |
| 433 | + $totalPrice = (int) $this->get_order_total();  | 
                                                        |
| 434 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));  | 
                                                        |
| 437 | 435 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' &&  | 
                                                        
| 438 | 436 |              $validAmount && $allowedCountry) { | 
                                                        
| 439 | 437 | return true;  | 
                                                        
@@ -468,7 +466,7 @@ discard block  | 
                                                    ||
| 468 | 466 | |
| 469 | 467 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function  | 
                                                        
| 470 | 468 |              if (strpos($redirectUrl, 'order-pay=')===false) { | 
                                                        
| 471 | - $redirectUrl.="&order-pay=".$order_id;  | 
                                                        |
| 469 | + $redirectUrl .= "&order-pay=".$order_id;  | 
                                                        |
| 472 | 470 | }  | 
                                                        
| 473 | 471 | |
| 474 | 472 | return array(  | 
                                                        
@@ -476,7 +474,7 @@ discard block  | 
                                                    ||
| 476 | 474 | 'redirect' => $redirectUrl  | 
                                                        
| 477 | 475 | );  | 
                                                        
| 478 | 476 |          } catch (Exception $e) { | 
                                                        
| 479 | -            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); | 
                                                        |
| 477 | +            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); | 
                                                        |
| 480 | 478 | return array();  | 
                                                        
| 481 | 479 | }  | 
                                                        
| 482 | 480 | }  | 
                                                        
@@ -547,7 +545,7 @@ discard block  | 
                                                    ||
| 547 | 545 | private function generateUrl($url)  | 
                                                        
| 548 | 546 |      { | 
                                                        
| 549 | 547 | $parsed_url = parse_url($url);  | 
                                                        
| 550 | -        if ($parsed_url !== false) { | 
                                                        |
| 548 | +        if ($parsed_url!==false) { | 
                                                        |
| 551 | 549 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];  | 
                                                        
| 552 | 550 | parse_str($parsed_url['query'], $arrayParams);  | 
                                                        
| 553 | 551 |              foreach ($arrayParams as $keyParam => $valueParam) { | 
                                                        
@@ -595,11 +593,10 @@ discard block  | 
                                                    ||
| 595 | 593 | private function getKeysUrl($order, $url)  | 
                                                        
| 596 | 594 |      { | 
                                                        
| 597 | 595 | $defaultFields = (get_class($order)=='WC_Order') ?  | 
                                                        
| 598 | -            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : | 
                                                        |
| 599 | - array();  | 
                                                        |
| 596 | +            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); | 
                                                        |
| 600 | 597 | |
| 601 | 598 | $parsedUrl = parse_url($url);  | 
                                                        
| 602 | -        if ($parsedUrl !== false) { | 
                                                        |
| 599 | +        if ($parsedUrl!==false) { | 
                                                        |
| 603 | 600 | //Replace parameters from url  | 
                                                        
| 604 | 601 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);  | 
                                                        
| 605 | 602 | |
@@ -644,7 +641,7 @@ discard block  | 
                                                    ||
| 644 | 641 |          foreach ($arrayParams as $keyParam => $valueParam) { | 
                                                        
| 645 | 642 |              preg_match('#\{{.*?}\}#', $valueParam, $match); | 
                                                        
| 646 | 643 |              if (count($match)) { | 
                                                        
| 647 | -                $key = str_replace(array('{{','}}'), array('',''), $match[0]); | 
                                                        |
| 644 | +                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); | 
                                                        |
| 648 | 645 | $arrayParams[$keyParam] = $defaultFields[$key];  | 
                                                        
| 649 | 646 | }  | 
                                                        
| 650 | 647 | }  | 
                                                        
@@ -659,12 +656,12 @@ discard block  | 
                                                    ||
| 659 | 656 | */  | 
                                                        
| 660 | 657 | private function unparseUrl($parsed_url)  | 
                                                        
| 661 | 658 |      { | 
                                                        
| 662 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';  | 
                                                        |
| 659 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';  | 
                                                        |
| 663 | 660 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';  | 
                                                        
| 664 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';  | 
                                                        |
| 665 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';  | 
                                                        |
| 666 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';  | 
                                                        |
| 661 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';  | 
                                                        |
| 662 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';  | 
                                                        |
| 663 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';  | 
                                                        |
| 667 | 664 | $path = $parsed_url['path'];  | 
                                                        
| 668 | - return $scheme . $host . $port . $path . $query . $fragment;  | 
                                                        |
| 665 | + return $scheme.$host.$port.$path.$query.$fragment;  | 
                                                        |
| 669 | 666 | }  | 
                                                        
| 670 | 667 | }  | 
                                                        
@@ -1,8 +1,8 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | function requireWPPluginFunctions()  | 
                                                        
| 3 | 3 |  { | 
                                                        
| 4 | -    if (! function_exists('is_plugin_active')) { | 
                                                        |
| 5 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php');  | 
                                                        |
| 4 | +    if (!function_exists('is_plugin_active')) { | 
                                                        |
| 5 | + require_once(ABSPATH.'wp-admin/includes/plugin.php');  | 
                                                        |
| 6 | 6 | }  | 
                                                        
| 7 | 7 | }  | 
                                                        
| 8 | 8 | |
@@ -20,7 +20,7 @@ discard block  | 
                                                    ||
| 20 | 20 | function getConfigValue($configKey)  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | global $wpdb;  | 
                                                        
| 23 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 23 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 24 | 24 |      $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey)); | 
                                                        
| 25 | 25 | |
| 26 | 26 | return $value;  | 
                                                        
@@ -37,8 +37,8 @@ discard block  | 
                                                    ||
| 37 | 37 | function isPgTableCreated($tableToCheck)  | 
                                                        
| 38 | 38 |  { | 
                                                        
| 39 | 39 | global $wpdb;  | 
                                                        
| 40 | - $tableName = $wpdb->prefix . $tableToCheck;  | 
                                                        |
| 41 | -    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) { | 
                                                        |
| 40 | + $tableName = $wpdb->prefix.$tableToCheck;  | 
                                                        |
| 41 | +    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) { | 
                                                        |
| 42 | 42 | return true;  | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
@@ -51,12 +51,12 @@ discard block  | 
                                                    ||
| 51 | 51 | function createPgCartTable()  | 
                                                        
| 52 | 52 |  { | 
                                                        
| 53 | 53 | global $wpdb;  | 
                                                        
| 54 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;  | 
                                                        |
| 54 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;  | 
                                                        |
| 55 | 55 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 56 | 56 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  | 
                                                        
| 57 | 57 | UNIQUE KEY id (id)) $charset_collate";  | 
                                                        
| 58 | 58 | |
| 59 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');  | 
                                                        |
| 59 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php');  | 
                                                        |
| 60 | 60 | dbDelta($sql);  | 
                                                        
| 61 | 61 | }  | 
                                                        
| 62 | 62 | |
@@ -64,14 +64,14 @@ discard block  | 
                                                    ||
| 64 | 64 |  { | 
                                                        
| 65 | 65 | global $wpdb;  | 
                                                        
| 66 | 66 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 67 | - $LogsTableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;  | 
                                                        |
| 67 | + $LogsTableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;  | 
                                                        |
| 68 | 68 | $sqlQuery = "CREATE TABLE $LogsTableName (  | 
                                                        
| 69 | 69 | id int NOT NULL AUTO_INCREMENT,  | 
                                                        
| 70 | 70 | log text NOT NULL,  | 
                                                        
| 71 | 71 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP,  | 
                                                        
| 72 | 72 | UNIQUE KEY id (id))  | 
                                                        
| 73 | 73 | $charset_collate";  | 
                                                        
| 74 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');  | 
                                                        |
| 74 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php');  | 
                                                        |
| 75 | 75 | dbDelta($sqlQuery);  | 
                                                        
| 76 | 76 | }  | 
                                                        
| 77 | 77 | |
@@ -82,7 +82,7 @@ discard block  | 
                                                    ||
| 82 | 82 | function insertLogEntry($exception = null, $message = null)  | 
                                                        
| 83 | 83 |  { | 
                                                        
| 84 | 84 | global $wpdb;  | 
                                                        
| 85 | -    if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) { | 
                                                        |
| 85 | +    if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) { | 
                                                        |
| 86 | 86 | createLogsTable();  | 
                                                        
| 87 | 87 | }  | 
                                                        
| 88 | 88 | $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();  | 
                                                        
@@ -91,7 +91,7 @@ discard block  | 
                                                    ||
| 91 | 91 |      } else { | 
                                                        
| 92 | 92 | $logEntry = $logEntry->info($message);  | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | - $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;  | 
                                                        |
| 94 | + $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;  | 
                                                        |
| 95 | 95 |      $wpdb->insert($tableName, array('log' => $logEntry->toJson())); | 
                                                        
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
@@ -102,7 +102,7 @@ discard block  | 
                                                    ||
| 102 | 102 |  { | 
                                                        
| 103 | 103 | $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();  | 
                                                        
| 104 | 104 |      $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep'); | 
                                                        
| 105 | -    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) { | 
                                                        |
| 105 | +    if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) { | 
                                                        |
| 106 | 106 | return true;  | 
                                                        
| 107 | 107 |      } else { | 
                                                        
| 108 | 108 | return false;  | 
                                                        
@@ -117,7 +117,7 @@ discard block  | 
                                                    ||
| 117 | 117 |  { | 
                                                        
| 118 | 118 | $pgThousandSeparator = getPgSimulatorThousandsSeparator();  | 
                                                        
| 119 | 119 |      $wc_price_thousand   = get_option('woocommerce_price_thousand_sep'); | 
                                                        
| 120 | -    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) { | 
                                                        |
| 120 | +    if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) { | 
                                                        |
| 121 | 121 | return true;  | 
                                                        
| 122 | 122 |      } else { | 
                                                        
| 123 | 123 | return false;  | 
                                                        
@@ -130,7 +130,7 @@ discard block  | 
                                                    ||
| 130 | 130 | function getPgSimulatorThousandsSeparator()  | 
                                                        
| 131 | 131 |  { | 
                                                        
| 132 | 132 | global $wpdb;  | 
                                                        
| 133 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 133 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 134 | 134 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";  | 
                                                        
| 135 | 135 | $result = $wpdb->get_row($query, ARRAY_A);  | 
                                                        
| 136 | 136 | |
@@ -143,7 +143,7 @@ discard block  | 
                                                    ||
| 143 | 143 | function getPgSimulatorDecimalSeparatorConfig()  | 
                                                        
| 144 | 144 |  { | 
                                                        
| 145 | 145 | global $wpdb;  | 
                                                        
| 146 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 146 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 147 | 147 | $query = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";  | 
                                                        
| 148 | 148 | $result = $wpdb->get_row($query, ARRAY_A);  | 
                                                        
| 149 | 149 | |
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 |      if (areThousandsSeparatorEqual()) { | 
                                                        
| 157 | 157 | return;  | 
                                                        
| 158 | 158 | }  | 
                                                        
| 159 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 159 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 160 | 160 |      $thousandSeparator = get_option('woocommerce_price_thousand_sep'); | 
                                                        
| 161 | 161 | $wpdb->update(  | 
                                                        
| 162 | 162 | $tableName,  | 
                                                        
@@ -173,7 +173,7 @@ discard block  | 
                                                    ||
| 173 | 173 |      if (areDecimalSeparatorEqual()) { | 
                                                        
| 174 | 174 | return;  | 
                                                        
| 175 | 175 | }  | 
                                                        
| 176 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 176 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 177 | 177 |      $decimalSeparator = get_option('woocommerce_price_decimal_sep'); | 
                                                        
| 178 | 178 | $wpdb->update(  | 
                                                        
| 179 | 179 | $tableName,  | 
                                                        
@@ -193,7 +193,7 @@ discard block  | 
                                                    ||
| 193 | 193 | */  | 
                                                        
| 194 | 194 | function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)  | 
                                                        
| 195 | 195 |  { | 
                                                        
| 196 | -    if (! in_array($simulatorType, $validSimulatorTypes)) { | 
                                                        |
| 196 | +    if (!in_array($simulatorType, $validSimulatorTypes)) { | 
                                                        |
| 197 | 197 | return false;  | 
                                                        
| 198 | 198 | }  | 
                                                        
| 199 | 199 | |
@@ -220,8 +220,8 @@ discard block  | 
                                                    ||
| 220 | 220 | function areMerchantKeysSet()  | 
                                                        
| 221 | 221 |  { | 
                                                        
| 222 | 222 |      $settings   = get_option('woocommerce_pagantis_settings'); | 
                                                        
| 223 | - $publicKey = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';  | 
                                                        |
| 224 | - $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';  | 
                                                        |
| 223 | + $publicKey = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';  | 
                                                        |
| 224 | + $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';  | 
                                                        |
| 225 | 225 |      if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { | 
                                                        
| 226 | 226 | return false;  | 
                                                        
| 227 | 227 | }  | 
                                                        
@@ -232,8 +232,8 @@ discard block  | 
                                                    ||
| 232 | 232 | function areMerchantKeysSet4x()  | 
                                                        
| 233 | 233 |  { | 
                                                        
| 234 | 234 |      $settings   = get_option('woocommerce_pagantis_settings'); | 
                                                        
| 235 | - $publicKey = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';  | 
                                                        |
| 236 | - $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';  | 
                                                        |
| 235 | + $publicKey = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';  | 
                                                        |
| 236 | + $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';  | 
                                                        |
| 237 | 237 |      if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) { | 
                                                        
| 238 | 238 | return false;  | 
                                                        
| 239 | 239 | }  | 
                                                        
@@ -244,7 +244,7 @@ discard block  | 
                                                    ||
| 244 | 244 | function isSimulatorEnabled()  | 
                                                        
| 245 | 245 |  { | 
                                                        
| 246 | 246 |      $settings = get_option('woocommerce_pagantis_settings'); | 
                                                        
| 247 | -    if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) { | 
                                                        |
| 247 | +    if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) { | 
                                                        |
| 248 | 248 | return true;  | 
                                                        
| 249 | 249 | }  | 
                                                        
| 250 | 250 | |
@@ -255,13 +255,13 @@ discard block  | 
                                                    ||
| 255 | 255 |  { | 
                                                        
| 256 | 256 |      $settings = get_option('woocommerce_pagantis_settings'); | 
                                                        
| 257 | 257 | |
| 258 | - return (! empty($settings['enabled']) && 'yes' === $settings['enabled']);  | 
                                                        |
| 258 | + return (!empty($settings['enabled']) && 'yes'===$settings['enabled']);  | 
                                                        |
| 259 | 259 | }  | 
                                                        
| 260 | 260 | |
| 261 | 261 | function isPluginEnabled4x()  | 
                                                        
| 262 | 262 |  { | 
                                                        
| 263 | 263 |      $settings = get_option('woocommerce_pagantis_settings'); | 
                                                        
| 264 | - return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);  | 
                                                        |
| 264 | + return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']);  | 
                                                        |
| 265 | 265 | }  | 
                                                        
| 266 | 266 | |
| 267 | 267 | |
@@ -269,7 +269,7 @@ discard block  | 
                                                    ||
| 269 | 269 |  { | 
                                                        
| 270 | 270 | $locale = strtolower(strstr(get_locale(), '_', true));  | 
                                                        
| 271 | 271 |      $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES')); | 
                                                        
| 272 | -    if (! in_array(strtolower($locale), $allowedCountries)) { | 
                                                        |
| 272 | +    if (!in_array(strtolower($locale), $allowedCountries)) { | 
                                                        |
| 273 | 273 | return false;  | 
                                                        
| 274 | 274 | }  | 
                                                        
| 275 | 275 | |
@@ -286,7 +286,7 @@ discard block  | 
                                                    ||
| 286 | 286 | global $product;  | 
                                                        
| 287 | 287 |      if (method_exists($product, 'get_price')) { | 
                                                        
| 288 | 288 | $productPrice = $product->get_price();  | 
                                                        
| 289 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));  | 
                                                        |
| 289 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));  | 
                                                        |
| 290 | 290 |          if ($validAmount) { | 
                                                        
| 291 | 291 | return true;  | 
                                                        
| 292 | 292 | }  | 
                                                        
@@ -305,7 +305,7 @@ discard block  | 
                                                    ||
| 305 | 305 | global $product;  | 
                                                        
| 306 | 306 |      if (method_exists($product, 'get_price')) { | 
                                                        
| 307 | 307 | $productPrice = $product->get_price();  | 
                                                        
| 308 | - $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));  | 
                                                        |
| 308 | + $validAmount = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));  | 
                                                        |
| 309 | 309 |          if ($validAmount) { | 
                                                        
| 310 | 310 | return true;  | 
                                                        
| 311 | 311 | }  | 
                                                        
@@ -324,7 +324,7 @@ discard block  | 
                                                    ||
| 324 | 324 | function getExtraConfig()  | 
                                                        
| 325 | 325 |  { | 
                                                        
| 326 | 326 | global $wpdb;  | 
                                                        
| 327 | - $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 327 | + $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;  | 
                                                        |
| 328 | 328 | $response = array();  | 
                                                        
| 329 | 329 |      $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A); | 
                                                        
| 330 | 330 |      foreach ($dbResult as $value) { | 
                                                        
@@ -336,8 +336,8 @@ discard block  | 
                                                    ||
| 336 | 336 | |
| 337 | 337 | function getModuleComposerVersion($moduleAbsolutePath)  | 
                                                        
| 338 | 338 |  { | 
                                                        
| 339 | - $maybe_composer_json = $moduleAbsolutePath . 'composer.json';  | 
                                                        |
| 340 | -    if (! file_exists($maybe_composer_json) && ! is_readable($maybe_composer_json)) { | 
                                                        |
| 339 | + $maybe_composer_json = $moduleAbsolutePath.'composer.json';  | 
                                                        |
| 340 | +    if (!file_exists($maybe_composer_json) && !is_readable($maybe_composer_json)) { | 
                                                        |
| 341 | 341 | return null;  | 
                                                        
| 342 | 342 | }  | 
                                                        
| 343 | 343 | $composer = json_decode(file_get_contents($maybe_composer_json));  | 
                                                        
@@ -356,9 +356,9 @@ discard block  | 
                                                    ||
| 356 | 356 | */  | 
                                                        
| 357 | 357 | function getNationalId($order)  | 
                                                        
| 358 | 358 |  { | 
                                                        
| 359 | -    foreach ((array)$order->get_meta_data() as $mdObject) { | 
                                                        |
| 359 | +    foreach ((array) $order->get_meta_data() as $mdObject) { | 
                                                        |
| 360 | 360 | $data = $mdObject->get_data();  | 
                                                        
| 361 | -        if ($data['key'] == 'vat_number') { | 
                                                        |
| 361 | +        if ($data['key']=='vat_number') { | 
                                                        |
| 362 | 362 | return $data['value'];  | 
                                                        
| 363 | 363 | }  | 
                                                        
| 364 | 364 | }  | 
                                                        
@@ -373,9 +373,9 @@ discard block  | 
                                                    ||
| 373 | 373 | */  | 
                                                        
| 374 | 374 | function getTaxId($order)  | 
                                                        
| 375 | 375 |  { | 
                                                        
| 376 | -    foreach ((array)$order->get_meta_data() as $mdObject) { | 
                                                        |
| 376 | +    foreach ((array) $order->get_meta_data() as $mdObject) { | 
                                                        |
| 377 | 377 | $data = $mdObject->get_data();  | 
                                                        
| 378 | -        if ($data['key'] == 'billing_cfpiva') { | 
                                                        |
| 378 | +        if ($data['key']=='billing_cfpiva') { | 
                                                        |
| 379 | 379 | return $data['value'];  | 
                                                        
| 380 | 380 | }  | 
                                                        
| 381 | 381 | }  | 
                                                        
@@ -392,7 +392,7 @@ discard block  | 
                                                    ||
| 392 | 392 | $metaProduct = get_post_meta($product_id);  | 
                                                        
| 393 | 393 | |
| 394 | 394 |      return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) | 
                                                        
| 395 | - && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';  | 
                                                        |
| 395 | + && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';  | 
                                                        |
| 396 | 396 | }  | 
                                                        
| 397 | 397 | |
| 398 | 398 | /**  | 
                                                        
@@ -403,7 +403,7 @@ discard block  | 
                                                    ||
| 403 | 403 | $promotedAmount = 0;  | 
                                                        
| 404 | 404 |      foreach (WC()->cart->get_cart() as $key => $item) { | 
                                                        
| 405 | 405 | $promotedProduct = isProductPromoted($item['product_id']);  | 
                                                        
| 406 | -        if ($promotedProduct == 'true') { | 
                                                        |
| 406 | +        if ($promotedProduct=='true') { | 
                                                        |
| 407 | 407 | $promotedAmount += $item['line_total'] + $item['line_tax'];  | 
                                                        
| 408 | 408 | }  | 
                                                        
| 409 | 409 | }  | 
                                                        
@@ -421,12 +421,12 @@ discard block  | 
                                                    ||
| 421 | 421 |  { | 
                                                        
| 422 | 422 | global $wpdb;  | 
                                                        
| 423 | 423 | checkCartProcessTable();  | 
                                                        
| 424 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;  | 
                                                        |
| 424 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;  | 
                                                        |
| 425 | 425 | |
| 426 | 426 | //Check if id exists  | 
                                                        
| 427 | 427 |      $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$orderId'"); | 
                                                        
| 428 | 428 | $countResults = count($resultsSelect);  | 
                                                        
| 429 | -    if ($countResults == 0) { | 
                                                        |
| 429 | +    if ($countResults==0) { | 
                                                        |
| 430 | 430 |          $wpdb->insert($tableName, array('id' => $orderId, 'order_id' => $pagantisOrderId), array('%d', '%s')); | 
                                                        
| 431 | 431 |      } else { | 
                                                        
| 432 | 432 |          $wpdb->update($tableName, array('order_id' => $pagantisOrderId), array('id' => $orderId), array('%s'), array('%d')); | 
                                                        
@@ -439,14 +439,14 @@ discard block  | 
                                                    ||
| 439 | 439 | function checkCartProcessTable()  | 
                                                        
| 440 | 440 |  { | 
                                                        
| 441 | 441 | global $wpdb;  | 
                                                        
| 442 | - $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;  | 
                                                        |
| 442 | + $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;  | 
                                                        |
| 443 | 443 | |
| 444 | -    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { | 
                                                        |
| 444 | +    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { | 
                                                        |
| 445 | 445 | $charset_collate = $wpdb->get_charset_collate();  | 
                                                        
| 446 | 446 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  | 
                                                        
| 447 | 447 | UNIQUE KEY id (id)) $charset_collate";  | 
                                                        
| 448 | 448 | |
| 449 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php');  | 
                                                        |
| 449 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php');  | 
                                                        |
| 450 | 450 | dbDelta($sql);  | 
                                                        
| 451 | 451 | }  | 
                                                        
| 452 | 452 | }  | 
                                                        
@@ -489,7 +489,7 @@ discard block  | 
                                                    ||
| 489 | 489 |              'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), | 
                                                        
| 490 | 490 | ));  | 
                                                        
| 491 | 491 |          foreach ($customer_orders as $customer_order) { | 
                                                        
| 492 | -            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { | 
                                                        |
| 492 | +            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) { | 
                                                        |
| 493 | 493 | $sign_up = substr($customer_order->post_date, 0, 10);  | 
                                                        
| 494 | 494 | }  | 
                                                        
| 495 | 495 | }  | 
                                                        
@@ -500,5 +500,5 @@ discard block  | 
                                                    ||
| 500 | 500 | |
| 501 | 501 | function isPagePaymentPage()  | 
                                                        
| 502 | 502 |  { | 
                                                        
| 503 | - return (is_checkout() && ! is_order_received_page()) || is_checkout_pay_page();  | 
                                                        |
| 503 | + return (is_checkout() && !is_order_received_page()) || is_checkout_pay_page();  | 
                                                        |
| 504 | 504 | }  |