@@ -54,36 +54,36 @@ discard block |
||
54 | 54 | $this->title = $this->extraConfig['PAGANTIS_TITLE']; |
55 | 55 | |
56 | 56 | //Useful vars |
57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
58 | 58 | $this->allowed_currencies = array("EUR"); |
59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false); |
61 | 61 | $this->language = strstr(get_locale(), '_', true); |
62 | 62 | |
63 | - if ($this->language == 'es' || $this->language == '') { |
|
63 | + if ($this->language=='es' || $this->language=='') { |
|
64 | 64 | $this->icon = esc_url(plugins_url('../assets/images/logopagamastarde.png', __FILE__)); |
65 | 65 | } else { |
66 | 66 | $this->icon = esc_url(plugins_url('../assets/images/logo.png', __FILE__)); |
67 | 67 | } |
68 | 68 | |
69 | 69 | //Panel form fields |
70 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
70 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
71 | 71 | $this->init_settings(); |
72 | 72 | |
73 | 73 | $this->extraConfig = $this->getExtraConfig(); |
74 | 74 | |
75 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
76 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
75 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
76 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
77 | 77 | foreach ($this->settings as $setting_key => $setting_value) { |
78 | 78 | $this->$setting_key = $setting_value; |
79 | 79 | } |
80 | 80 | |
81 | 81 | //Hooks |
82 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
83 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
84 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
85 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
86 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
82 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
83 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
84 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
85 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
86 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
87 | 87 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
88 | 88 | } |
89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function loadPagantisTranslation($mofile, $domain) |
97 | 97 | { |
98 | - if ('pagantis' === $domain) { |
|
99 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
98 | + if ('pagantis'===$domain) { |
|
99 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
100 | 100 | } |
101 | 101 | return $mofile; |
102 | 102 | } |
@@ -129,24 +129,24 @@ discard block |
||
129 | 129 | public function pagantisCheckFields() |
130 | 130 | { |
131 | 131 | $error_string = ''; |
132 | - if ($this->settings['enabled'] !== 'yes') { |
|
132 | + if ($this->settings['enabled']!=='yes') { |
|
133 | 133 | return; |
134 | 134 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) { |
135 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
135 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis'); |
|
136 | 136 | $this->settings['enabled'] = 'no'; |
137 | 137 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") { |
138 | 138 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis'); |
139 | 139 | $this->settings['enabled'] = 'no'; |
140 | 140 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) { |
141 | - $error_string = __(' only can be used in Euros', 'pagantis'); |
|
141 | + $error_string = __(' only can be used in Euros', 'pagantis'); |
|
142 | 142 | $this->settings['enabled'] = 'no'; |
143 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
144 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') { |
|
143 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
144 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') { |
|
145 | 145 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
146 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
147 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') { |
|
146 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
147 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') { |
|
148 | 148 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis'); |
149 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) { |
|
149 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) { |
|
150 | 150 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis'); |
151 | 151 | } |
152 | 152 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $shippingAddress = $order->get_address('shipping'); |
182 | 182 | $billingAddress = $order->get_address('billing'); |
183 | - if ($shippingAddress['address_1'] == '') { |
|
183 | + if ($shippingAddress['address_1']=='') { |
|
184 | 184 | $shippingAddress = $billingAddress; |
185 | 185 | } |
186 | 186 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ->setNationalId($national_id) |
208 | 208 | ->setTaxId($tax_id) |
209 | 209 | ; |
210 | - $orderBillingAddress = new Address(); |
|
210 | + $orderBillingAddress = new Address(); |
|
211 | 211 | $orderBillingAddress |
212 | 212 | ->setZipCode($billingAddress['postcode']) |
213 | 213 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
339 | 339 | } |
340 | 340 | } catch (\Exception $exception) { |
341 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
341 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
342 | 342 | $this->insertLog($exception); |
343 | 343 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
344 | 344 | wp_redirect($checkout_url); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | public function pagantisNotification() |
353 | 353 | { |
354 | 354 | try { |
355 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
355 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
356 | 356 | |
357 | 357 | include_once('notifyController.php'); |
358 | 358 | $notify = new WcPagantisNotify(); |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function pagantisCompleteStatus($status, $order_id, $order) |
393 | 393 | { |
394 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
395 | - if ($order->get_status() == 'failed') { |
|
394 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
395 | + if ($order->get_status()=='failed') { |
|
396 | 396 | $status = 'processing'; |
397 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
397 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
398 | 398 | $status = 'processing'; |
399 | 399 | } |
400 | 400 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
419 | 419 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
420 | 420 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
421 | - (int)$this->get_order_total()>$this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
421 | + (int) $this->get_order_total() > $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
422 | 422 | return true; |
423 | 423 | } |
424 | 424 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
448 | 448 | if (strpos($redirectUrl, 'order-pay=')===false) { |
449 | - $redirectUrl.="&order-pay=".$order_id; |
|
449 | + $redirectUrl .= "&order-pay=".$order_id; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return array( |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | ); |
456 | 456 | |
457 | 457 | } catch (Exception $e) { |
458 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
458 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
459 | 459 | return array(); |
460 | 460 | } |
461 | 461 | } |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | private function generateUrl($url) |
516 | 516 | { |
517 | 517 | $parsed_url = parse_url($url); |
518 | - if ($parsed_url !== false) { |
|
518 | + if ($parsed_url!==false) { |
|
519 | 519 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
520 | 520 | parse_str($parsed_url['query'], $arrayParams); |
521 | 521 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -563,11 +563,10 @@ discard block |
||
563 | 563 | private function getKeysUrl($order, $url) |
564 | 564 | { |
565 | 565 | $defaultFields = (get_class($order)=='WC_Order') ? |
566 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
567 | - array(); |
|
566 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
568 | 567 | |
569 | 568 | $parsedUrl = parse_url($url); |
570 | - if ($parsedUrl !== false) { |
|
569 | + if ($parsedUrl!==false) { |
|
571 | 570 | //Replace parameters from url |
572 | 571 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
573 | 572 | |
@@ -612,7 +611,7 @@ discard block |
||
612 | 611 | foreach ($arrayParams as $keyParam => $valueParam) { |
613 | 612 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
614 | 613 | if (count($match)) { |
615 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
614 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
616 | 615 | $arrayParams[$keyParam] = $defaultFields[$key]; |
617 | 616 | } |
618 | 617 | } |
@@ -627,13 +626,13 @@ discard block |
||
627 | 626 | */ |
628 | 627 | private function unparseUrl($parsed_url) |
629 | 628 | { |
630 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
629 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
631 | 630 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
632 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
633 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
634 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
631 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
632 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
633 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
635 | 634 | $path = $parsed_url['path']; |
636 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
635 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
637 | 636 | } |
638 | 637 | |
639 | 638 | /** |
@@ -655,20 +654,20 @@ discard block |
||
655 | 654 | $is_guest = "false"; |
656 | 655 | $sign_up = substr($current_user->user_registered, 0, 10); |
657 | 656 | $customer_orders = get_posts(array( |
658 | - 'numberposts' => - 1, |
|
657 | + 'numberposts' => -1, |
|
659 | 658 | 'meta_key' => '_customer_user', |
660 | 659 | 'meta_value' => $current_user->ID, |
661 | - 'post_type' => array( 'shop_order' ), |
|
662 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
660 | + 'post_type' => array('shop_order'), |
|
661 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
663 | 662 | )); |
664 | 663 | } else { |
665 | 664 | $is_guest = "true"; |
666 | 665 | $customer_orders = get_posts(array( |
667 | - 'numberposts' => - 1, |
|
666 | + 'numberposts' => -1, |
|
668 | 667 | 'meta_key' => '_billing_email', |
669 | 668 | 'meta_value' => $billingEmail, |
670 | - 'post_type' => array( 'shop_order' ), |
|
671 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
669 | + 'post_type' => array('shop_order'), |
|
670 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
672 | 671 | )); |
673 | 672 | foreach ($customer_orders as $customer_order) { |
674 | 673 | if (trim($sign_up)=='' || |
@@ -697,7 +696,7 @@ discard block |
||
697 | 696 | //Check if id exists |
698 | 697 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
699 | 698 | $countResults = count($resultsSelect); |
700 | - if ($countResults == 0) { |
|
699 | + if ($countResults==0) { |
|
701 | 700 | $wpdb->insert( |
702 | 701 | $tableName, |
703 | 702 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -722,7 +721,7 @@ discard block |
||
722 | 721 | global $wpdb; |
723 | 722 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
724 | 723 | |
725 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
724 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
726 | 725 | $charset_collate = $wpdb->get_charset_collate(); |
727 | 726 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
728 | 727 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -755,9 +754,9 @@ discard block |
||
755 | 754 | */ |
756 | 755 | private function getNationalId($order) |
757 | 756 | { |
758 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
757 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
759 | 758 | $data = $mdObject->get_data(); |
760 | - if ($data['key'] == 'vat_number') { |
|
759 | + if ($data['key']=='vat_number') { |
|
761 | 760 | return $data['value']; |
762 | 761 | } |
763 | 762 | } |
@@ -772,9 +771,9 @@ discard block |
||
772 | 771 | */ |
773 | 772 | private function getTaxId($order) |
774 | 773 | { |
775 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
774 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
776 | 775 | $data = $mdObject->get_data(); |
777 | - if ($data['key'] == 'billing_cfpiva') { |
|
776 | + if ($data['key']=='billing_cfpiva') { |
|
778 | 777 | return $data['value']; |
779 | 778 | } |
780 | 779 | } |
@@ -804,7 +803,7 @@ discard block |
||
804 | 803 | { |
805 | 804 | global $wpdb; |
806 | 805 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
807 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
806 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
808 | 807 | $charset_collate = $wpdb->get_charset_collate(); |
809 | 808 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
810 | 809 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |