<?php

session_start(); 
$strJsonFileContents = file_get_contents("config.json");
$array = json_decode($strJsonFileContents, true);
$paymentID = $_GET['paymentID'];
$proxy = $array["proxy"];
$uri = $array["queryURL"].$paymentID;
$url = curl_init($uri);

$header=array(
    'Content-Type:application/json',
    'authorization:'.$_SESSION['token'],
    'x-app-key:'.$array["app_key"]              
);	
    
curl_setopt($url,CURLOPT_HTTPHEADER, $header);
curl_setopt($url,CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($url,CURLOPT_RETURNTRANSFER, true);
curl_setopt($url,CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($url, CURLOPT_PROXY, $proxy);

$resultdatax=curl_exec($url);
curl_close($url);
echo $resultdatax;  

$logData = [
    "API Title" => "Query Payment",
    "API URL" => stripslashes($uri),
    "Request Timestamp" => date('Y-m-d\TH:i:s.Z')."Z",
    "Header" => $header,
    "Body" => null,
    "API Response" => json_decode($resultdatax, true)
];

writeLog("bKash", $logData);

function writeLog($logName, $logData){
    file_put_contents("Logs/".$logName."_".date("Y-m-d_H").".json","\n============== ".date("Y-m-d H:i:s")." ==============\n".json_encode($logData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), FILE_APPEND);
}
?>
