<?php
//$ref=$_POST['tx_ref'];
$ref='439570506';
$clientId = "portal.niqs.org.ng";
$secretKey = "E7VELRHBJ6FWKE2ZK861L4F5HDKCDY";

// perform sha512 hash
$hashValue = hash('sha512',($ref.$secretKey));

// interswitch webservice url remember to add the saved transaction reference variable
//$url ="https://stageserv.interswitchng.com/quicktellercheckout/api/v2/transaction.json?transRef=$ref";
$url ="https://paywith.quickteller.com/api/v2/transaction.json?transRef=$ref";

// append the header putting the secret key and hash
$headers = array(
    "GET /HTTP/1.1",
    "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1",
    "Content-type: text/xml;charset=\"utf-8\"",
    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",            "Accept-Language: en-us,en;q=0.5",
    "Accept-Encoding: gzip,deflate",
    "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
    "Keep-Alive: 300",
    "Connection: keep-alive",
    "clientid: $clientId",
    "Hash: $hashValue" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$data = curl_exec($ch);
if (curl_errno($ch)) {
    print "Error: " . curl_error($ch);
}
else {
    // Show me the result
    $json = json_decode($data, TRUE);
    //var_dump($data);
    curl_close($ch);
    print_r($json);

    // you can perform simple if else to interpret the printed json result in your UI
    // bye bye
}?>
<div>
    <h1>Query Transaction Result</h1>
    <br/><br/><br/>
<?php
echo("Response Code = ".$json['ResponseCode'].", Response Description = ".$json['ResponseDescription'].", Amount = ".$json['Amount'].", Payment Reference = ".$json['PaymentReference'].", Transaction Date = ".$json['TransactionDate']);
?>