@@ -2,8 +2,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | ->setNationalId($national_id) |
| 219 | 219 | ->setTaxId($tax_id) |
| 220 | 220 | ; |
| 221 | - $orderBillingAddress = new Address(); |
|
| 221 | + $orderBillingAddress = new Address(); |
|
| 222 | 222 | $orderBillingAddress |
| 223 | 223 | ->setZipCode($billingAddress['postcode']) |
| 224 | 224 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | $details->addProduct($product); |
| 295 | 295 | |
| 296 | 296 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 297 | - if ($promotedProduct == 'true') { |
|
| 298 | - $promotedAmount+=$product->getAmount(); |
|
| 299 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 300 | - ' - Price: ' . $item->get_total() . |
|
| 301 | - ' - Qty: ' . $product->getQuantity() . |
|
| 302 | - ' - Item ID: ' . $item['id_product']; |
|
| 297 | + if ($promotedProduct=='true') { |
|
| 298 | + $promotedAmount += $product->getAmount(); |
|
| 299 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 300 | + ' - Price: '.$item->get_total(). |
|
| 301 | + ' - Qty: '.$product->getQuantity(). |
|
| 302 | + ' - Item ID: '.$item['id_product']; |
|
| 303 | 303 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 304 | 304 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 305 | 305 | } |
@@ -346,9 +346,7 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 348 | 348 | $purchaseCountry = |
| 349 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 350 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 351 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 349 | + 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; |
|
| 352 | 350 | |
| 353 | 351 | $orderConfiguration = new Configuration(); |
| 354 | 352 | $orderConfiguration |
@@ -390,7 +388,7 @@ discard block |
||
| 390 | 388 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 391 | 389 | } |
| 392 | 390 | } catch (\Exception $exception) { |
| 393 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 391 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 394 | 392 | insertLogEntry($exception); |
| 395 | 393 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 396 | 394 | wp_redirect($checkout_url); |
@@ -405,7 +403,7 @@ discard block |
||
| 405 | 403 | public function pagantisNotification() |
| 406 | 404 | { |
| 407 | 405 | try { |
| 408 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 406 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 409 | 407 | |
| 410 | 408 | include_once('notifyController.php'); |
| 411 | 409 | $notify = new WcPagantisNotify(); |
@@ -444,10 +442,10 @@ discard block |
||
| 444 | 442 | */ |
| 445 | 443 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 446 | 444 | { |
| 447 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) { |
|
| 448 | - if ($order->get_status() == 'failed') { |
|
| 445 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) { |
|
| 446 | + if ($order->get_status()=='failed') { |
|
| 449 | 447 | $status = 'processing'; |
| 450 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 448 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 451 | 449 | $status = 'processing'; |
| 452 | 450 | } |
| 453 | 451 | } |
@@ -473,8 +471,8 @@ discard block |
||
| 473 | 471 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 474 | 472 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']; |
| 475 | 473 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT']; |
| 476 | - $totalPrice = (int)$this->get_order_total(); |
|
| 477 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 474 | + $totalPrice = (int) $this->get_order_total(); |
|
| 475 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 478 | 476 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 479 | 477 | $validAmount && $allowedCountry) { |
| 480 | 478 | return true; |
@@ -507,7 +505,7 @@ discard block |
||
| 507 | 505 | |
| 508 | 506 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 509 | 507 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 510 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 508 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 511 | 509 | } |
| 512 | 510 | |
| 513 | 511 | return array( |
@@ -515,7 +513,7 @@ discard block |
||
| 515 | 513 | 'redirect' => $redirectUrl |
| 516 | 514 | ); |
| 517 | 515 | } catch (Exception $e) { |
| 518 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 516 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 519 | 517 | return array(); |
| 520 | 518 | } |
| 521 | 519 | } |
@@ -584,7 +582,7 @@ discard block |
||
| 584 | 582 | private function generateUrl($url) |
| 585 | 583 | { |
| 586 | 584 | $parsed_url = parse_url($url); |
| 587 | - if ($parsed_url !== false) { |
|
| 585 | + if ($parsed_url!==false) { |
|
| 588 | 586 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 589 | 587 | parse_str($parsed_url['query'], $arrayParams); |
| 590 | 588 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -632,11 +630,10 @@ discard block |
||
| 632 | 630 | private function getKeysUrl($order, $url) |
| 633 | 631 | { |
| 634 | 632 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 635 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 636 | - array(); |
|
| 633 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 637 | 634 | |
| 638 | 635 | $parsedUrl = parse_url($url); |
| 639 | - if ($parsedUrl !== false) { |
|
| 636 | + if ($parsedUrl!==false) { |
|
| 640 | 637 | //Replace parameters from url |
| 641 | 638 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 642 | 639 | |
@@ -681,7 +678,7 @@ discard block |
||
| 681 | 678 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 682 | 679 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 683 | 680 | if (count($match)) { |
| 684 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 681 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 685 | 682 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 686 | 683 | } |
| 687 | 684 | } |
@@ -696,13 +693,13 @@ discard block |
||
| 696 | 693 | */ |
| 697 | 694 | private function unparseUrl($parsed_url) |
| 698 | 695 | { |
| 699 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 696 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 700 | 697 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 701 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 702 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 703 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 698 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 699 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 700 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 704 | 701 | $path = $parsed_url['path']; |
| 705 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 702 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 706 | 703 | } |
| 707 | 704 | |
| 708 | 705 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | ->setNationalId($national_id) |
| 185 | 185 | ->setTaxId($tax_id) |
| 186 | 186 | ; |
| 187 | - $orderBillingAddress = new Address(); |
|
| 187 | + $orderBillingAddress = new Address(); |
|
| 188 | 188 | $orderBillingAddress |
| 189 | 189 | ->setZipCode($billingAddress['postcode']) |
| 190 | 190 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | $details->addProduct($product); |
| 262 | 262 | |
| 263 | 263 | $promotedProduct = isProductPromoted($item->get_product_id()); |
| 264 | - if ($promotedProduct == 'true') { |
|
| 265 | - $promotedAmount+=$product->getAmount(); |
|
| 266 | - $promotedMessage = 'Promoted Item: ' . $wcProduct->get_name() . |
|
| 267 | - ' - Price: ' . $item->get_total() . |
|
| 268 | - ' - Qty: ' . $product->getQuantity() . |
|
| 269 | - ' - Item ID: ' . $item['id_product']; |
|
| 264 | + if ($promotedProduct=='true') { |
|
| 265 | + $promotedAmount += $product->getAmount(); |
|
| 266 | + $promotedMessage = 'Promoted Item: '.$wcProduct->get_name(). |
|
| 267 | + ' - Price: '.$item->get_total(). |
|
| 268 | + ' - Qty: '.$product->getQuantity(). |
|
| 269 | + ' - Item ID: '.$item['id_product']; |
|
| 270 | 270 | $promotedMessage = substr($promotedMessage, 0, 999); |
| 271 | 271 | $metadataOrder->addMetadata('promotedProduct', $promotedMessage); |
| 272 | 272 | } |
@@ -314,9 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 316 | 316 | $purchaseCountry = |
| 317 | - in_array(strtolower($this->language), $allowedCountries) ? $this->language : |
|
| 318 | - in_array(strtolower($shippingAddress['country']), $allowedCountries) ? $shippingAddress['country'] : |
|
| 319 | - in_array(strtolower($billingAddress['country']), $allowedCountries) ? $billingAddress['country'] : null; |
|
| 317 | + 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; |
|
| 320 | 318 | |
| 321 | 319 | $orderConfiguration = new Configuration(); |
| 322 | 320 | $orderConfiguration |
@@ -341,7 +339,7 @@ discard block |
||
| 341 | 339 | $pagantisOrder = $orderClient->createOrder($orderApiClient); |
| 342 | 340 | if ($pagantisOrder instanceof \Pagantis\OrdersApiClient\Model\Order) { |
| 343 | 341 | $url = $pagantisOrder->getActionUrls()->getForm(); |
| 344 | - addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x,self::METHOD_ID); |
|
| 342 | + addOrderToProcessingQueue($pagantisOrder->getId(), $order->get_id(), $this->urlToken4x, self::METHOD_ID); |
|
| 345 | 343 | } else { |
| 346 | 344 | throw new OrderNotFoundException(); |
| 347 | 345 | } |
@@ -360,7 +358,7 @@ discard block |
||
| 360 | 358 | wc_get_template('iframe.php', $template_fields, '', $this->template_path); |
| 361 | 359 | } |
| 362 | 360 | } catch (\Exception $exception) { |
| 363 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error'); |
|
| 361 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error'); |
|
| 364 | 362 | insertLogEntry($exception); |
| 365 | 363 | $checkout_url = get_permalink(wc_get_page_id('checkout')); |
| 366 | 364 | wp_redirect($checkout_url); |
@@ -376,7 +374,7 @@ discard block |
||
| 376 | 374 | public function pagantisNotification() |
| 377 | 375 | { |
| 378 | 376 | try { |
| 379 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 377 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 380 | 378 | |
| 381 | 379 | include_once('notifyController.php'); |
| 382 | 380 | $notify = new WcPagantisNotify(); |
@@ -415,10 +413,10 @@ discard block |
||
| 415 | 413 | */ |
| 416 | 414 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 417 | 415 | { |
| 418 | - if ($order->get_payment_method() == WcPagantis4xGateway::METHOD_ID) { |
|
| 419 | - if ($order->get_status() == 'failed') { |
|
| 416 | + if ($order->get_payment_method()==WcPagantis4xGateway::METHOD_ID) { |
|
| 417 | + if ($order->get_status()=='failed') { |
|
| 420 | 418 | $status = 'processing'; |
| 421 | - } elseif ($order->get_status() == 'pending' && $status=='completed') { |
|
| 419 | + } elseif ($order->get_status()=='pending' && $status=='completed') { |
|
| 422 | 420 | $status = 'processing'; |
| 423 | 421 | } |
| 424 | 422 | } |
@@ -447,8 +445,8 @@ discard block |
||
| 447 | 445 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 448 | 446 | $minAmount = $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT_4x']; |
| 449 | 447 | $maxAmount = $this->extraConfig['PAGANTIS_DISPLAY_MAX_AMOUNT_4x']; |
| 450 | - $totalPrice = (int)$this->get_order_total(); |
|
| 451 | - $validAmount = ($totalPrice>=$minAmount && ($totalPrice<=$maxAmount || $maxAmount=='0')); |
|
| 448 | + $totalPrice = (int) $this->get_order_total(); |
|
| 449 | + $validAmount = ($totalPrice >= $minAmount && ($totalPrice <= $maxAmount || $maxAmount=='0')); |
|
| 452 | 450 | if ($cfg['enabled_4x']==='yes' && $cfg['pagantis_public_key_4x']!='' && $cfg['pagantis_private_key_4x']!='' && |
| 453 | 451 | $validAmount && $allowedCountry) { |
| 454 | 452 | return true; |
@@ -483,7 +481,7 @@ discard block |
||
| 483 | 481 | |
| 484 | 482 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 485 | 483 | if (strpos($redirectUrl, 'order-pay=')===false) { |
| 486 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 484 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 487 | 485 | } |
| 488 | 486 | |
| 489 | 487 | return array( |
@@ -491,7 +489,7 @@ discard block |
||
| 491 | 489 | 'redirect' => $redirectUrl |
| 492 | 490 | ); |
| 493 | 491 | } catch (Exception $e) { |
| 494 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error'); |
|
| 492 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error'); |
|
| 495 | 493 | return array(); |
| 496 | 494 | } |
| 497 | 495 | } |
@@ -562,7 +560,7 @@ discard block |
||
| 562 | 560 | private function generateUrl($url) |
| 563 | 561 | { |
| 564 | 562 | $parsed_url = parse_url($url); |
| 565 | - if ($parsed_url !== false) { |
|
| 563 | + if ($parsed_url!==false) { |
|
| 566 | 564 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 567 | 565 | parse_str($parsed_url['query'], $arrayParams); |
| 568 | 566 | foreach ($arrayParams as $keyParam => $valueParam) { |
@@ -610,11 +608,10 @@ discard block |
||
| 610 | 608 | private function getKeysUrl($order, $url) |
| 611 | 609 | { |
| 612 | 610 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 613 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : |
|
| 614 | - array(); |
|
| 611 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array(); |
|
| 615 | 612 | |
| 616 | 613 | $parsedUrl = parse_url($url); |
| 617 | - if ($parsedUrl !== false) { |
|
| 614 | + if ($parsedUrl!==false) { |
|
| 618 | 615 | //Replace parameters from url |
| 619 | 616 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 620 | 617 | |
@@ -659,7 +656,7 @@ discard block |
||
| 659 | 656 | foreach ($arrayParams as $keyParam => $valueParam) { |
| 660 | 657 | preg_match('#\{{.*?}\}#', $valueParam, $match); |
| 661 | 658 | if (count($match)) { |
| 662 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]); |
|
| 659 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]); |
|
| 663 | 660 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 664 | 661 | } |
| 665 | 662 | } |
@@ -674,12 +671,12 @@ discard block |
||
| 674 | 671 | */ |
| 675 | 672 | private function unparseUrl($parsed_url) |
| 676 | 673 | { |
| 677 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 674 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 678 | 675 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 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'] : ''; |
|
| 676 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 677 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 678 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 682 | 679 | $path = $parsed_url['path']; |
| 683 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 680 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 684 | 681 | } |
| 685 | 682 | } |