@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $this->insertLog($exception); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
| 89 | + if ($_SERVER['REQUEST_METHOD']=='POST') {
|
|
| 90 | 90 | $jsonResponse->printResponse(); |
| 91 | 91 | } else {
|
| 92 | 92 | return $jsonResponse; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | private function checkConcurrency() |
| 104 | 104 | {
|
| 105 | 105 | $this->woocommerceOrderId = $_GET['order-received']; |
| 106 | - if ($this->woocommerceOrderId == '') {
|
|
| 106 | + if ($this->woocommerceOrderId=='') {
|
|
| 107 | 107 | throw new QuoteNotFoundException(); |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $queryResult = $wpdb->get_row("select order_id from $tableName where id='".$this->woocommerceOrderId."'");
|
| 132 | 132 | $this->pagantisOrderId = $queryResult->order_id; |
| 133 | 133 | |
| 134 | - if ($this->pagantisOrderId == '') {
|
|
| 134 | + if ($this->pagantisOrderId=='') {
|
|
| 135 | 135 | throw new NoIdentificationException(); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | {
|
| 197 | 197 | $pagantisAmount = $this->pagantisOrder->getShoppingCart()->getTotalAmount(); |
| 198 | 198 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 199 | - if ($pagantisAmount != $wcAmount) {
|
|
| 199 | + if ($pagantisAmount!=$wcAmount) {
|
|
| 200 | 200 | throw new AmountMismatchException($pagantisAmount, $wcAmount); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | global $wpdb; |
| 238 | 238 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 239 | 239 | |
| 240 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 240 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 241 | 241 | $charset_collate = $wpdb->get_charset_collate(); |
| 242 | 242 | $sql = "CREATE TABLE $tableName (id int, order_id varchar(50), wc_order_id varchar(50), |
| 243 | 243 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | global $wpdb; |
| 256 | 256 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 257 | 257 | |
| 258 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 258 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 259 | 259 | $charset_collate = $wpdb->get_charset_collate(); |
| 260 | 260 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 261 | 261 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | if ($exception instanceof \Exception) {
|
| 356 | 356 | $this->checkDbLogTable(); |
| 357 | - $logEntry= new LogEntry(); |
|
| 357 | + $logEntry = new LogEntry(); |
|
| 358 | 358 | $logEntryJson = $logEntry->error($exception)->toJson(); |
| 359 | 359 | |
| 360 | 360 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function loadPagantisTranslation($mofile, $domain) |
| 79 | 79 | { |
| 80 | - if ('pagantis' === $domain) { |
|
| 81 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 80 | + if ('pagantis'===$domain) { |
|
| 81 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 82 | 82 | } |
| 83 | 83 | return $mofile; |
| 84 | 84 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 93 | 93 | |
| 94 | 94 | //Check if table exists |
| 95 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 95 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 96 | 96 | if ($tableExists) { |
| 97 | 97 | $charset_collate = $wpdb->get_charset_collate(); |
| 98 | 98 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | $locale = strtolower(strstr(get_locale(), '_', true)); |
| 147 | 147 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 148 | 148 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 149 | - if ($cfg['enabled'] !== 'yes' || $cfg['pagantis_public_key'] == '' || $cfg['pagantis_private_key'] == '' || |
|
| 150 | - $cfg['simulator'] !== 'yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
| 151 | - !$allowedCountry ) { |
|
| 149 | + if ($cfg['enabled']!=='yes' || $cfg['pagantis_public_key']=='' || $cfg['pagantis_private_key']=='' || |
|
| 150 | + $cfg['simulator']!=='yes' || $product->price < $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] || |
|
| 151 | + !$allowedCountry) { |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function addPagantisGateway($methods) |
| 176 | 176 | { |
| 177 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 177 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 178 | 178 | return $methods; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function pagantisRowMeta($links, $file) |
| 231 | 231 | { |
| 232 | - if ($file == plugin_basename(__FILE__)) { |
|
| 232 | + if ($file==plugin_basename(__FILE__)) { |
|
| 233 | 233 | $links[] = '<a href="'.WcPagantis::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'pagantis').'</a>'; |
| 234 | 234 | $links[] = '<a href="'.WcPagantis::PAGANTIS_DOC_URL.'" target="_blank">'. |
| 235 | 235 | __('API documentation', 'pagantis').'</a>'; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 258 | 258 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 259 | 259 | $results = $wpdb->get_results($query); |
| 260 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 260 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 261 | 261 | foreach ($results as $key => $result) { |
| 262 | 262 | $response[$key]['timestamp'] = $result->createdAt; |
| 263 | 263 | $response[$key]['log'] = json_decode($result->log); |
@@ -284,12 +284,12 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $filters = ($data->get_params()); |
| 286 | 286 | $secretKey = $filters['secret']; |
| 287 | - $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 287 | + $cfg = get_option('woocommerce_pagantis_settings'); |
|
| 288 | 288 | $privateKey = isset($cfg['pagantis_private_key']) ? $cfg['pagantis_private_key'] : null; |
| 289 | - if ($privateKey != $secretKey) { |
|
| 289 | + if ($privateKey!=$secretKey) { |
|
| 290 | 290 | $response['status'] = 401; |
| 291 | 291 | $response['result'] = 'Unauthorized'; |
| 292 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 292 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 293 | 293 | if (count($_POST)) { |
| 294 | 294 | foreach ($_POST as $config => $value) { |
| 295 | 295 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <script> |
| 2 | 2 | function findPriceSelector() |
| 3 | 3 | { |
| 4 | - var priceSelectors = <?php echo json_encode($priceSelector);?>; |
|
| 4 | + var priceSelectors = <?php echo json_encode($priceSelector); ?>; |
|
| 5 | 5 | return priceSelectors.find(function(candidateSelector) { |
| 6 | 6 | var priceDOM = document.querySelector(candidateSelector); |
| 7 | 7 | return (priceDOM != null ); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | function findQuantitySelector() |
| 13 | 13 | { |
| 14 | - var quantitySelectors = <?php echo json_encode($quantitySelector);?>; |
|
| 14 | + var quantitySelectors = <?php echo json_encode($quantitySelector); ?>; |
|
| 15 | 15 | return quantitySelectors.find(function(candidateSelector) { |
| 16 | 16 | var priceDOM = document.querySelector(candidateSelector); |
| 17 | 17 | return (priceDOM != null ); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | return finishInterval(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - var price = '<?php echo $total;?>'; |
|
| 54 | + var price = '<?php echo $total; ?>'; |
|
| 55 | 55 | |
| 56 | 56 | var locale = '<?php echo $locale; ?>'; |
| 57 | 57 | if (locale == 'es' || locale == '') { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | var sdk = pgSDK; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - var positionSelector = '<?php echo $positionSelector;?>'; |
|
| 63 | + var positionSelector = '<?php echo $positionSelector; ?>'; |
|
| 64 | 64 | if (positionSelector === 'default') { |
| 65 | 65 | positionSelector = '.pagantisSimulator'; |
| 66 | 66 | } |
@@ -54,36 +54,36 @@ discard block |
||
| 54 | 54 | $this->title = $this->extraConfig['PAGANTIS_TITLE']; |
| 55 | 55 | |
| 56 | 56 | //Useful vars |
| 57 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 57 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 58 | 58 | $this->allowed_currencies = array("EUR");
|
| 59 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Pagantis.php'; |
|
| 59 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Pagantis.php'; |
|
| 60 | 60 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
|
| 61 | 61 | $this->language = strstr(get_locale(), '_', true); |
| 62 | 62 | |
| 63 | - if ($this->language == 'es' || $this->language == '') {
|
|
| 63 | + if ($this->language=='es' || $this->language=='') {
|
|
| 64 | 64 | $this->icon = esc_url(plugins_url('../assets/images/logopagamastarde.png', __FILE__));
|
| 65 | 65 | } else {
|
| 66 | 66 | $this->icon = esc_url(plugins_url('../assets/images/logo.png', __FILE__));
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | //Panel form fields |
| 70 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php');//Panel options |
|
| 70 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-pagantis.php'); //Panel options |
|
| 71 | 71 | $this->init_settings(); |
| 72 | 72 | |
| 73 | 73 | $this->extraConfig = $this->getExtraConfig(); |
| 74 | 74 | |
| 75 | - $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='')?$this->extraConfig['PAGANTIS_URL_OK']:$this->generateOkUrl(); |
|
| 76 | - $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='')?$this->extraConfig['PAGANTIS_URL_KO']:$this->generateKoUrl(); |
|
| 75 | + $this->settings['ok_url'] = ($this->extraConfig['PAGANTIS_URL_OK']!='') ? $this->extraConfig['PAGANTIS_URL_OK'] : $this->generateOkUrl(); |
|
| 76 | + $this->settings['ko_url'] = ($this->extraConfig['PAGANTIS_URL_KO']!='') ? $this->extraConfig['PAGANTIS_URL_KO'] : $this->generateKoUrl(); |
|
| 77 | 77 | foreach ($this->settings as $setting_key => $setting_value) {
|
| 78 | 78 | $this->$setting_key = $setting_value; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | //Hooks |
| 82 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
|
|
| 83 | - add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 84 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 85 | - add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 86 | - add_filter('woocommerce_payment_complete_order_status', array($this,'pagantisCompleteStatus'), 10, 3);
|
|
| 82 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 83 | + add_action('admin_notices', array($this, 'pagantisCheckFields')); //Check config fields
|
|
| 84 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'pagantisReceiptPage')); //Pagantis form
|
|
| 85 | + add_action('woocommerce_api_wcpagantisgateway', array($this, 'pagantisNotification')); //Json Notification
|
|
| 86 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'pagantisCompleteStatus'), 10, 3);
|
|
| 87 | 87 | add_filter('load_textdomain_mofile', array($this, 'loadPagantisTranslation'), 10, 2);
|
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function loadPagantisTranslation($mofile, $domain) |
| 97 | 97 | {
|
| 98 | - if ('pagantis' === $domain) {
|
|
| 99 | - $mofile = WP_LANG_DIR . '/../plugins/pagantis/languages/pagantis-' . get_locale() . '.mo'; |
|
| 98 | + if ('pagantis'===$domain) {
|
|
| 99 | + $mofile = WP_LANG_DIR.'/../plugins/pagantis/languages/pagantis-'.get_locale().'.mo'; |
|
| 100 | 100 | } |
| 101 | 101 | return $mofile; |
| 102 | 102 | } |
@@ -129,24 +129,24 @@ discard block |
||
| 129 | 129 | public function pagantisCheckFields() |
| 130 | 130 | {
|
| 131 | 131 | $error_string = ''; |
| 132 | - if ($this->settings['enabled'] !== 'yes') {
|
|
| 132 | + if ($this->settings['enabled']!=='yes') {
|
|
| 133 | 133 | return; |
| 134 | 134 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
|
| 135 | - $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 135 | + $error_string = __(' is not compatible with your php and/or curl version', 'pagantis');
|
|
| 136 | 136 | $this->settings['enabled'] = 'no'; |
| 137 | 137 | } elseif ($this->settings['pagantis_public_key']=="" || $this->settings['pagantis_private_key']=="") {
|
| 138 | 138 | $error_string = __(' is not configured correctly, the fields Public Key and Secret Key are mandatory for use this plugin', 'pagantis');
|
| 139 | 139 | $this->settings['enabled'] = 'no'; |
| 140 | 140 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
| 141 | - $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 141 | + $error_string = __(' only can be used in Euros', 'pagantis');
|
|
| 142 | 142 | $this->settings['enabled'] = 'no'; |
| 143 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']<'2' |
|
| 144 | - || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS']>'12') {
|
|
| 143 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] < '2' |
|
| 144 | + || $this->extraConfig['PAGANTIS_SIMULATOR_MAX_INSTALLMENTS'] > '12') {
|
|
| 145 | 145 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 146 | - } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']<'2' |
|
| 147 | - || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS']>'12') {
|
|
| 146 | + } elseif ($this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] < '2' |
|
| 147 | + || $this->extraConfig['PAGANTIS_SIMULATOR_START_INSTALLMENTS'] > '12') {
|
|
| 148 | 148 | $error_string = __(' only can be payed from 2 to 12 installments', 'pagantis');
|
| 149 | - } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT']<0) {
|
|
| 149 | + } elseif ($this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] < 0) {
|
|
| 150 | 150 | $error_string = __(' can not have a minimum amount less than 0', 'pagantis');
|
| 151 | 151 | } |
| 152 | 152 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $shippingAddress = $order->get_address('shipping');
|
| 182 | 182 | $billingAddress = $order->get_address('billing');
|
| 183 | - if ($shippingAddress['address_1'] == '') {
|
|
| 183 | + if ($shippingAddress['address_1']=='') {
|
|
| 184 | 184 | $shippingAddress = $billingAddress; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | ->setNationalId($national_id) |
| 208 | 208 | ->setTaxId($tax_id) |
| 209 | 209 | ; |
| 210 | - $orderBillingAddress = new Address(); |
|
| 210 | + $orderBillingAddress = new Address(); |
|
| 211 | 211 | $orderBillingAddress |
| 212 | 212 | ->setZipCode($billingAddress['postcode']) |
| 213 | 213 | ->setFullName($billingAddress['first_name']." ".$billingAddress['last_name']) |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | wc_get_template('iframe.php', $template_fields, '', $this->template_path);
|
| 339 | 339 | } |
| 340 | 340 | } catch (\Exception $exception) {
|
| 341 | - wc_add_notice(__('Payment error ', 'pagantis') . $exception->getMessage(), 'error');
|
|
| 341 | + wc_add_notice(__('Payment error ', 'pagantis').$exception->getMessage(), 'error');
|
|
| 342 | 342 | $this->insertLog($exception); |
| 343 | 343 | $checkout_url = get_permalink(wc_get_page_id('checkout'));
|
| 344 | 344 | wp_redirect($checkout_url); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | public function pagantisNotification() |
| 353 | 353 | {
|
| 354 | 354 | try {
|
| 355 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 355 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 356 | 356 | |
| 357 | 357 | include_once('notifyController.php');
|
| 358 | 358 | $notify = new WcPagantisNotify(); |
@@ -391,10 +391,10 @@ discard block |
||
| 391 | 391 | */ |
| 392 | 392 | public function pagantisCompleteStatus($status, $order_id, $order) |
| 393 | 393 | {
|
| 394 | - if ($order->get_payment_method() == WcPagantisGateway::METHOD_ID) {
|
|
| 395 | - if ($order->get_status() == 'failed') {
|
|
| 394 | + if ($order->get_payment_method()==WcPagantisGateway::METHOD_ID) {
|
|
| 395 | + if ($order->get_status()=='failed') {
|
|
| 396 | 396 | $status = 'processing'; |
| 397 | - } elseif ($order->get_status() == 'pending' && $status=='completed') {
|
|
| 397 | + } elseif ($order->get_status()=='pending' && $status=='completed') {
|
|
| 398 | 398 | $status = 'processing'; |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $allowedCountries = unserialize($this->extraConfig['PAGANTIS_ALLOWED_COUNTRIES']); |
| 419 | 419 | $allowedCountry = (in_array(strtolower($locale), $allowedCountries)); |
| 420 | 420 | if ($this->enabled==='yes' && $this->pagantis_public_key!='' && $this->pagantis_private_key!='' && |
| 421 | - (int)$this->get_order_total()>$this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) {
|
|
| 421 | + (int) $this->get_order_total() > $this->extraConfig['PAGANTIS_DISPLAY_MIN_AMOUNT'] && $allowedCountry) {
|
|
| 422 | 422 | return true; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | |
| 447 | 447 | $redirectUrl = $order->get_checkout_payment_url(true); //pagantisReceiptPage function |
| 448 | 448 | if (strpos($redirectUrl, 'order-pay=')===false) {
|
| 449 | - $redirectUrl.="&order-pay=".$order_id; |
|
| 449 | + $redirectUrl .= "&order-pay=".$order_id; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | return array( |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | 457 | } catch (Exception $e) {
|
| 458 | - wc_add_notice(__('Payment error ', 'pagantis') . $e->getMessage(), 'error');
|
|
| 458 | + wc_add_notice(__('Payment error ', 'pagantis').$e->getMessage(), 'error');
|
|
| 459 | 459 | return array(); |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | private function generateUrl($url) |
| 516 | 516 | {
|
| 517 | 517 | $parsed_url = parse_url($url); |
| 518 | - if ($parsed_url !== false) {
|
|
| 518 | + if ($parsed_url!==false) {
|
|
| 519 | 519 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 520 | 520 | parse_str($parsed_url['query'], $arrayParams); |
| 521 | 521 | foreach ($arrayParams as $keyParam => $valueParam) {
|
@@ -563,11 +563,10 @@ discard block |
||
| 563 | 563 | private function getKeysUrl($order, $url) |
| 564 | 564 | {
|
| 565 | 565 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 566 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
|
|
| 567 | - array(); |
|
| 566 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
|
|
| 568 | 567 | |
| 569 | 568 | $parsedUrl = parse_url($url); |
| 570 | - if ($parsedUrl !== false) {
|
|
| 569 | + if ($parsedUrl!==false) {
|
|
| 571 | 570 | //Replace parameters from url |
| 572 | 571 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 573 | 572 | |
@@ -612,7 +611,7 @@ discard block |
||
| 612 | 611 | foreach ($arrayParams as $keyParam => $valueParam) {
|
| 613 | 612 | preg_match('#\{{.*?}\}#', $valueParam, $match);
|
| 614 | 613 | if (count($match)) {
|
| 615 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]);
|
|
| 614 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
|
|
| 616 | 615 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 617 | 616 | } |
| 618 | 617 | } |
@@ -627,13 +626,13 @@ discard block |
||
| 627 | 626 | */ |
| 628 | 627 | private function unparseUrl($parsed_url) |
| 629 | 628 | {
|
| 630 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 629 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 631 | 630 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 632 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 633 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 634 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 631 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 632 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 633 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 635 | 634 | $path = $parsed_url['path']; |
| 636 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 635 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 637 | 636 | } |
| 638 | 637 | |
| 639 | 638 | /** |
@@ -655,20 +654,20 @@ discard block |
||
| 655 | 654 | $is_guest = "false"; |
| 656 | 655 | $sign_up = substr($current_user->user_registered, 0, 10); |
| 657 | 656 | $customer_orders = get_posts(array( |
| 658 | - 'numberposts' => - 1, |
|
| 657 | + 'numberposts' => -1, |
|
| 659 | 658 | 'meta_key' => '_customer_user', |
| 660 | 659 | 'meta_value' => $current_user->ID, |
| 661 | - 'post_type' => array( 'shop_order' ), |
|
| 662 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
| 660 | + 'post_type' => array('shop_order'),
|
|
| 661 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 663 | 662 | )); |
| 664 | 663 | } else {
|
| 665 | 664 | $is_guest = "true"; |
| 666 | 665 | $customer_orders = get_posts(array( |
| 667 | - 'numberposts' => - 1, |
|
| 666 | + 'numberposts' => -1, |
|
| 668 | 667 | 'meta_key' => '_billing_email', |
| 669 | 668 | 'meta_value' => $billingEmail, |
| 670 | - 'post_type' => array( 'shop_order' ), |
|
| 671 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 669 | + 'post_type' => array('shop_order'),
|
|
| 670 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 672 | 671 | )); |
| 673 | 672 | foreach ($customer_orders as $customer_order) {
|
| 674 | 673 | if (trim($sign_up)=='' || |
@@ -697,7 +696,7 @@ discard block |
||
| 697 | 696 | //Check if id exists |
| 698 | 697 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
|
| 699 | 698 | $countResults = count($resultsSelect); |
| 700 | - if ($countResults == 0) {
|
|
| 699 | + if ($countResults==0) {
|
|
| 701 | 700 | $wpdb->insert( |
| 702 | 701 | $tableName, |
| 703 | 702 | array('id' => $orderId, 'order_id' => $pagantisOrderId),
|
@@ -722,7 +721,7 @@ discard block |
||
| 722 | 721 | global $wpdb; |
| 723 | 722 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 724 | 723 | |
| 725 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 724 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 726 | 725 | $charset_collate = $wpdb->get_charset_collate(); |
| 727 | 726 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 728 | 727 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -755,9 +754,9 @@ discard block |
||
| 755 | 754 | */ |
| 756 | 755 | private function getNationalId($order) |
| 757 | 756 | {
|
| 758 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 757 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 759 | 758 | $data = $mdObject->get_data(); |
| 760 | - if ($data['key'] == 'vat_number') {
|
|
| 759 | + if ($data['key']=='vat_number') {
|
|
| 761 | 760 | return $data['value']; |
| 762 | 761 | } |
| 763 | 762 | } |
@@ -772,9 +771,9 @@ discard block |
||
| 772 | 771 | */ |
| 773 | 772 | private function getTaxId($order) |
| 774 | 773 | {
|
| 775 | - foreach ((array)$order->get_meta_data() as $mdObject) {
|
|
| 774 | + foreach ((array) $order->get_meta_data() as $mdObject) {
|
|
| 776 | 775 | $data = $mdObject->get_data(); |
| 777 | - if ($data['key'] == 'billing_cfpiva') {
|
|
| 776 | + if ($data['key']=='billing_cfpiva') {
|
|
| 778 | 777 | return $data['value']; |
| 779 | 778 | } |
| 780 | 779 | } |
@@ -804,7 +803,7 @@ discard block |
||
| 804 | 803 | {
|
| 805 | 804 | global $wpdb; |
| 806 | 805 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 807 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 806 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 808 | 807 | $charset_collate = $wpdb->get_charset_collate(); |
| 809 | 808 | $sql = "CREATE TABLE $tableName ( id int NOT NULL AUTO_INCREMENT, log text NOT NULL, |
| 810 | 809 | createdAt timestamp DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY id (id)) $charset_collate"; |