Skip to content

Commit

Permalink
log Paytabs messages into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
wajihkm committed May 19, 2020
1 parent 0891118 commit 934dda2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 5 additions & 0 deletions includes/paytabs_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
14 changes: 7 additions & 7 deletions includes/paytabs_payment_methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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}]");
}
}
}
Expand All @@ -191,15 +191,15 @@ 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;
}

$success = $result->response_code == 100;
$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;
Expand All @@ -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;
}

Expand All @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions paytabs-paypage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: PayTabs - WooCommerce Payment Gateway
* Plugin URI: https://paytabs.com/
* Description: PayTabs is a <strong>3rd party payment gateway</strong>. 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
Expand All @@ -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',
Expand Down

0 comments on commit 934dda2

Please sign in to comment.