<?php
require_once __DIR__ . '/../../config/database.php';
require_once __DIR__ . '/../../config/constants.php';
require_once __DIR__ . '/../../includes/functions.php';

apply_cors();

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    send_error('Method not allowed.', 405);
}

$pdo = getDbConnection();
$stmt = $pdo->query(
    'SELECT id, plan_name, price, validity_days, description
     FROM subscriptions WHERE is_active = 1 ORDER BY display_order ASC, price ASC'
);

send_success(['plans' => $stmt->fetchAll()]);
