<?php

/**
 * Created by PhpStorm.
 * User: Olamide
 * Date: 11/4/2018
 * Time: 12:11 AM
 */
require_once("../includes/initialize.php");
require_once('../includes/config.php');
require_once('../includes/mail.php');
require_once('../includes/mailer.php');
$transId = null;
global $database;

if (!(isset($_GET['transid']))) {
    if (isset($_GET['flag'])) {
        header('location: ../dashboard.php?type=transhistory');

    } else {
        header('location: ../admindash.php');
    }
} else {
     $transId = $_GET['transid'];
    $amount= $_GET['amount'];
  $_SESSION['amount']=$amount;
 
}
  ?>
  

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
 
<script type="text/javascript">

transreference=<?php echo json_encode($transId)?>
amount=<?php echo json_encode($amount)?>

  var settings = {
  "url": "https://webpay.interswitchng.com/collections/api/v1/gettransaction.json?merchantcode=MX78620&transactionreference="+transreference+"&amount="+amount,
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Cookie": "BIGipServerpool_isw_payment_gateway_prod=68035500.49431.0000"
  },
  
  
  };
  
  $.ajax(settings).done(function (response) {
//console.log(response);
 responseCode = response.ResponseCode
 referenceNumber = response.MerchantReference
 ResponseDescription=response.ResponseDescription


 confirmPayment=1
 
 
 $.ajax({
     

                type:"Post",
                url:"confirm_schoolfee.php",
                data:{confirmPayment:confirmPayment,responseCode:responseCode,referenceNumber:referenceNumber,ResponseDescription:ResponseDescription},
                success: function(data){
                  data=$.trim(data);
                  //alert(data);
                location.href="http://eportal.oscotechesaoke.edu.ng/student_portal/dashboard.php?type=transhistory";
                 
              }
             
 })
});
</script>


<?php

?>
