![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/.cursor-server/data/User/History/-2e1c70d1/ |
<?php
session_start();
require_once 'config/database.php';
if (!isset($_SESSION['user_id'])) {
die('Not logged in');
}
$pdo = getDBConnection();
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
echo "<h1>Payment Methods Debug</h1>";
echo "<p><strong>User ID:</strong> " . $_SESSION['user_id'] . "</p>";
echo "<p><strong>User Name:</strong> " . $user['name'] . "</p>";
echo "<p><strong>Stripe Customer ID:</strong> " . ($user['stripe_customer_id'] ?? 'NULL') . "</p>";
if (!empty($user['stripe_customer_id'])) {
$stripe_secret = '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';
$customer_id = $user['stripe_customer_id'];
echo "<h2>Fetching Payment Methods from Stripe</h2>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com/v1/payment_methods?customer=$customer_id&type=card");
curl_setopt($ch, CURLOPT_USERPWD, $stripe_secret . ":");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>HTTP Code:</strong> $http_code</p>";
echo "<p><strong>Response:</strong></p>";
echo "<pre>" . htmlspecialchars($response) . "</pre>";
$payment_data = json_decode($response, true);
$payment_methods = $payment_data['data'] ?? [];
echo "<h2>Payment Methods Found: " . count($payment_methods) . "</h2>";
if (!empty($payment_methods)) {
echo "<ul>";
foreach ($payment_methods as $pm) {
echo "<li>";
echo "<strong>ID:</strong> " . $pm['id'] . "<br>";
echo "<strong>Brand:</strong> " . $pm['card']['brand'] . "<br>";
echo "<strong>Last 4:</strong> " . $pm['card']['last4'] . "<br>";
echo "<strong>Exp:</strong> " . $pm['card']['exp_month'] . "/" . $pm['card']['exp_year'] . "<br>";
echo "</li>";
}
echo "</ul>";
} else {
echo "<p>No payment methods found.</p>";
}
} else {
echo "<p><strong>No Stripe Customer ID found!</strong></p>";
}
echo "<p><a href='/account_settings.php?tab=payment'>Back to Account Settings</a></p>";
?>