<?php

define("IN_SITE", true);

require_once(__DIR__."/../../libs/db.php");
require_once(__DIR__."/../../libs/lang.php");
require_once(__DIR__."/../../libs/helper.php");

$CMSNT = new DB();
 


if ($_SERVER['REQUEST_METHOD'] == 'GET'){
    // Validate trans_id
    $trans_id = validate_alphanumeric($_GET['trans_id'], 32);
    if ($trans_id === false) {
        die(json_encode([
            'status' => 'error',
            'return' => 0
        ]));
    }

    $row = $CMSNT->get_row_safe("SELECT * FROM `invoices` WHERE `trans_id` = ?", [$trans_id]);
    if (!$row) {
        die(json_encode([
            'status' => 'error',
            'return' => 0
        ]));
    }
    
    die(json_encode([
        'status' => display_invoice($row['status']), 
        'return' => $row['status']
    ]));

}
 