<?php
 session_start();
 require_once('../connect.php');
 require_once('sql_required.php');


 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $id = $_POST['id'];
    $meterpayment_amount = $_POST['meterdevice_amount'];
    $payment_date = $_POST['payment_date'];
    $modeofpay = $_POST['modeofpay'];
    $payment_ref_meter = $_POST['payment_ref_meter'];
    

    $sql = "INSERT INTO `tbl_payments` (`unique_id`, `payment_type`, `amount`, `payment_date`, `receipt_url`, `item_details`, `payment_option`,`referrence_code`) 
            VALUES ('$id', 'MD', '$meterpayment_amount', '$payment_date', 'NA', 'NA', '$modeofpay','$payment_ref_meter')";

    if (mysqli_query($conn, $sql)) {
        echo json_encode(array("statusCode" => 200));
    } else {
        echo json_encode(array("statusCode" => 201, "error" => mysqli_error($conn)));
    }

    mysqli_close($conn);
} else {
    echo json_encode(array("statusCode" => 400, "error" => "Invalid request method"));
}
 ?>