<?php
session_start();
require_once(__DIR__ . "/../../config/db.php");
require_once(__DIR__ . "/../../session.php");

if (!isset($_POST['trxid'])) {
    http_response_code(400);
    echo 'Transaction ID is required.';
    exit;
}

$trxid = $_POST['trxid'];

$readMessage = "UPDATE transaction SET is_read = 1 WHERE trxid = :trxid AND user_id = :user_id";
$stmt = $db->prepare($readMessage);
$stmt->bindParam(':trxid', $trxid, PDO::PARAM_STR);
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);

if ($stmt->execute()) {
    echo 'Status updated successfully.';
} else {
    http_response_code(500);
    echo 'Failed to update status.';
}
