![]() 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/domains/soundstudiopro.com/public_html/ |
<?php
/**
* DIRECT FIX: Match Stripe prices to plans and update config
*/
session_start();
require_once 'config/database.php';
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
die("Admin access required");
}
$stripe_secret = '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';
$plans_config = require __DIR__ . '/config/subscription_plans.php';
// Get ALL prices from Stripe
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.stripe.com/v1/prices?limit=100&type=recurring');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $stripe_secret]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$prices_data = json_decode($response, true);
$price_map = []; // amount => price_id
if (isset($prices_data['data'])) {
foreach ($prices_data['data'] as $price) {
$amount = $price['unit_amount'] / 100;
$price_map[(string)$amount] = $price['id'];
}
}
// Match plans to prices
$updates = [];
foreach ($plans_config as $plan_key => $plan) {
$expected_amount = (string)$plan['price'];
if (isset($price_map[$expected_amount])) {
$updates[$plan_key] = $price_map[$expected_amount];
}
}
// Update config file
$config_file = __DIR__ . '/config/subscription_plans.php';
$config_content = file_get_contents($config_file);
foreach ($updates as $plan_key => $price_id) {
// Replace the stripe_price_id for this specific plan
$pattern = "/('{$plan_key}'\s*=>\s*\[[^\]]*'stripe_price_id'\s*=>\s*['\"])[^'\"]*(['\"])/s";
$replacement = "$1{$price_id}$2";
$config_content = preg_replace($pattern, $replacement, $config_content, 1);
}
file_put_contents($config_file, $config_content);
echo "✅ Config updated!<br><br>";
echo "Updated plans:<br>";
foreach ($updates as $plan_key => $price_id) {
$plan = $plans_config[$plan_key];
echo "{$plan['name']} (\${$plan['price']}) → {$price_id}<br>";
}
// Show what's missing
$missing = [];
foreach ($plans_config as $plan_key => $plan) {
if (!isset($updates[$plan_key])) {
$missing[] = "{$plan['name']} (\${$plan['price']})";
}
}
if (!empty($missing)) {
echo "<br>⚠️ Missing prices (need to create in Stripe):<br>";
foreach ($missing as $m) {
echo "{$m}<br>";
}
}