<?php
	error_reporting(0);
	define('INCLUDE_CHECK',true);
	session_start();
	require ('classes/config.php');
	
	if($_SESSION['txn_ref']=="") {
		header("location: index.php?action=pay_method");	
	}
	
	 $sql = mysql_query("SELECT * FROM tranzact_t WHERE txn_ref='$_SESSION[txn_ref]' AND status='UNPAID' LIMIT 1");			
	 		while($srows = mysql_fetch_array($sql)){
			
				$fullname = $srows['surname']. " " . $srows['othername'] ; 
				$courses = $srows['department'];
				$email = $srows['email'];
				$phone = $srows['phone'];
				$level = $srows['level'];
				$fno = $srows['fno'];
				$txn_ref = $srows['txn_ref'];
				$amount_fetch = preg_replace("/\.?0*$/",'',$srows['amount']);
				$overhead = preg_replace("/\.?0*$/",'',$srows['overhead']);
				$txn_fee = preg_replace("/\.?0*$/",'',$srows['txn_fee']);
				$amount = $amount_fetch + $overhead + $txn_fee;
				$amounts = $amount * 100;
				//$overheads = $overhead * 100;
				$faculty = $srows['faculty'];
				$session = $srows['session'];
			}
                        if ($overhead == "0"){$overheads = ($overhead * 100) and $ict_overheads = 0 * 100;}
			if ($overhead != "0"){$overheads = (($overhead - 150) * 100) and $ict_overheads = 150 * 100;}
$_SESSION['email'] = $email ;
$_SESSION['surname'] = $fullname;
$_SESSION['amt4hash']= $amounts;				
$product_id = 6925;
$pay_item_id= 101;
$cur = 566;
$mackey = "4D7826760C772D0AEBFA4141ECAD80E73B74347E017F6FDDF18E0AD8C68D91DFA7131319D072709A44ABFCB74E4CFC0B6D6E4E82C9C0D0D35CDE4ABC48E80C27";
$ash_codes= ($txn_ref . $product_id.  $pay_item_id . $amounts . "http://eportal.oscotechesaoke.edu.ng/collegepayment/index.php?action=web_service_feedback" . $mackey);
$ash_code= hash('sha512',$ash_codes);
//echo "Session Details:";	print_r($_SESSION);	
?>


       		<div class="rightp">
            	<h1>Payment Verification</h1>
                <div class="kontent">
           
                <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12">
                                    <code>You can Copy/Print this Transaction Number for future reference</code> <br /><br />
                                    <p class="btn btn-primary">Your Transaction Reference No:</p> <span class="btn btn-warning"><?php echo $txn_ref ?></span><br /><br />
                                <div class="well" style="background:#FFF">
 
 
<table class="table table-bordered table-hover">
  <tr>
    <td align="right"><strong>Full Name:</strong></td>
    <td><?php echo $fullname ?></td>
    <td align="right"><strong>FormNo/MatricNo:</strong></td>
    <td><?php echo $fno ?></td>
  </tr>
  <tr>
    <td align="right"><strong>Faculty:</strong></td>
    <td><?php echo $faculty ?></td>
    <td align="right"><strong>Department:</strong></td>
    <td><?php echo $courses ?></td>
  </tr>
 <tr>
    <td align="right"><strong>Level:</strong></td>
    <td><?php echo $level ?></td>
     <td align="right"><strong>Phone:</strong></td>
    <td><?php echo $phone ?></td>
  </tr>  
  <tr>
  <tr>
    <td align="right"><strong>Email:</strong></td>
    <td width="814"><?php echo $email ?></td>
     <td align="right"><strong>Session:</strong></td>
    <td width="814"><?php echo $session ?></td>
  </tr>  
  <tr>
  	 <td  colspan="4"><h1>Total Amount: <?php echo number_format($amount,2) ?></h1></td> 
  </tr>
</table>
  <p><strong>NOTE</strong>: The Total Amount of <strike>N</strike><?php echo number_format($amount,2)?>  will be deducted from your account. Thanks</p>    
</div>
<form name="form1" action= "https://webpay.interswitchng.com/paydirect/pay" method="post">
<input name="product_id" type="hidden" value="<?php echo $product_id; ?>" />
<input name="cust_id" type="hidden" value="<?php echo $fno; ?>" />
<input name="cust_name" type="hidden" value="<?php echo $fullname; ?>" />
<input name="pay_item_id" type="hidden" value="<?php echo $pay_item_id; ?>" />
<input name="pay_item_name" type="hidden" value="OSCOTECH Payment" />
<input name="amount" type="hidden" value="<?php echo $amounts; ?>" />
<input name="currency" type="hidden" value="<?php echo $cur; ?>" />
<input name="site_redirect_url" type="hidden" value="http://eportal.oscotechesaoke.edu.ng/collegepayment/index.php?action=web_service_feedback"/>
<input name="site_name" type="hidden" value="http://oscotechesaoke.edu.ng"/>
<input name="txn_ref" type="hidden" value="<?php echo $_SESSION['txn_ref']; ?>" />
<input name="hash" type="hidden" value="<?php echo $ash_code; ?>" />
<input name="payment_params" type="hidden" value="college_split"/>
<input name="xml_data" type="hidden" value=
                   '<payment_item_detail>
			  	<item_details detail_ref="<?php echo $_SESSION['txn_ref']; ?>" college="OSCOTECH" department="<?php echo $courses; ?>" faculty="<?php echo $faculty; ?>">
              		<item_detail item_id="1" item_name="ict overhead fees" item_amt="<?php echo $ict_overheads; ?>" bank_id="76" acct_num="0284122013" />
                       <item_detail item_id="2" item_name="overhead fees" item_amt="<?php echo $overheads; ?>" bank_id="76" acct_num="0213965027" /> 
              <?php
			  		$sql=mysql_query("SELECT * FROM tranzact_t_items WHERE txn_ref='{$_SESSION['txn_ref']}'");
					
					$i=2;
					while($rowt=mysql_fetch_array($sql)){
						$fees_description =$rowt['fees_description'];
						$amountt = preg_replace("/\.?0*$/",'',$rowt['amount']);
						$amountp = $amountt * 100;
					$i++;
				?>
			  		<item_detail item_id="<?php echo $i;?>" item_name="<?php echo $fees_description;?>" item_amt="<?php echo $amountp; ?>" bank_id="76" acct_num="0213965027" />
                 <?php	
							}														
							?>   
			   </item_details> 
               
            </payment_item_detail>'/>
<a href="index.php?action=payment_processing" class="btn btn-default" >BACK</a>
<input type="submit" name="submit" class="btn btn-danger" value="PAY NOW" /> 
<input type="button" name="print" class="btn btn-success" value="PRINT" /> 
</form>

                
                </div>
            </div>
        </div><!-- content -->    
        
