<?php
header("Content-Type: application/json; charset=UTF-8");
require_once "config.php";

$sql = "SELECT * FROM payment_methods ORDER BY id DESC";
$result = $conn->query($sql);

if ($result && $result->num_rows > 0) {
    $methods = [];
    while ($row = $result->fetch_assoc()) {
        $methods[] = $row;
    }
    echo json_encode([
        "status" => "success",
        "count" => count($methods),
        "data" => $methods
    ]);
} else {
    echo json_encode([
        "status" => "error",
        "message" => "No payment methods found"
    ]);
}

$conn->close();
?>
