@@ -282,9 +282,9 @@ |
||
282 | 282 | if ($promotedProduct == 'true') { |
283 | 283 | $promotedAmount+=$product->getAmount(); |
284 | 284 | $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
285 | - ' Price: ' . $item->get_total() . |
|
286 | - ' Qty: ' . $product->getQuantity() . |
|
287 | - ' Item ID: ' . $item['id_product']; |
|
285 | + ' Price: ' . $item->get_total() . |
|
286 | + ' Qty: ' . $product->getQuantity() . |
|
287 | + ' Item ID: ' . $item['id_product']; |
|
288 | 288 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
289 | 289 | } |
290 | 290 | } |
@@ -54,38 +54,38 @@ discard block |
||
54 | 54 | $this->method_title = ucfirst($this->id); |
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 | $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis'); |
75 | 75 | $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis."; |
76 | 76 | |
77 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
78 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
77 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
78 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
79 | 79 | foreach ($this->settings as $setting_key => $setting_value) { |
80 | 80 | $this->$setting_key = $setting_value; |
81 | 81 | } |
82 | 82 | |
83 | 83 | //Hooks |
84 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options |
|
85 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
86 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
87 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
88 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3); |
|
84 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options |
|
85 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields |
|
86 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form |
|
87 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification |
|
88 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3); |
|
89 | 89 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2); |
90 | 90 | } |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function loadPagantisTranslation($mofile, $domain) |
99 | 99 | { |
100 | - if ('pagantis' === $domain) { |
|
101 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
100 | + if ('pagantis'===$domain) { |
|
101 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
102 | 102 | } |
103 | 103 | return $mofile; |
104 | 104 | } |
@@ -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 | 138 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") { |
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']) |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | $details->addProduct($product); |
280 | 280 | |
281 | 281 | $promotedProduct = $this->isPromoted($item->get_product_id()); |
282 | - if ($promotedProduct == 'true') { |
|
283 | - $promotedAmount+=$product->getAmount(); |
|
284 | - $promotedMessage = 'Promoted Item: ' . $product->getDescription() . |
|
285 | - ' Price: ' . $item->get_total() . |
|
286 | - ' Qty: ' . $product->getQuantity() . |
|
287 | - ' Item ID: ' . $item['id_product']; |
|
282 | + if ($promotedProduct=='true') { |
|
283 | + $promotedAmount += $product->getAmount(); |
|
284 | + $promotedMessage = 'Promoted Item: '.$product->getDescription(). |
|
285 | + ' Price: '.$item->get_total(). |
|
286 | + ' Qty: '.$product->getQuantity(). |
|
287 | + ' Item ID: '.$item['id_product']; |
|
288 | 288 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
289 | 289 | } |
290 | 290 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
357 | 357 | } |
358 | 358 | } catch (\Exception $exception) { |
359 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
359 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
360 | 360 | $this->insertLog($exception); |
361 | 361 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
362 | 362 | wp_redirect($checkout_url); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | public function pagantisNotification() |
371 | 371 | { |
372 | 372 | try { |
373 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
373 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
374 | 374 | |
375 | 375 | include_once('notifyController.php'); |
376 | 376 | $notify = new WcPagantisNotify(); |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | */ |
410 | 410 | public function pagantisCompleteStatus($status, $order_id, $order) |
411 | 411 | { |
412 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
413 | - if ($order->get_status() == 'failed') { |
|
412 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
413 | + if ($order->get_status()=='failed') { |
|
414 | 414 | $status = 'processing'; |
415 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
415 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
416 | 416 | $status = 'processing'; |
417 | 417 | } |
418 | 418 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
437 | 437 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
438 | 438 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
439 | - (int)$this->get_order_total()>$this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
439 | + (int) $this->get_order_total() > $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) { |
|
440 | 440 | return true; |
441 | 441 | } |
442 | 442 | |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
466 | 466 | if (strpos($redirectUrl, 'order-pay=')===false) { |
467 | - $redirectUrl.="&order-pay=".$order_id; |
|
467 | + $redirectUrl .= "&order-pay=".$order_id; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | return array( |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | ); |
474 | 474 | |
475 | 475 | } catch (Exception $e) { |
476 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
476 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
477 | 477 | return array(); |
478 | 478 | } |
479 | 479 | } |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | private function generateUrl($url) |
538 | 538 | { |
539 | 539 | $parsed_url = parse_url($url); |
540 | - if ($parsed_url !== false) { |
|
540 | + if ($parsed_url!==false) { |
|
541 | 541 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
542 | 542 | parse_str($parsed_url['query'], $arrayParams); |
543 | 543 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -585,11 +585,10 @@ discard block |
||
585 | 585 | private function getKeysUrl($order, $url) |
586 | 586 | { |
587 | 587 | $defaultFields = (get_class($order)=='WC_Order') ? |
588 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
589 | - array(); |
|
588 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
590 | 589 | |
591 | 590 | $parsedUrl = parse_url($url); |
592 | - if ($parsedUrl !== false) { |
|
591 | + if ($parsedUrl!==false) { |
|
593 | 592 | //Replace parameters from url |
594 | 593 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
595 | 594 | |
@@ -634,7 +633,7 @@ discard block |
||
634 | 633 | foreach ($arrayParams as $keyParam => $valueParam) { |
635 | 634 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
636 | 635 | if (count($match)) { |
637 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
636 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
638 | 637 | $arrayParams[$keyParam] = $defaultFields[$key]; |
639 | 638 | } |
640 | 639 | } |
@@ -649,13 +648,13 @@ discard block |
||
649 | 648 | */ |
650 | 649 | private function unparseUrl($parsed_url) |
651 | 650 | { |
652 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
651 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
653 | 652 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
654 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
655 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
656 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
653 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
654 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
655 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
657 | 656 | $path = $parsed_url['path']; |
658 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
657 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
659 | 658 | } |
660 | 659 | |
661 | 660 | /** |
@@ -677,20 +676,20 @@ discard block |
||
677 | 676 | $is_guest = "false"; |
678 | 677 | $sign_up = substr($current_user->user_registered, 0, 10); |
679 | 678 | $customer_orders = get_posts(array( |
680 | - 'numberposts' => - 1, |
|
679 | + 'numberposts' => -1, |
|
681 | 680 | 'meta_key' => '_customer_user', |
682 | 681 | 'meta_value' => $current_user->ID, |
683 | - 'post_type' => array( 'shop_order' ), |
|
684 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
682 | + 'post_type' => array('shop_order'), |
|
683 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
685 | 684 | )); |
686 | 685 | } else { |
687 | 686 | $is_guest = "true"; |
688 | 687 | $customer_orders = get_posts(array( |
689 | - 'numberposts' => - 1, |
|
688 | + 'numberposts' => -1, |
|
690 | 689 | 'meta_key' => '_billing_email', |
691 | 690 | 'meta_value' => $billingEmail, |
692 | - 'post_type' => array( 'shop_order' ), |
|
693 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
691 | + 'post_type' => array('shop_order'), |
|
692 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'), |
|
694 | 693 | )); |
695 | 694 | foreach ($customer_orders as $customer_order) { |
696 | 695 | if (trim($sign_up)=='' || |
@@ -719,7 +718,7 @@ discard block |
||
719 | 718 | //Check if id exists |
720 | 719 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'"); |
721 | 720 | $countResults = count($resultsSelect); |
722 | - if ($countResults == 0) { |
|
721 | + if ($countResults==0) { |
|
723 | 722 | $wpdb->insert( |
724 | 723 | $tableName, |
725 | 724 | array('id' => $orderId, 'order_id' => $pagantisOrderId), |
@@ -744,7 +743,7 @@ discard block |
||
744 | 743 | global $wpdb; |
745 | 744 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
746 | 745 | |
747 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
746 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
748 | 747 | $charset_collate = $wpdb->get_charset_collate(); |
749 | 748 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
750 | 749 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -777,9 +776,9 @@ discard block |
||
777 | 776 | */ |
778 | 777 | private function getNationalId($order) |
779 | 778 | { |
780 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
779 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
781 | 780 | $data = $mdObject->get_data(); |
782 | - if ($data['key'] == 'vat_number') { |
|
781 | + if ($data['key']=='vat_number') { |
|
783 | 782 | return $data['value']; |
784 | 783 | } |
785 | 784 | } |
@@ -794,9 +793,9 @@ discard block |
||
794 | 793 | */ |
795 | 794 | private function getTaxId($order) |
796 | 795 | { |
797 | - foreach ((array)$order->get_meta_data() as $mdObject) { |
|
796 | + foreach ((array) $order->get_meta_data() as $mdObject) { |
|
798 | 797 | $data = $mdObject->get_data(); |
799 | - if ($data['key'] == 'billing_cfpiva') { |
|
798 | + if ($data['key']=='billing_cfpiva') { |
|
800 | 799 | return $data['value']; |
801 | 800 | } |
802 | 801 | } |
@@ -826,7 +825,7 @@ discard block |
||
826 | 825 | { |
827 | 826 | global $wpdb; |
828 | 827 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
829 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) { |
|
828 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) { |
|
830 | 829 | $charset_collate = $wpdb->get_charset_collate(); |
831 | 830 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
832 | 831 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -845,7 +844,7 @@ discard block |
||
845 | 844 | { |
846 | 845 | $metaProduct = get_post_meta($product_id); |
847 | 846 | return (array_key_exists('custom_product_pagantis_promoted', $metaProduct) && |
848 | - $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false'; |
|
847 | + $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false'; |
|
849 | 848 | } |
850 | 849 | |
851 | 850 | /** |
@@ -858,8 +857,8 @@ discard block |
||
858 | 857 | $promotedAmount = 0; |
859 | 858 | foreach ($items as $key => $item) { |
860 | 859 | $promotedProduct = $this->isPromoted($item['product_id']); |
861 | - if ($promotedProduct == 'true') { |
|
862 | - $promotedAmount+=$item['line_total']; |
|
860 | + if ($promotedProduct=='true') { |
|
861 | + $promotedAmount += $item['line_total']; |
|
863 | 862 | } |
864 | 863 | } |
865 | 864 |