diff --git a/quiztech-assessment-platform.php b/quiztech-assessment-platform.php index 1be21cc..93ba753 100644 --- a/quiztech-assessment-platform.php +++ b/quiztech-assessment-platform.php @@ -307,37 +307,4 @@ function quiztech_register_rest_routes() { 'permission_callback' => '__return_true' // Allow public access - Stripe needs to reach this ) ); } -add_action( 'rest_api_init', 'quiztech_register_rest_routes' ); - -/** - * Basic logging function for debugging. Allows passing of an object or array for the $data paramater - * - * Set the CUSTOM_DEBUG_LOG file in wp-config.php - * - */ -function log_to_file2($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"); - - // 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 +add_action( 'rest_api_init', 'quiztech_register_rest_routes' ); \ No newline at end of file diff --git a/src/Gateways/StripeGateway.php b/src/Gateways/StripeGateway.php index 6e28677..5648b01 100644 --- a/src/Gateways/StripeGateway.php +++ b/src/Gateways/StripeGateway.php @@ -1,7 +1,3 @@ - - - - ['card'], @@ -101,11 +104,22 @@ class StripeGateway { // Redirect to Stripe Checkout if ( isset( $session->url ) ) { - log_to_file2('StripeGateway::initiatePayment - Session created. Redirecting to: ' . $session->url); - error_log("Quiztech StripeGateway: Attempting redirect to Stripe URL: " . $session->url); + $log_message_redirect = "Quiztech StripeGateway: Attempting redirect to Stripe URL: " . $session->url; + if (function_exists('log_to_file')) { + log_to_file($log_message_redirect); + } else { + error_log($log_message_redirect); + } + wp_safe_redirect( $session->url ); + // If execution reaches here, exit() failed or was bypassed. - error_log("Quiztech StripeGateway: CRITICAL - Execution continued after wp_safe_redirect and before exit()."); + $log_message_critical = "Quiztech StripeGateway: CRITICAL - Execution continued after wp_safe_redirect and before exit()."; + if (function_exists('log_to_file')) { + log_to_file($log_message_critical); + } else { + error_log($log_message_critical); + } exit; } else { return new WP_Error( 'stripe_session_error', __( 'Could not create Stripe Checkout session.', 'quiztech' ) );