<?php
// File: API_KONEKSI/pembayaran/get_metode.php
header('Content-Type: application/json');
include '../config/koneksi.php';

$metode_id = $_GET['metode_id'] ?? '';

if (empty($metode_id)) {
    echo json_encode(["status" => "gagal", "pesan" => "ID Metode tidak valid", "data" => []]);
    exit;
}

$query = "SELECT tipe_metode, nama_metode, rekening_no, atas_nama, qris_gambar FROM mst_metode_bayar WHERE metode_id = ? AND active_st = 1";
$stmt = $conn->prepare($query);
$stmt->bind_param("s", $metode_id);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc()) {
    echo json_encode(["status" => "sukses", "pesan" => "Data ditemukan", "data" => [$row]]);
} else {
    echo json_encode(["status" => "gagal", "pesan" => "Metode pembayaran tidak ditemukan", "data" => []]);
}
$stmt->close();
$conn->close();
?>