From 934dda2a73dbc568b3593e7f8b493dd3e07a7782 Mon Sep 17 00:00:00 2001 From: wajih Date: Tue, 19 May 2020 11:33:11 +0400 Subject: [PATCH] log Paytabs messages into separate file --- includes/paytabs_functions.php | 5 +++++ includes/paytabs_payment_methods.php | 14 +++++++------- paytabs-paypage.php | 5 +++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/includes/paytabs_functions.php b/includes/paytabs_functions.php index 3b3b881..e294283 100644 --- a/includes/paytabs_functions.php +++ b/includes/paytabs_functions.php @@ -18,3 +18,8 @@ function woocommerce_paytabs_version_check($version = '3.0') return false; } + +function paytabs_error_log($message) +{ + error_log($message . PHP_EOL, 3, PAYTABS_DEBUG_FILE); +} diff --git a/includes/paytabs_payment_methods.php b/includes/paytabs_payment_methods.php index 8880e25..8172090 100644 --- a/includes/paytabs_payment_methods.php +++ b/includes/paytabs_payment_methods.php @@ -146,7 +146,7 @@ public function process_payment($order_id) ); } else { $_logPaypage = json_encode($paypage); - error_log("PayTabs: create PayPage failed for Order {$order_id}, [{$_logPaypage}]"); + paytabs_error_log("PayTabs: create PayPage failed for Order {$order_id}, [{$_logPaypage}]"); $errorMessage = 'PayTabs could not create PayPage'; try { @@ -172,7 +172,7 @@ private function checkCallback() $this->callback($payment_reference, $orderId); } } else { - error_log("PayTabs: callback failed for Order {$orderId}, payemnt_reference [{$payment_reference}]"); + paytabs_error_log("PayTabs: callback failed for Order {$orderId}, payemnt_reference [{$payment_reference}]"); } } } @@ -191,7 +191,7 @@ public function callback($payment_reference, $order_id) $response = ($result && isset($result->response_code)); if (!$response) { - error_log("PayTabs: callback failed for Order {$order_id}, empty response [{$_logVerify}]"); + paytabs_error_log("PayTabs: callback failed for Order {$order_id}, empty response [{$_logVerify}]"); return; } @@ -199,7 +199,7 @@ public function callback($payment_reference, $order_id) $message = $result->result; if (!isset($result->reference_no)) { - error_log("PayTabs: callback failed for Order {$order_id}, response [{$_logVerify}]"); + paytabs_error_log("PayTabs: callback failed for Order {$order_id}, response [{$_logVerify}]"); wc_add_notice($message, 'error'); // return false; @@ -209,14 +209,14 @@ public function callback($payment_reference, $order_id) $orderId = $result->reference_no; if ($orderId != $order_id) { - error_log("PayTabs: callback failed for Order {$order_id}, Order mismatch [{$_logVerify}]"); + paytabs_error_log("PayTabs: callback failed for Order {$order_id}, Order mismatch [{$_logVerify}]"); return; } $order = wc_get_order($orderId); if (!$order) { - error_log("PayTabs: callback failed for Order {$order_id}, Order not found, response [{$_logVerify}]"); + paytabs_error_log("PayTabs: callback failed for Order {$order_id}, Order not found, response [{$_logVerify}]"); return; } @@ -226,7 +226,7 @@ public function callback($payment_reference, $order_id) // exit; } else { $_logOrder = (json_encode($order->get_data())); - error_log("PayTabs: callback failed for Order {$order_id}, response [{$_logVerify}], Order [{$_logOrder}]"); + paytabs_error_log("PayTabs: callback failed for Order {$order_id}, response [{$_logVerify}], Order [{$_logOrder}]"); $this->orderFailed($order, $message); diff --git a/paytabs-paypage.php b/paytabs-paypage.php index 049cf82..ac07930 100644 --- a/paytabs-paypage.php +++ b/paytabs-paypage.php @@ -8,7 +8,7 @@ * Plugin Name: PayTabs - WooCommerce Payment Gateway * Plugin URI: https://paytabs.com/ * Description: PayTabs is a 3rd party payment gateway. Ideal payment solutions for your internet business. - * Version: 3.1.8 + * Version: 3.1.9 * Author: PayTabs * Author URI: https://paytabs.com/ * Revision Date : 19/April/2020 @@ -21,9 +21,10 @@ //load plugin function when woocommerce loaded add_action('plugins_loaded', 'woocommerce_paytabs_init', 0); -define('PAYTABS_PAYPAGE_VERSION', '3.1.8'); +define('PAYTABS_PAYPAGE_VERSION', '3.1.9'); define('PAYTABS_PAYPAGE_DIR', plugin_dir_path(__FILE__)); define('PAYTABS_PAYPAGE_ICONS_URL', plugins_url("icons/", __FILE__)); +define('PAYTABS_DEBUG_FILE', WP_CONTENT_DIR . "/debug_paytabs.log"); $PAYTABS_PAYPAGE_METHODS = [ 'creditcard' => 'WC_Gateway_Paytabs_Creditcard', 'mada' => 'WC_Gateway_Paytabs_Mada',