@@ -3,17 +3,17 @@ |
||
| 3 | 3 | |
| 4 | 4 | function loadSimulator() |
| 5 | 5 | { |
| 6 | - var positionSelector = '<? echo $positionSelector;?>'; |
|
| 6 | + var positionSelector = '<? echo $positionSelector; ?>'; |
|
| 7 | 7 | if (positionSelector === 'default') { |
| 8 | 8 | positionSelector = '.PmtSimulator'; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - var priceSelector = '<? echo $priceSelector;?>'; |
|
| 11 | + var priceSelector = '<? echo $priceSelector; ?>'; |
|
| 12 | 12 | if (priceSelector === 'default') { |
| 13 | 13 | priceSelector = 'div.summary.entry-summary span.woocommerce-Price-amount.amount'; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - var quantitySelector = '<? echo $quantitySelector;?>'; |
|
| 16 | + var quantitySelector = '<? echo $quantitySelector; ?>'; |
|
| 17 | 17 | if (quantitySelector === 'default') { |
| 18 | 18 | quantitySelector = 'div.quantity>input'; |
| 19 | 19 | } |
@@ -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->pmtOrderId = $queryResult->order_id; |
| 133 | 133 | |
| 134 | - if ($this->pmtOrderId == '') {
|
|
| 134 | + if ($this->pmtOrderId=='') {
|
|
| 135 | 135 | throw new NoIdentificationException(); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | {
|
| 197 | 197 | $pmtAmount = $this->pmtOrder->getShoppingCart()->getTotalAmount(); |
| 198 | 198 | $wcAmount = intval(strval(100 * $this->woocommerceOrder->get_total())); |
| 199 | - if ($pmtAmount != $wcAmount) {
|
|
| 199 | + if ($pmtAmount!=$wcAmount) {
|
|
| 200 | 200 | throw new AmountMismatchException($pmtAmount, $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; |
@@ -39,28 +39,28 @@ discard block |
||
| 39 | 39 | $this->title = WcPaylaterGateway::METHOD_TITLE; |
| 40 | 40 | |
| 41 | 41 | //Useful vars |
| 42 | - $this->template_path = plugin_dir_path(__FILE__) . '../templates/'; |
|
| 42 | + $this->template_path = plugin_dir_path(__FILE__).'../templates/'; |
|
| 43 | 43 | $this->allowed_currencies = array("EUR");
|
| 44 | 44 | $this->allowed_languages = array("es_ES");
|
| 45 | - $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)) . '/WC_Paylater.php'; |
|
| 45 | + $this->mainFileLocation = dirname(plugin_dir_path(__FILE__)).'/WC_Paylater.php'; |
|
| 46 | 46 | $this->plugin_info = get_file_data($this->mainFileLocation, array('Version' => 'Version'), false);
|
| 47 | 47 | |
| 48 | 48 | //Panel form fields |
| 49 | - $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-paylater.php');//Panel options |
|
| 49 | + $this->form_fields = include(plugin_dir_path(__FILE__).'../includes/settings-paylater.php'); //Panel options |
|
| 50 | 50 | $this->init_settings(); |
| 51 | 51 | |
| 52 | - $this->settings['ok_url'] = (getenv('PMT_URL_OK')!='')?getenv('PMT_URL_OK'):$this->generateOkUrl();
|
|
| 53 | - $this->settings['ko_url'] = (getenv('PMT_URL_KO')!='')?getenv('PMT_URL_KO'):$this->generateKoUrl();
|
|
| 52 | + $this->settings['ok_url'] = (getenv('PMT_URL_OK')!='') ?getenv('PMT_URL_OK') : $this->generateOkUrl();
|
|
| 53 | + $this->settings['ko_url'] = (getenv('PMT_URL_KO')!='') ?getenv('PMT_URL_KO') : $this->generateKoUrl();
|
|
| 54 | 54 | foreach ($this->settings as $setting_key => $setting_value) {
|
| 55 | 55 | $this->$setting_key = $setting_value; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | //Hooks |
| 59 | - add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this,'process_admin_options')); //Save plugin options
|
|
| 60 | - add_action('admin_notices', array($this, 'paylaterCheckFields')); //Check config fields
|
|
| 61 | - add_action('woocommerce_receipt_'.$this->id, array($this, 'paylaterReceiptPage')); //Pmt form
|
|
| 62 | - add_action('woocommerce_api_wcpaylatergateway', array($this, 'paylaterNotification')); //Json Notification
|
|
| 63 | - add_filter('woocommerce_payment_complete_order_status', array($this,'paylaterCompleteStatus'), 10, 3);
|
|
| 59 | + add_action('woocommerce_update_options_payment_gateways_'.$this->id, array($this, 'process_admin_options')); //Save plugin options
|
|
| 60 | + add_action('admin_notices', array($this, 'paylaterCheckFields')); //Check config fields
|
|
| 61 | + add_action('woocommerce_receipt_'.$this->id, array($this, 'paylaterReceiptPage')); //Pmt form
|
|
| 62 | + add_action('woocommerce_api_wcpaylatergateway', array($this, 'paylaterNotification')); //Json Notification
|
|
| 63 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'paylaterCompleteStatus'), 10, 3);
|
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /*********** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $template_fields = array( |
| 78 | 78 | 'panel_header' => $this->title, |
| 79 | 79 | 'panel_description' => $this->method_description, |
| 80 | - 'button1_label' => __('Login al panel de ', 'paylater') . WcPaylaterGateway::METHOD_TITLE,
|
|
| 80 | + 'button1_label' => __('Login al panel de ', 'paylater').WcPaylaterGateway::METHOD_TITLE,
|
|
| 81 | 81 | 'button2_label' => __('Documentación', 'paylater'),
|
| 82 | 82 | 'logo' => $this->icon, |
| 83 | 83 | 'settings' => $this->generate_settings_html($this->form_fields, false) |
@@ -91,36 +91,36 @@ discard block |
||
| 91 | 91 | public function paylaterCheckFields() |
| 92 | 92 | {
|
| 93 | 93 | $error_string = ''; |
| 94 | - if ($this->settings['enabled'] !== 'yes') {
|
|
| 94 | + if ($this->settings['enabled']!=='yes') {
|
|
| 95 | 95 | return; |
| 96 | 96 | } elseif (!version_compare(phpversion(), '5.3.0', '>=')) {
|
| 97 | - $error_string = __(' no es compatible con su versión de php y/o curl', 'paylater');
|
|
| 97 | + $error_string = __(' no es compatible con su versión de php y/o curl', 'paylater');
|
|
| 98 | 98 | $this->settings['enabled'] = 'no'; |
| 99 | 99 | } elseif ($this->settings['pmt_public_key']=="" || $this->settings['pmt_private_key']=="") {
|
| 100 | - $keys_error = <<<EOD |
|
| 100 | + $keys_error = <<<EOD |
|
| 101 | 101 | no está configurado correctamente, los campos Public Key y Secret Key son obligatorios para su funcionamiento |
| 102 | 102 | EOD; |
| 103 | 103 | $error_string = __($keys_error, 'paylater'); |
| 104 | 104 | $this->settings['enabled'] = 'no'; |
| 105 | 105 | } elseif (!in_array(get_woocommerce_currency(), $this->allowed_currencies)) {
|
| 106 | - $error_string = __(' solo puede ser usado en Euros', 'paylater');
|
|
| 106 | + $error_string = __(' solo puede ser usado en Euros', 'paylater');
|
|
| 107 | 107 | $this->settings['enabled'] = 'no'; |
| 108 | 108 | } elseif (!in_array(get_locale(), $this->allowed_languages)) {
|
| 109 | 109 | $error_string = __(' solo puede ser usado en Español', 'paylater');
|
| 110 | 110 | $this->settings['enabled'] = 'no'; |
| 111 | - } elseif (getenv('PMT_SIMULATOR_MAX_INSTALLMENTS')<'2'
|
|
| 112 | - || getenv('PMT_SIMULATOR_MAX_INSTALLMENTS')>'12') {
|
|
| 111 | + } elseif (getenv('PMT_SIMULATOR_MAX_INSTALLMENTS') < '2'
|
|
| 112 | + || getenv('PMT_SIMULATOR_MAX_INSTALLMENTS') > '12') {
|
|
| 113 | 113 | $error_string = __(' solo puede ser pagado de 2 a 12 plazos.', 'paylater');
|
| 114 | - } elseif (getenv('PMT_SIMULATOR_START_INSTALLMENTS')<'2'
|
|
| 115 | - || getenv('PMT_SIMULATOR_START_INSTALLMENTS')>'12') {
|
|
| 114 | + } elseif (getenv('PMT_SIMULATOR_START_INSTALLMENTS') < '2'
|
|
| 115 | + || getenv('PMT_SIMULATOR_START_INSTALLMENTS') > '12') {
|
|
| 116 | 116 | $error_string = __(' solo puede ser pagado de 2 a 12 plazos.', 'paylater');
|
| 117 | - } elseif (getenv('PMT_DISPLAY_MIN_AMOUNT')<0) {
|
|
| 117 | + } elseif (getenv('PMT_DISPLAY_MIN_AMOUNT') < 0) {
|
|
| 118 | 118 | $error_string = __(' el importe debe ser mayor a 0.', 'paylater');
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if ($error_string!='') {
|
| 122 | 122 | $template_fields = array( |
| 123 | - 'error_msg' => WcPaylaterGateway::METHOD_TITLE .' '.$error_string, |
|
| 123 | + 'error_msg' => WcPaylaterGateway::METHOD_TITLE.' '.$error_string, |
|
| 124 | 124 | ); |
| 125 | 125 | wc_get_template('error_msg.php', $template_fields, '', $this->template_path);
|
| 126 | 126 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $shippingAddress = $order->get_address('shipping');
|
| 148 | 148 | $billingAddress = $order->get_address('billing');
|
| 149 | - if ($shippingAddress['address_1'] == '') {
|
|
| 149 | + if ($shippingAddress['address_1']=='') {
|
|
| 150 | 150 | $shippingAddress = $billingAddress; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | ->setFixPhone($shippingAddress['phone']) |
| 169 | 169 | ->setMobilePhone($shippingAddress['phone']) |
| 170 | 170 | ; |
| 171 | - $orderBillingAddress = new Address(); |
|
| 171 | + $orderBillingAddress = new Address(); |
|
| 172 | 172 | $orderBillingAddress |
| 173 | 173 | ->setZipCode($billingAddress['postcode']) |
| 174 | 174 | ->setFullName($billingAddress['fist_name']." ".$billingAddress['last_name']) |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | wc_get_template('iframe.php', $template_fields, '', $this->template_path);
|
| 291 | 291 | } |
| 292 | 292 | } catch (\Exception $exception) {
|
| 293 | - wc_add_notice(__('Error en el pago - ', 'paylater') . $exception->getMessage(), 'error');
|
|
| 293 | + wc_add_notice(__('Error en el pago - ', 'paylater').$exception->getMessage(), 'error');
|
|
| 294 | 294 | $checkout_url = get_permalink(wc_get_page_id('checkout'));
|
| 295 | 295 | wp_redirect($checkout_url); |
| 296 | 296 | exit; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | public function paylaterNotification() |
| 304 | 304 | {
|
| 305 | 305 | try {
|
| 306 | - $origin = ($_SERVER['REQUEST_METHOD'] == 'POST') ? 'Notify' : 'Order'; |
|
| 306 | + $origin = ($_SERVER['REQUEST_METHOD']=='POST') ? 'Notify' : 'Order'; |
|
| 307 | 307 | |
| 308 | 308 | include_once('notifyController.php');
|
| 309 | 309 | $notify = new WcPaylaterNotify(); |
@@ -342,10 +342,10 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function paylaterCompleteStatus($status, $order_id, $order) |
| 344 | 344 | {
|
| 345 | - if ($order->get_payment_method() == WcPaylaterGateway::METHOD_ID) {
|
|
| 346 | - if ($order->get_status() == 'failed') {
|
|
| 345 | + if ($order->get_payment_method()==WcPaylaterGateway::METHOD_ID) {
|
|
| 346 | + if ($order->get_status()=='failed') {
|
|
| 347 | 347 | $status = 'processing'; |
| 348 | - } elseif ($order->get_status() == 'pending' && $status=='completed') {
|
|
| 348 | + } elseif ($order->get_status()=='pending' && $status=='completed') {
|
|
| 349 | 349 | $status = 'processing'; |
| 350 | 350 | } |
| 351 | 351 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | public function is_available() |
| 367 | 367 | {
|
| 368 | 368 | if ($this->enabled==='yes' && $this->pmt_public_key!='' && $this->pmt_private_key!='' && |
| 369 | - $this->get_order_total()>getenv('PMT_DISPLAY_MIN_AMOUNT')) {
|
|
| 369 | + $this->get_order_total() > getenv('PMT_DISPLAY_MIN_AMOUNT')) {
|
|
| 370 | 370 | return true; |
| 371 | 371 | } |
| 372 | 372 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | ); |
| 404 | 404 | |
| 405 | 405 | } catch (Exception $e) {
|
| 406 | - wc_add_notice(__('Error en el pago ', 'paylater') . $e->getMessage(), 'error');
|
|
| 406 | + wc_add_notice(__('Error en el pago ', 'paylater').$e->getMessage(), 'error');
|
|
| 407 | 407 | return array(); |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | private function generateUrl($url) |
| 456 | 456 | {
|
| 457 | 457 | $parsed_url = parse_url($url); |
| 458 | - if ($parsed_url !== false) {
|
|
| 458 | + if ($parsed_url!==false) {
|
|
| 459 | 459 | $parsed_url['query'] = !isset($parsed_url['query']) ? '' : $parsed_url['query']; |
| 460 | 460 | parse_str($parsed_url['query'], $arrayParams); |
| 461 | 461 | foreach ($arrayParams as $keyParam => $valueParam) {
|
@@ -503,11 +503,10 @@ discard block |
||
| 503 | 503 | private function getKeysUrl($order, $url) |
| 504 | 504 | {
|
| 505 | 505 | $defaultFields = (get_class($order)=='WC_Order') ? |
| 506 | - array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) :
|
|
| 507 | - array(); |
|
| 506 | + array('order-received'=>$order->get_id(), 'key'=>$order->get_order_key()) : array();
|
|
| 508 | 507 | |
| 509 | 508 | $parsedUrl = parse_url($url); |
| 510 | - if ($parsedUrl !== false) {
|
|
| 509 | + if ($parsedUrl!==false) {
|
|
| 511 | 510 | //Replace parameters from url |
| 512 | 511 | $parsedUrl['query'] = $this->getKeysParametersUrl($parsedUrl['query'], $defaultFields); |
| 513 | 512 | |
@@ -552,7 +551,7 @@ discard block |
||
| 552 | 551 | foreach ($arrayParams as $keyParam => $valueParam) {
|
| 553 | 552 | preg_match('#\{{.*?}\}#', $valueParam, $match);
|
| 554 | 553 | if (count($match)) {
|
| 555 | - $key = str_replace(array('{{','}}'), array('',''), $match[0]);
|
|
| 554 | + $key = str_replace(array('{{', '}}'), array('', ''), $match[0]);
|
|
| 556 | 555 | $arrayParams[$keyParam] = $defaultFields[$key]; |
| 557 | 556 | } |
| 558 | 557 | } |
@@ -567,13 +566,13 @@ discard block |
||
| 567 | 566 | */ |
| 568 | 567 | private function unparseUrl($parsed_url) |
| 569 | 568 | {
|
| 570 | - $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; |
|
| 569 | + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'].'://' : ''; |
|
| 571 | 570 | $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; |
| 572 | - $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; |
|
| 573 | - $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; |
|
| 574 | - $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; |
|
| 571 | + $port = isset($parsed_url['port']) ? ':'.$parsed_url['port'] : ''; |
|
| 572 | + $query = isset($parsed_url['query']) ? '?'.$parsed_url['query'] : ''; |
|
| 573 | + $fragment = isset($parsed_url['fragment']) ? '#'.$parsed_url['fragment'] : ''; |
|
| 575 | 574 | $path = $parsed_url['path']; |
| 576 | - return $scheme . $host . $port . $path . $query . $fragment; |
|
| 575 | + return $scheme.$host.$port.$path.$query.$fragment; |
|
| 577 | 576 | } |
| 578 | 577 | |
| 579 | 578 | /** |
@@ -595,20 +594,20 @@ discard block |
||
| 595 | 594 | $is_guest = "false"; |
| 596 | 595 | $sign_up = substr($current_user->user_registered, 0, 10); |
| 597 | 596 | $customer_orders = get_posts(array( |
| 598 | - 'numberposts' => - 1, |
|
| 597 | + 'numberposts' => -1, |
|
| 599 | 598 | 'meta_key' => '_customer_user', |
| 600 | 599 | 'meta_value' => $current_user->ID, |
| 601 | - 'post_type' => array( 'shop_order' ), |
|
| 602 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded' ), |
|
| 600 | + 'post_type' => array('shop_order'),
|
|
| 601 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 603 | 602 | )); |
| 604 | 603 | } else {
|
| 605 | 604 | $is_guest = "true"; |
| 606 | 605 | $customer_orders = get_posts(array( |
| 607 | - 'numberposts' => - 1, |
|
| 606 | + 'numberposts' => -1, |
|
| 608 | 607 | 'meta_key' => '_billing_email', |
| 609 | 608 | 'meta_value' => $billingEmail, |
| 610 | - 'post_type' => array( 'shop_order' ), |
|
| 611 | - 'post_status' => array( 'wc-completed', 'wc-processing', 'wc-refunded'), |
|
| 609 | + 'post_type' => array('shop_order'),
|
|
| 610 | + 'post_status' => array('wc-completed', 'wc-processing', 'wc-refunded'),
|
|
| 612 | 611 | )); |
| 613 | 612 | foreach ($customer_orders as $customer_order) {
|
| 614 | 613 | if (trim($sign_up)=='' || |
@@ -637,7 +636,7 @@ discard block |
||
| 637 | 636 | //Check if id exists |
| 638 | 637 | $resultsSelect = $wpdb->get_results("select * from $tableName where id='$orderId'");
|
| 639 | 638 | $countResults = count($resultsSelect); |
| 640 | - if ($countResults == 0) {
|
|
| 639 | + if ($countResults==0) {
|
|
| 641 | 640 | $wpdb->insert( |
| 642 | 641 | $tableName, |
| 643 | 642 | array('id' => $orderId, 'order_id' => $pmtOrderId),
|
@@ -662,7 +661,7 @@ discard block |
||
| 662 | 661 | global $wpdb; |
| 663 | 662 | $tableName = $wpdb->prefix.self::ORDERS_TABLE; |
| 664 | 663 | |
| 665 | - if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName) {
|
|
| 664 | + if ($wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName) {
|
|
| 666 | 665 | $charset_collate = $wpdb->get_charset_collate(); |
| 667 | 666 | $sql = "CREATE TABLE $tableName ( id int, order_id varchar(50), wc_order_id varchar(50), |
| 668 | 667 | UNIQUE KEY id (id)) $charset_collate"; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $tableName = $wpdb->prefix.self::CONFIG_TABLE; |
| 73 | 73 | |
| 74 | 74 | //Check if table exists |
| 75 | - $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'") != $tableName; |
|
| 75 | + $tableExists = $wpdb->get_var("SHOW TABLES LIKE '$tableName'")!=$tableName; |
|
| 76 | 76 | if ($tableExists) { |
| 77 | 77 | $charset_collate = $wpdb->get_charset_collate(); |
| 78 | 78 | $sql = "CREATE TABLE IF NOT EXISTS $tableName ( |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | foreach (array_merge($this->defaultConfigs, $simpleDbConfigs) as $key => $value) { |
| 103 | - putenv($key . '=' . $value); |
|
| 103 | + putenv($key.'='.$value); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | //Current plugin config: pmt_public_key => New field --- public_key => Old field |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | global $product; |
| 128 | 128 | |
| 129 | 129 | $cfg = get_option('woocommerce_paylater_settings'); |
| 130 | - if ($cfg['enabled'] !== 'yes' || $cfg['pmt_public_key'] == '' || $cfg['pmt_private_key'] == '' || |
|
| 131 | - $cfg['simulator'] !== 'yes') { |
|
| 130 | + if ($cfg['enabled']!=='yes' || $cfg['pmt_public_key']=='' || $cfg['pmt_private_key']=='' || |
|
| 131 | + $cfg['simulator']!=='yes') { |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function addPaylaterGateway($methods) |
| 155 | 155 | { |
| 156 | - if (! class_exists('WC_Payment_Gateway')) { |
|
| 156 | + if (!class_exists('WC_Payment_Gateway')) { |
|
| 157 | 157 | return $methods; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function paylaterRowMeta($links, $file) |
| 208 | 208 | { |
| 209 | - if ($file == plugin_basename(__FILE__)) { |
|
| 209 | + if ($file==plugin_basename(__FILE__)) { |
|
| 210 | 210 | $links[] = '<a href="'.WcPaylater::GIT_HUB_URL.'" target="_blank">'.__('Documentation', 'paylater').'</a>'; |
| 211 | 211 | $links[] = '<a href="'.WcPaylater::PMT_DOC_URL.'" target="_blank">'. |
| 212 | 212 | __('API documentation', 'paylater').'</a>'; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $tableName = $wpdb->prefix.self::LOGS_TABLE; |
| 235 | 235 | $query = "select * from $tableName where createdAt>$from and createdAt<$to order by createdAt desc"; |
| 236 | 236 | $results = $wpdb->get_results($query); |
| 237 | - if (isset($results) && $privateKey == $secretKey) { |
|
| 237 | + if (isset($results) && $privateKey==$secretKey) { |
|
| 238 | 238 | foreach ($results as $key => $result) { |
| 239 | 239 | $response[$key]['timestamp'] = $result->createdAt; |
| 240 | 240 | $response[$key]['log'] = json_decode($result->log); |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $filters = ($data->get_params()); |
| 263 | 263 | $secretKey = $filters['secret']; |
| 264 | - $cfg = get_option('woocommerce_paylater_settings'); |
|
| 264 | + $cfg = get_option('woocommerce_paylater_settings'); |
|
| 265 | 265 | $privateKey = isset($cfg['pmt_private_key']) ? $cfg['pmt_private_key'] : null; |
| 266 | - if ($privateKey != $secretKey) { |
|
| 266 | + if ($privateKey!=$secretKey) { |
|
| 267 | 267 | $response['status'] = 401; |
| 268 | 268 | $response['result'] = 'Unauthorized'; |
| 269 | - } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 269 | + } elseif ($_SERVER['REQUEST_METHOD']=='POST') { |
|
| 270 | 270 | if (count($_POST)) { |
| 271 | 271 | foreach ($_POST as $config => $value) { |
| 272 | 272 | if (isset($this->defaultConfigs[$config]) && $response['status']==null) { |