Completed
Push — master ( f6d0fe...75b072 )
by
unknown
16s queued 10s
created
includes/pg-functions.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 function requireWPPluginFunctions()
4 4
 {
5
-    if (! function_exists('is_plugin_active')) {
6
-        require_once(ABSPATH . 'wp-admin/includes/plugin.php');
5
+    if (!function_exists('is_plugin_active')) {
6
+        require_once(ABSPATH.'wp-admin/includes/plugin.php');
7 7
     }
8 8
 }
9 9
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 function getConfigValue($configKey)
22 22
 {
23 23
     global $wpdb;
24
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
24
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
25 25
     $value     = $wpdb->get_var($wpdb->prepare("SELECT value FROM $tableName WHERE config= %s ", $configKey));
26 26
 
27 27
     return $value;
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 function isPgTableCreated($tableToCheck)
39 39
 {
40 40
     global $wpdb;
41
-    $tableName = $wpdb->prefix . $tableToCheck;
42
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") == $tableName) {
41
+    $tableName = $wpdb->prefix.$tableToCheck;
42
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")==$tableName) {
43 43
         return true;
44 44
     }
45 45
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 function createPgCartTable()
53 53
 {
54 54
     global $wpdb;
55
-    $tableName       = $wpdb->prefix . PG_CART_PROCESS_TABLE;
55
+    $tableName       = $wpdb->prefix.PG_CART_PROCESS_TABLE;
56 56
     $charset_collate = $wpdb->get_charset_collate();
57 57
     $sql             = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50),  
58 58
                   UNIQUE KEY id (id)) $charset_collate";
59 59
 
60
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
60
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
61 61
     dbDelta($sql);
62 62
 }
63 63
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 {
66 66
     global $wpdb;
67 67
     $charset_collate = $wpdb->get_charset_collate();
68
-    $LogsTableName   = $wpdb->prefix . PG_LOGS_TABLE_NAME;
68
+    $LogsTableName   = $wpdb->prefix.PG_LOGS_TABLE_NAME;
69 69
     $sqlQuery        = "CREATE TABLE $LogsTableName ( 
70 70
     id int NOT NULL AUTO_INCREMENT,
71 71
     log text NOT NULL, 
72 72
     createdAt timestamp DEFAULT CURRENT_TIMESTAMP,
73 73
     UNIQUE KEY id (id)) 
74 74
     $charset_collate";
75
-    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
75
+    require_once(ABSPATH.'wp-admin/includes/upgrade.php');
76 76
     dbDelta($sqlQuery);
77 77
 }
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 function insertLogEntry($exception = null, $message = null)
84 84
 {
85 85
     global $wpdb;
86
-    if (! isPgTableCreated(PG_LOGS_TABLE_NAME)) {
86
+    if (!isPgTableCreated(PG_LOGS_TABLE_NAME)) {
87 87
         createLogsTable();
88 88
     }
89 89
     $logEntry = new Pagantis\ModuleUtils\Model\Log\LogEntry();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     } else {
93 93
         $logEntry = $logEntry->info($message);
94 94
     }
95
-    $tableName = $wpdb->prefix . PG_LOGS_TABLE_NAME;
95
+    $tableName = $wpdb->prefix.PG_LOGS_TABLE_NAME;
96 96
     $wpdb->insert($tableName, array('log' => $logEntry->toJson()));
97 97
 }
98 98
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 {
104 104
     $pgDecimalSeparator = getPgSimulatorDecimalSeparatorConfig();
105 105
     $wc_decimal_sep     = get_option('woocommerce_price_decimal_sep');
106
-    if (stripslashes($wc_decimal_sep) == stripslashes($pgDecimalSeparator)) {
106
+    if (stripslashes($wc_decimal_sep)==stripslashes($pgDecimalSeparator)) {
107 107
         return true;
108 108
     } else {
109 109
         return false;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 {
119 119
     $pgThousandSeparator = getPgSimulatorThousandsSeparator();
120 120
     $wc_price_thousand   = get_option('woocommerce_price_thousand_sep');
121
-    if (stripslashes($wc_price_thousand) == stripslashes($pgThousandSeparator)) {
121
+    if (stripslashes($wc_price_thousand)==stripslashes($pgThousandSeparator)) {
122 122
         return true;
123 123
     } else {
124 124
         return false;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 function getPgSimulatorThousandsSeparator()
132 132
 {
133 133
     global $wpdb;
134
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
134
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
135 135
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_THOUSANDS_SEPARATOR'";
136 136
     $result    = $wpdb->get_row($query, ARRAY_A);
137 137
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 function getPgSimulatorDecimalSeparatorConfig()
145 145
 {
146 146
     global $wpdb;
147
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
147
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
148 148
     $query     = "SELECT value FROM $tableName WHERE config='PAGANTIS_SIMULATOR_DECIMAL_SEPARATOR'";
149 149
     $result    = $wpdb->get_row($query, ARRAY_A);
150 150
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     if (areThousandsSeparatorEqual()) {
158 158
         return;
159 159
     }
160
-    $tableName         = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
160
+    $tableName         = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
161 161
     $thousandSeparator = get_option('woocommerce_price_thousand_sep');
162 162
     $wpdb->update(
163 163
         $tableName,
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     if (areDecimalSeparatorEqual()) {
175 175
         return;
176 176
     }
177
-    $tableName        = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
177
+    $tableName        = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
178 178
     $decimalSeparator = get_option('woocommerce_price_decimal_sep');
179 179
     $wpdb->update(
180 180
         $tableName,
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function isSimulatorTypeValid($simulatorType, $validSimulatorTypes)
196 196
 {
197
-    if (! in_array($simulatorType, $validSimulatorTypes)) {
197
+    if (!in_array($simulatorType, $validSimulatorTypes)) {
198 198
         return false;
199 199
     }
200 200
 
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 function areMerchantKeysSet()
222 222
 {
223 223
     $settings   = get_option('woocommerce_pagantis_settings');
224
-    $publicKey  = ! empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
-    $privateKey = ! empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
224
+    $publicKey  = !empty($settings['pagantis_public_key']) ? $settings['pagantis_public_key'] : '';
225
+    $privateKey = !empty($settings['pagantis_private_key']) ? $settings['pagantis_private_key'] : '';
226 226
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
227 227
         return false;
228 228
     }
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 function areMerchantKeysSet4x()
234 234
 {
235 235
     $settings   = get_option('woocommerce_pagantis_settings');
236
-    $publicKey  = ! empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
-    $privateKey = ! empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
236
+    $publicKey  = !empty($settings['pagantis_public_key_4x']) ? $settings['pagantis_public_key_4x'] : '';
237
+    $privateKey = !empty($settings['pagantis_private_key_4x']) ? $settings['pagantis_private_key_4x'] : '';
238 238
     if ((empty($publicKey) && empty($privateKey)) || (empty($publicKey) || empty($privateKey))) {
239 239
         return false;
240 240
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 function isSimulatorEnabled()
246 246
 {
247 247
     $settings = get_option('woocommerce_pagantis_settings');
248
-    if ((! empty($settings['simulator']) && 'yes' === $settings['simulator']) ? true : false) {
248
+    if ((!empty($settings['simulator']) && 'yes'===$settings['simulator']) ? true : false) {
249 249
         return true;
250 250
     }
251 251
 
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 {
257 257
     $settings = get_option('woocommerce_pagantis_settings');
258 258
 
259
-    return (! empty($settings['enabled']) && 'yes' === $settings['enabled']);
259
+    return (!empty($settings['enabled']) && 'yes'===$settings['enabled']);
260 260
 }
261 261
 
262 262
 function isPluginEnabled4x()
263 263
 {
264 264
     $settings = get_option('woocommerce_pagantis_settings');
265
-    return (! empty($settings['enabled_4x']) && 'yes' === $settings['enabled_4x']);
265
+    return (!empty($settings['enabled_4x']) && 'yes'===$settings['enabled_4x']);
266 266
 }
267 267
 
268 268
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 {
271 271
     $locale           = strtolower(strstr(get_locale(), '_', true));
272 272
     $allowedCountries = maybe_unserialize(getConfigValue('PAGANTIS_ALLOWED_COUNTRIES'));
273
-    if (! in_array(strtolower($locale), $allowedCountries)) {
273
+    if (!in_array(strtolower($locale), $allowedCountries)) {
274 274
         return false;
275 275
     }
276 276
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     global $product;
288 288
     if (method_exists($product, 'get_price')) {
289 289
         $productPrice = $product->get_price();
290
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
290
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
291 291
         if ($validAmount) {
292 292
             return true;
293 293
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     global $product;
307 307
     if (method_exists($product, 'get_price')) {
308 308
         $productPrice = $product->get_price();
309
-        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount == '0'));
309
+        $validAmount  = ($productPrice >= $minAmount && ($productPrice <= $maxAmount || $maxAmount=='0'));
310 310
         if ($validAmount) {
311 311
             return true;
312 312
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 function getExtraConfig()
326 326
 {
327 327
     global $wpdb;
328
-    $tableName = $wpdb->prefix . PG_CONFIG_TABLE_NAME;
328
+    $tableName = $wpdb->prefix.PG_CONFIG_TABLE_NAME;
329 329
     $response  = array();
330 330
     $dbResult  = $wpdb->get_results("select config, value from $tableName", ARRAY_A);
331 331
     foreach ($dbResult as $value) {
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 function getModuleVersion()
339 339
 {
340 340
 
341
-    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE). '/WC_Pagantis.php';
341
+    $mainFile = plugin_dir_path(PG_WC_MAIN_FILE).'/WC_Pagantis.php';
342 342
     $version = get_file_data($mainFile, array('Version' => 'Version'), false);
343 343
     return $version['Version'];
344 344
 }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
     );
472 472
 
473 473
         foreach ($metaKeys as $key) {
474
-            $date = empty($customer->get_meta($key)) ? $customer->get_meta($key) : get_user_meta( $customerID, '_automatewoo_birthday_full', true );
474
+            $date = empty($customer->get_meta($key)) ? $customer->get_meta($key) : get_user_meta($customerID, '_automatewoo_birthday_full', true);
475 475
         }
476 476
 
477 477
     }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     $metaProduct = get_post_meta($product_id);
490 490
 
491 491
     return (array_key_exists('custom_product_pagantis_promoted', $metaProduct)
492
-            && $metaProduct['custom_product_pagantis_promoted']['0'] === 'yes') ? 'true' : 'false';
492
+            && $metaProduct['custom_product_pagantis_promoted']['0']==='yes') ? 'true' : 'false';
493 493
 }
494 494
 
495 495
 /**
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     $promotedAmount = 0;
501 501
     foreach (WC()->cart->get_cart() as $key => $item) {
502 502
         $promotedProduct = isProductPromoted($item['product_id']);
503
-        if ($promotedProduct == 'true') {
503
+        if ($promotedProduct=='true') {
504 504
             $promotedAmount += $item['line_total'] + $item['line_tax'];
505 505
         }
506 506
     }
@@ -514,24 +514,24 @@  discard block
 block discarded – undo
514 514
  * @param $urlToken
515 515
  * @param $methodID
516 516
  */
517
-function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken ,$methodID)
517
+function addOrderToProcessingQueue($pagantisOrderId, $wcOrderID, $urlToken, $methodID)
518 518
 {
519 519
     global $wpdb;
520 520
     checkCartProcessTable();
521
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
521
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
522 522
 
523 523
     //Check if id exists
524 524
     $resultsSelect = $wpdb->get_results("SELECT * FROM $tableName WHERE id='$pagantisOrderId'");
525 525
     $countResults  = count($resultsSelect);
526 526
 
527
-    if ($countResults == 0) {
527
+    if ($countResults==0) {
528 528
         $wpdb->insert($tableName, array(
529 529
             'order_id' => $pagantisOrderId,
530 530
             'wc_order_id' => $wcOrderID,
531 531
             'token'       => $urlToken
532 532
         ), array('%s', '%s', '%s'));
533 533
 
534
-        $logEntry = "Cart Added to Processing Queue" .
534
+        $logEntry = "Cart Added to Processing Queue".
535 535
             " cart hash: ".WC()->cart->get_cart_hash().
536 536
             " Merchant order id: ".$wcOrderID.
537 537
             " Pagantis order id: ".$pagantisOrderId.
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
         insertLogEntry(null, $logEntry);
541 541
     } else {
542 542
         $wpdb->update($tableName,
543
-            array('order_id' => $pagantisOrderId,'token' => $urlToken),
543
+            array('order_id' => $pagantisOrderId, 'token' => $urlToken),
544 544
             array('wc_order_id' => $wcOrderID),
545 545
             array('%s,%s'),
546 546
             array('%s'));
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 function alterCartProcessTable()
552 552
 {
553 553
     global $wpdb;
554
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
555
-    if (! $wpdb->get_var( "SHOW COLUMNS FROM `{$tableName}` LIKE 'token';" ) ) {
554
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
555
+    if (!$wpdb->get_var("SHOW COLUMNS FROM `{$tableName}` LIKE 'token';")) {
556 556
         $wpdb->query("ALTER TABLE $tableName ADD COLUMN `token` VARCHAR(32) NOT NULL AFTER `order_id`");
557 557
         $wpdb->query("ALTER TABLE $tableName DROP PRIMARY KEY, ADD PRIMARY KEY(order_id)");
558 558
         // OLDER VERSIONS OF MODULE USE UNIQUE KEY ON `id` MEANING THIS VALUE WAS NULLABLE
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 function checkCartProcessTable()
567 567
 {
568 568
     global $wpdb;
569
-    $tableName = $wpdb->prefix . PG_CART_PROCESS_TABLE;
569
+    $tableName = $wpdb->prefix.PG_CART_PROCESS_TABLE;
570 570
 
571
-    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
571
+    if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
572 572
 
573 573
         $charset_collate = $wpdb->get_charset_collate();
574 574
         $sql = "CREATE TABLE IF NOT EXISTS $tableName(
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
              PRIMARY KEY (`id`, `order_id`)
580 580
             )$charset_collate";
581 581
 
582
-        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
582
+        require_once(ABSPATH.'wp-admin/includes/upgrade.php');
583 583
         dbDelta($sql);
584 584
     }
585 585
 }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
623 623
         ));
624 624
         foreach ($customer_orders as $customer_order) {
625
-            if (trim($sign_up) == '' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
625
+            if (trim($sign_up)=='' || strtotime(substr($customer_order->post_date, 0, 10)) <= strtotime($sign_up)) {
626 626
                 $sign_up = substr($customer_order->post_date, 0, 10);
627 627
             }
628 628
         }
Please login to merge, or discard this patch.
controllers/paymentController4x.php 1 patch
Spacing   +41 added lines, -44 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->urlToken4x = strtoupper(md5(uniqid(rand(), true)));
67 67
 
68 68
         //Useful vars
69
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
69
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
70 70
         $this->allowed_currencies = getAllowedCurrencies();
71 71
         $this->language = strstr(get_locale(), '_', true);
72 72
         if ($this->language=='') {
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
76 76
 
77 77
         //Panel form fields
78
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
78
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
79 79
         $this->init_settings();
80 80
 
81 81
         $this->extraConfig = getExtraConfig();
82 82
         $this->title = __($this->extraConfig['PAGANTIS_TITLE_4x'], 'pagantis');
83 83
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
84 84
 
85
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
86
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
85
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
86
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
87 87
         foreach ($this->settings as $setting_key => $setting_value) {
88 88
             $this->$setting_key = $setting_value;
89 89
         }
90 90
 
91 91
         //Hooks
92
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
93
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
94
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
95
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
92
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
93
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
94
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
95
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
96 96
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
97 97
     }
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function loadPagantisTranslation($mofile, $domain)
106 106
     {
107
-        if ('pagantis' === $domain) {
108
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
107
+        if ('pagantis'===$domain) {
108
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
109 109
         }
110 110
         return $mofile;
111 111
     }
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
 
155 155
             $shippingAddress = $order->get_address('shipping');
156 156
             $billingAddress = $order->get_address('billing');
157
-            if ($shippingAddress['address_1'] == '') {
157
+            if ($shippingAddress['address_1']=='') {
158 158
                 $shippingAddress = $billingAddress;
159 159
             }
160 160
 
161 161
             $customer_id = $order->get_customer_id();
162
-            $national_id = maybeGetIDNumber($order , $customer_id);
163
-            $tax_id = maybeGetTaxIDNumber($order , $customer_id);
164
-            $phoneNumber = maybeGetPhoneNumber($order , $customer_id);
162
+            $national_id = maybeGetIDNumber($order, $customer_id);
163
+            $tax_id = maybeGetTaxIDNumber($order, $customer_id);
164
+            $phoneNumber = maybeGetPhoneNumber($order, $customer_id);
165 165
 
166 166
 
167 167
             $userAddress = new Address();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                 ->setDni($national_id)
188 188
                 ->setTaxId($tax_id)
189 189
             ;
190
-            $orderBillingAddress =  new Address();
190
+            $orderBillingAddress = new Address();
191 191
             $orderBillingAddress
192 192
                 ->setZipCode($billingAddress['postcode'])
193 193
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
                 $details->addProduct($product);
265 265
 
266 266
                 $promotedProduct = isProductPromoted($item->get_product_id());
267
-                if ($promotedProduct == 'true') {
268
-                    $promotedAmount+=$product->getAmount();
269
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
270
-                                       ' - Price: ' . $item->get_total() .
271
-                                       ' - Qty: ' . $product->getQuantity() .
272
-                                       ' - Item ID: ' . $item['id_product'];
267
+                if ($promotedProduct=='true') {
268
+                    $promotedAmount += $product->getAmount();
269
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
270
+                                       ' - Price: '.$item->get_total().
271
+                                       ' - Qty: '.$product->getQuantity().
272
+                                       ' - Item ID: '.$item['id_product'];
273 273
                     $promotedMessage = substr($promotedMessage, 0, 999);
274 274
                     $metadataOrder->addMetadata('promotedProduct', $promotedMessage);
275 275
                 }
@@ -317,9 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
319 319
             $purchaseCountry =
320
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
321
-                    in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
322
-                        in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
320
+                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;
323 321
 
324 322
             $orderConfiguration = new Configuration();
325 323
             $orderConfiguration
@@ -344,7 +342,7 @@  discard block
 block discarded – undo
344 342
             $pagantisOrder = $orderClient->createOrder($orderApiClient);
345 343
             if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) {
346 344
                 $url = $pagantisOrder->getActionUrls()->getForm();
347
-                addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x,self::METHOD_ID);
345
+                addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x, self::METHOD_ID);
348 346
             } else {
349 347
                 throw new OrderNotFoundException();
350 348
             }
@@ -363,7 +361,7 @@  discard block
 block discarded – undo
363 361
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
364 362
             }
365 363
         } catch (\Exception $exception) {
366
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
364
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
367 365
             insertLogEntry($exception);
368 366
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
369 367
             wp_redirect($checkout_url);
@@ -379,7 +377,7 @@  discard block
 block discarded – undo
379 377
     public function pagantisNotification()
380 378
     {
381 379
         try {
382
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
380
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
383 381
 
384 382
             include_once('notifyController.php');
385 383
             $notify = new WcPagantisNotify();
@@ -418,10 +416,10 @@  discard block
 block discarded – undo
418 416
      */
419 417
     public function pagantisCompleteStatus($status, $order_id, $order)
420 418
     {
421
-        if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) {
422
-            if ($order->get_status() == 'failed') {
419
+        if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) {
420
+            if ($order->get_status()=='failed') {
423 421
                 $status = 'processing';
424
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
422
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
425 423
                 $status = 'processing';
426 424
             }
427 425
         }
@@ -450,8 +448,8 @@  discard block
 block discarded – undo
450 448
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
451 449
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x'];
452 450
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x'];
453
-        $totalPrice = (int)$this->get_order_total();
454
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
451
+        $totalPrice = (int) $this->get_order_total();
452
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
455 453
         if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' &&
456 454
             $validAmount && $allowedCountry) {
457 455
             return true;
@@ -486,7 +484,7 @@  discard block
 block discarded – undo
486 484
 
487 485
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
488 486
             if (strpos($redirectUrl, 'order-pay=')===false) {
489
-                $redirectUrl.="&order-pay=".$order_id;
487
+                $redirectUrl .= "&order-pay=".$order_id;
490 488
             }
491 489
 
492 490
             return array(
@@ -494,7 +492,7 @@  discard block
 block discarded – undo
494 492
                 'redirect' => $redirectUrl
495 493
             );
496 494
         } catch (Exception $e) {
497
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
495
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
498 496
             return array();
499 497
         }
500 498
     }
@@ -565,7 +563,7 @@  discard block
 block discarded – undo
565 563
     private function generateUrl($url)
566 564
     {
567 565
         $parsed_url = parse_url($url);
568
-        if ($parsed_url !== false) {
566
+        if ($parsed_url!==false) {
569 567
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
570 568
             parse_str($parsed_url['query'], $arrayParams);
571 569
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -613,11 +611,10 @@  discard block
 block discarded – undo
613 611
     private function getKeysUrl($order, $url)
614 612
     {
615 613
         $defaultFields = (get_class($order)=='WC_Order') ?
616
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
617
-            array();
614
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
618 615
 
619 616
         $parsedUrl = parse_url($url);
620
-        if ($parsedUrl !== false) {
617
+        if ($parsedUrl!==false) {
621 618
             //Replace parameters from url
622 619
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
623 620
 
@@ -662,7 +659,7 @@  discard block
 block discarded – undo
662 659
         foreach ($arrayParams as $keyParam => $valueParam) {
663 660
             preg_match('#\{{.*?}\}#', $valueParam, $match);
664 661
             if (count($match)) {
665
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
662
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
666 663
                 $arrayParams[$keyParam] = $defaultFields[$key];
667 664
             }
668 665
         }
@@ -677,12 +674,12 @@  discard block
 block discarded – undo
677 674
      */
678 675
     private function unparseUrl($parsed_url)
679 676
     {
680
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
677
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
681 678
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
682
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
683
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
684
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
679
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
680
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
681
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
685 682
         $path     = $parsed_url['path'];
686
-        return $scheme . $host . $port . $path . $query . $fragment;
683
+        return $scheme.$host.$port.$path.$query.$fragment;
687 684
     }
688 685
 }
Please login to merge, or discard this patch.
controllers/paymentController.php 1 patch
Spacing   +51 added lines, -54 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
         $this->urlToken = strtoupper(md5(uniqid(rand(), true)));
64 64
 
65 65
         //Useful vars
66
-        $this->template_path = plugin_dir_path(__FILE__) . '../templates/';
66
+        $this->template_path = plugin_dir_path(__FILE__).'../templates/';
67 67
         $this->allowed_currencies = getAllowedCurrencies();
68
-        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php';
68
+        $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php';
69 69
         $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
70 70
         $this->language = strstr(get_locale(), '_', true);
71 71
         if ($this->language=='') {
@@ -74,25 +74,25 @@  discard block
 block discarded – undo
74 74
         $this->icon = 'https://cdn.digitalorigin.com/assets/master/logos/pg-130x30.svg';
75 75
 
76 76
         //Panel form fields
77
-        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options
77
+        $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options
78 78
         $this->init_settings();
79 79
 
80 80
         $this->extraConfig = getExtraConfig();
81 81
         $this->title = __($this->extraConfig['PAGANTIS_TITLE'], 'pagantis');
82 82
         $this->method_description = "Financial Payment Gateway. Enable the possibility for your customers to pay their order in confortable installments with Pagantis.";
83 83
 
84
-        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl();
85
-        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl();
84
+        $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl();
85
+        $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl();
86 86
         foreach ($this->settings as $setting_key => $setting_value) {
87 87
             $this->$setting_key = $setting_value;
88 88
         }
89 89
 
90 90
         //Hooks
91
-        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
92
-        add_action('admin_notices', array($this, 'pagantisCheckFields'));                          //Check config fields
93
-        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage'));          //Pagantis form
94
-        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification'));      //Json Notification
95
-        add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
91
+        add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
92
+        add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
93
+        add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
94
+        add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
95
+        add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
96 96
         add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
97 97
     }
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function loadPagantisTranslation($mofile, $domain)
106 106
     {
107
-        if ('pagantis' === $domain) {
108
-            $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo';
107
+        if ('pagantis'===$domain) {
108
+            $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo';
109 109
         }
110 110
         return $mofile;
111 111
     }
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
     public function pagantisCheckFields()
140 140
     {
141 141
         $error_string = '';
142
-        if ($this->settings['enabled'] !== 'yes') {
142
+        if ($this->settings['enabled']!=='yes') {
143 143
             return;
144 144
         } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
145
-            $error_string =  __(' is not compatible with your php and/or curl version', 'pagantis');
145
+            $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
146 146
             $this->settings['enabled'] = 'no';
147
-        } 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']))) {
147
+        } 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']))) {
148 148
             $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
149 149
             $this->settings['enabled'] = 'no';
150 150
         } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
151
-            $error_string =  __(' only can be used in Euros', 'pagantis');
151
+            $error_string = __(' only can be used in Euros', 'pagantis');
152 152
             $this->settings['enabled'] = 'no';
153
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2'
154
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
153
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2'
154
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
155 155
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
156
-        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2'
157
-                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
156
+        } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2'
157
+                  || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
158 158
             $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
159
-        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
159
+        } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
160 160
             $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
161 161
         }
162 162
 
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 
190 190
             $shippingAddress = $order->get_address('shipping');
191 191
             $billingAddress = $order->get_address('billing');
192
-            if ($shippingAddress['address_1'] == '') {
192
+            if ($shippingAddress['address_1']=='') {
193 193
                 $shippingAddress = $billingAddress;
194 194
             }
195 195
 
196 196
             $customer_id = $order->get_customer_id();
197
-            $national_id = maybeGetIDNumber($order , $customer_id);
198
-            $tax_id = maybeGetTaxIDNumber($order , $customer_id);
199
-            $phoneNumber = maybeGetPhoneNumber($order , $customer_id);
197
+            $national_id = maybeGetIDNumber($order, $customer_id);
198
+            $tax_id = maybeGetTaxIDNumber($order, $customer_id);
199
+            $phoneNumber = maybeGetPhoneNumber($order, $customer_id);
200 200
 
201 201
             $userAddress = new Address();
202 202
             $userAddress
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
                 ->setDni($national_id)
221 221
                 ->setTaxId($tax_id)
222 222
             ;
223
-            $orderBillingAddress =  new Address();
223
+            $orderBillingAddress = new Address();
224 224
             $orderBillingAddress
225 225
                 ->setZipCode($billingAddress['postcode'])
226 226
                 ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name'])
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
                 $details->addProduct($product);
297 297
 
298 298
                 $promotedProduct = isProductPromoted($item->get_product_id());
299
-                if ($promotedProduct == 'true') {
300
-                    $promotedAmount+=$product->getAmount();
301
-                    $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() .
302
-                                       ' - Price: ' . $item->get_total() .
303
-                                       ' - Qty: ' . $product->getQuantity() .
304
-                                       ' - Item ID: ' . $item['id_product'];
299
+                if ($promotedProduct=='true') {
300
+                    $promotedAmount += $product->getAmount();
301
+                    $promotedMessage = 'Promoted Item: '.$wcProduct->get_name().
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
                 }
@@ -348,9 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
             $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']);
350 350
             $purchaseCountry =
351
-                in_array(strtolower($this->language), $allowedCountries) ? $this->language :
352
-                in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] :
353
-                in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null;
351
+                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;
354 352
 
355 353
             $orderConfiguration = new Configuration();
356 354
             $orderConfiguration
@@ -392,7 +390,7 @@  discard block
 block discarded – undo
392 390
                 wc_get_template('iframe.php', $template_fields, '', $this->template_path);
393 391
             }
394 392
         } catch (\Exception $exception) {
395
-            wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
393
+            wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
396 394
             insertLogEntry($exception);
397 395
             $checkout_url = get_permalink(wc_get_page_id('checkout'));
398 396
             wp_redirect($checkout_url);
@@ -407,7 +405,7 @@  discard block
 block discarded – undo
407 405
     public function pagantisNotification()
408 406
     {
409 407
         try {
410
-            $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order';
408
+            $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order';
411 409
 
412 410
             include_once('notifyController.php');
413 411
             $notify = new WcPagantisNotify();
@@ -446,10 +444,10 @@  discard block
 block discarded – undo
446 444
      */
447 445
     public function pagantisCompleteStatus($status, $order_id, $order)
448 446
     {
449
-        if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
450
-            if ($order->get_status() == 'failed') {
447
+        if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
448
+            if ($order->get_status()=='failed') {
451 449
                 $status = 'processing';
452
-            } elseif ($order->get_status() == 'pending' && $status=='completed') {
450
+            } elseif ($order->get_status()=='pending' && $status=='completed') {
453 451
                 $status = 'processing';
454 452
             }
455 453
         }
@@ -475,8 +473,8 @@  discard block
 block discarded – undo
475 473
         $allowedCountry = (in_array(strtolower($locale), $allowedCountries));
476 474
         $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'];
477 475
         $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT'];
478
-        $totalPrice = (int)$this->get_order_total();
479
-        $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0'));
476
+        $totalPrice = (int) $this->get_order_total();
477
+        $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0'));
480 478
         if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' &&
481 479
             $validAmount && $allowedCountry) {
482 480
             return true;
@@ -509,7 +507,7 @@  discard block
 block discarded – undo
509 507
 
510 508
             $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function
511 509
             if (strpos($redirectUrl, 'order-pay=')===false) {
512
-                $redirectUrl.="&order-pay=".$order_id;
510
+                $redirectUrl .= "&order-pay=".$order_id;
513 511
             }
514 512
 
515 513
             return array(
@@ -517,7 +515,7 @@  discard block
 block discarded – undo
517 515
                 'redirect' => $redirectUrl
518 516
             );
519 517
         } catch (Exception $e) {
520
-            wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
518
+            wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
521 519
             return array();
522 520
         }
523 521
     }
@@ -586,7 +584,7 @@  discard block
 block discarded – undo
586 584
     private function generateUrl($url)
587 585
     {
588 586
         $parsed_url = parse_url($url);
589
-        if ($parsed_url !== false) {
587
+        if ($parsed_url!==false) {
590 588
             $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query'];
591 589
             parse_str($parsed_url['query'], $arrayParams);
592 590
             foreach ($arrayParams as $keyParam => $valueParam) {
@@ -634,11 +632,10 @@  discard block
 block discarded – undo
634 632
     private function getKeysUrl($order, $url)
635 633
     {
636 634
         $defaultFields = (get_class($order)=='WC_Order') ?
637
-            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
638
-            array();
635
+            array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
639 636
 
640 637
         $parsedUrl = parse_url($url);
641
-        if ($parsedUrl !== false) {
638
+        if ($parsedUrl!==false) {
642 639
             //Replace parameters from url
643 640
             $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields);
644 641
 
@@ -683,7 +680,7 @@  discard block
 block discarded – undo
683 680
         foreach ($arrayParams as $keyParam => $valueParam) {
684 681
             preg_match('#\{{.*?}\}#', $valueParam, $match);
685 682
             if (count($match)) {
686
-                $key = str_replace(array('{{','}}'), array('',''), $match[0]);
683
+                $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
687 684
                 $arrayParams[$keyParam] = $defaultFields[$key];
688 685
             }
689 686
         }
@@ -698,13 +695,13 @@  discard block
 block discarded – undo
698 695
      */
699 696
     private function unparseUrl($parsed_url)
700 697
     {
701
-        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
698
+        $scheme   = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : '';
702 699
         $host     = isset($parsed_url['host']) ? $parsed_url['host'] : '';
703
-        $port     = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
704
-        $query    = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
705
-        $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
700
+        $port     = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : '';
701
+        $query    = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : '';
702
+        $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : '';
706 703
         $path     = $parsed_url['path'];
707
-        return $scheme . $host . $port . $path . $query . $fragment;
704
+        return $scheme.$host.$port.$path.$query.$fragment;
708 705
     }
709 706
 
710 707
 }
Please login to merge, or discard this patch.