<?php
session_start();
header('Content-Type: application/json');
require_once "../includes/functions.php";

$user_id = $_SESSION['user_id'] ?? 0;
$amount  = floatval($_POST['amount'] ?? 0);
$ref  = ($_POST['reference']);

if(!$user_id){
    echo json_encode(["status"=>"error","message"=>"Unauthorized"]);
    exit;
}
if($amount <= 0){
    echo json_encode(["status"=>"error","message"=>"Invalid amount"]);
    exit;
}

$response = requestDeposit($user_id, $amount, $ref);
if ($response["status"] === "success") {
    echo json_encode($response);
} else {
    echo json_encode($response);
}


