prepare("SELECT email FROM users WHERE id = ?"); $stmt->execute([$user_id]); $user = $stmt->fetch(); if (!$user) { die("User not found."); } $checkout_session = \Stripe\Checkout\Session::create([ 'customer_email' => $user['email'], 'payment_method_types' => ['card'], 'line_items' => [[ 'price' => $priceId, 'quantity' => 1, ]], 'mode' => 'subscription', 'success_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/success.php?session_id={CHECKOUT_SESSION_ID}', 'cancel_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/cancel.php', 'client_reference_id' => $user_id ]); header("HTTP/1.1 303 See Other"); header("Location: " . $checkout_session->url);