<?php
// card-response.php
$logFile = __DIR__ . "/incoming_data3.txt";

$timestamp = date("Y-m-d H:i:s");
$rawInput = file_get_contents("php://input");

$data = [
    "GET"  => $_GET,
    "POST" => $_POST,
    "RAW"  => $rawInput
];

// Basic log header
$entry  = "============================\n";
$entry .= $_GET['jobid'];
$entry .= "Date: $timestamp\n";
$entry .= "============================\n";
$entry .= "REQUEST DUMP:\n";
$entry .= print_r($data, true);
$entry .= "\n";
$r = rand(10000,90000);



if (trim(file_get_contents('gateway_status.txt')) !== 'ON') {
    $res=array(
    "status"=>'failed',
    "ref"=>23423233,
    "transid"=>$r
    );   
}else{
    
    $res=array(
    "status"=>'success',
    "ref"=>23423233,
    "transid"=>$r
    );
    
}




echo(json_encode($res));

file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX);