diff --git a/quiztech-assessment-platform.php b/quiztech-assessment-platform.php index e2a7b91..f2c7e6d 100644 --- a/quiztech-assessment-platform.php +++ b/quiztech-assessment-platform.php @@ -315,29 +315,29 @@ add_action( 'rest_api_init', 'quiztech_register_rest_routes' ); * Set the CUSTOM_DEBUG_LOG file in wp-config.php * */ -function log_to_file($message, $data = false){ - // Only proceed if a message is provided - if ($message) { - // Check if the custom log file constant is defined - if (defined('CUSTOM_DEBUG_LOG') && CUSTOM_DEBUG_LOG) { - $log_File = CUSTOM_DEBUG_LOG; +// function log_to_file($message, $data = false){ +// // Only proceed if a message is provided +// if ($message) { +// // Check if the custom log file constant is defined +// if (defined('CUSTOM_DEBUG_LOG') && CUSTOM_DEBUG_LOG) { +// $log_File = CUSTOM_DEBUG_LOG; - $date = new DateTime(); - $date = $date->format("Y/m/d h:i:s"); +// $date = new DateTime(); +// $date = $date->format("Y/m/d h:i:s"); - // Convert arrays and objects to JSON format - if (is_array($data) || is_object($data)) { - $data = json_encode($data, JSON_PRETTY_PRINT); - $message = $message . "\r\n" . $data; - } else if ($data) { - $message = $message . " " . $data; - } +// // Convert arrays and objects to JSON format +// if (is_array($data) || is_object($data)) { +// $data = json_encode($data, JSON_PRETTY_PRINT); +// $message = $message . "\r\n" . $data; +// } else if ($data) { +// $message = $message . " " . $data; +// } - // Log the message to the specified file - error_log("[$date] " . $message ."\r\n", 3, $log_File); - } - // If CUSTOM_DEBUG_LOG is not defined, do nothing (fail silently) - // Alternatively, could log to default PHP error log: - // else { error_log("Quiztech Debug: " . $message); } - } -} \ No newline at end of file +// // Log the message to the specified file +// error_log("[$date] " . $message ."\r\n", 3, $log_File); +// } +// // If CUSTOM_DEBUG_LOG is not defined, do nothing (fail silently) +// // Alternatively, could log to default PHP error log: +// // else { error_log("Quiztech Debug: " . $message); } +// } +// } \ No newline at end of file diff --git a/src/Includes/payments.php b/src/Includes/payments.php index 359eef8..a9bbcf7 100644 --- a/src/Includes/payments.php +++ b/src/Includes/payments.php @@ -25,7 +25,7 @@ if ( ! \defined( 'WPINC' ) ) { * @return mixed Gateway-specific response (e.g., redirect URL, session ID) or WP_Error on failure. */ function quiztech_initiate_credit_purchase( $user_id, $item_id, $quantity = 1 ) { -log_to_file("quiztech_initiate_credit_purchase - 1"); +\log_to_file("quiztech_initiate_credit_purchase - 1"); // 1. Validate input if ( ! $user_id || ! \get_user_by( 'ID', $user_id ) ) { return new \WP_Error( 'invalid_user', \__( 'Invalid user ID provided.', 'quiztech' ) ); @@ -38,7 +38,7 @@ log_to_file("quiztech_initiate_credit_purchase - 1"); return new \WP_Error( 'invalid_quantity', \__( 'Quantity must be at least 1.', 'quiztech' ) ); } - log_to_file("quiztech_initiate_credit_purchase - 2"); + \log_to_file("quiztech_initiate_credit_purchase - 2"); // 2. Get Item Details (Using hardcoded packages for now, mirroring the theme) // TODO: Move credit packages to a filterable array or WP options for better management. $credit_packages = array( @@ -59,7 +59,7 @@ log_to_file("quiztech_initiate_credit_purchase - 1"); // Convert price to cents for Stripe $price_in_cents = (int) ( (float) $price_decimal * 100 ); - log_to_file("quiztech_initiate_credit_purchase - 3"); + \log_to_file("quiztech_initiate_credit_purchase - 3"); // 3. Get Active Gateway // TODO: Read active gateway from plugin settings (e.g., get_option('quiztech_settings')['payment_gateway']) $active_gateway = 'stripe'; // Placeholder @@ -71,7 +71,7 @@ log_to_file("quiztech_initiate_credit_purchase - 1"); } $gateway = new StripeGateway(); - log_to_file("quiztech_initiate_credit_purchase - 4"); + \log_to_file("quiztech_initiate_credit_purchase - 4"); // 4. Prepare Metadata for Stripe and Webhook $metadata = [ 'user_id' => $user_id, @@ -83,12 +83,12 @@ log_to_file("quiztech_initiate_credit_purchase - 1"); 'transaction_type'=> 'credit_purchase', // Identify the transaction type ]; - log_to_file("quiztech_initiate_credit_purchase - 5"); + \log_to_file("quiztech_initiate_credit_purchase - 5"); // 5. Call Gateway's initiatePayment method $result = $gateway->initiatePayment( $user_id, $item_id, $quantity, $price_in_cents, $currency, $metadata ); - log_to_file("quiztech_initiate_credit_purchase - Result: ", $result); + \log_to_file("quiztech_initiate_credit_purchase - Result: ", $result); // The gateway method should handle the redirect on success or return WP_Error return $result; }