<?php
ob_start();session_start();
require_once('includes/initialize.php');

include 'remita_constants.php';

$rrr=$_POST["rrr"];

$bank_transactions = StudentAcct::get_transaction_bank_details($rrr);

if ($bank_transactions->formno=='PU'){
   $totalAmount = "2645"; 
   $servicetypeid = StudentAcct::getcredentials(1);
   $servicetypeid=$servicetypeid->serviceTypeId;
}else{
   $totalAmount = "15645"; 
   $servicetypeid = StudentAcct::getcredentials(2);
   
   $servicetypeid=$servicetypeid->serviceTypeId;
}


$orderId=$bank_transactions->orderId;

//echo "RRR from Bank response: ".$rrr.': ORDER ID: '.$orderId;
$output='';
  $output = remita_transaction_details($rrr);
 
 echo json_encode($output);
 

function remita_transaction_detailsyyyy($rrr,$orderId){
    $mert =  "";
    $api_key = "";
    $mode = "Live";
    
    $hash_string = MERCHANTID . $servicetypeid . $orderID . $totalAmount . APIKEY;
$hash = hash('sha512', $hash_string);
    
    
     $hash_string = $orderId . APIKEY . MERCHANTID;
    $hash = hash('sha512', $hash_string);
    if( $mode == 'Test' ){
        $query_url = 'http://remitademo.net/remita/exapp/api/v1/send/api/echannelsvc';
        }
    else if( $mode == 'Live' ){
        $query_url = 'https://login.remita.net/remita/exapp/api/v1/send/api/echannelsvc';
        }
     $url    = $query_url . '/' . MERCHANTID  . '/' . $rrr . '/' . $hash . '/' . 'status.reg';
    $result = file_get_contents($url);
    $response = json_decode($result, true);
    return $response;
} 





function remita_transaction_details($rrr){
    $mert =  "";
    $api_key = "";
    $mode = "Live";
     $hash_string = $rrr. APIKEY . MERCHANTID;
    $hash = hash('sha512', $hash_string);
    if( $mode == 'Test' ){
        $query_url = 'http://www.remitademo.net/remita/exapp/api/v1/send/api/echannelsvc';
        }
    else if( $mode == 'Live' ){
        $query_url = 'https://login.remita.net/remita/exapp/api/v1/send/api/echannelsvc';
        }
    $url    = $query_url . '/' . MERCHANTID  . '/' . $rrr . '/' . $hash . '/' . 'status.reg';
    $result = file_get_contents($url);
    $response = json_decode($result, true);
    return $response;
}

?>