<?php
/**
 * check_verification_status.php
 * Deposit Page থেকে বার বার (Poll করে) জিজ্ঞেস করা হয় —
 * "এই TrxID কি এখনো Verify হয়েছে?"
 */
include "../serive/samparka.php";
header('Content-Type: application/json; charset=utf-8');

$trxid = trim(mysqli_real_escape_string($conn, $_GET['trxid'] ?? ''));

if ($trxid === '') {
    echo json_encode(['verified' => false]);
    exit;
}

$stmt = $conn->prepare("SELECT status, verified_amount FROM pending_verifications WHERE trxid = ? LIMIT 1");
$stmt->bind_param("s", $trxid);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    echo json_encode(['verified' => false]);
    exit;
}

$row = $result->fetch_assoc();

if ($row['status'] === 'verified') {
    echo json_encode(['verified' => true, 'amount' => $row['verified_amount']]);
} else {
    echo json_encode(['verified' => false]);
}
