<?php include('Crypto.php');
include('API.php');
?>
<?php require_once 'config.php';
require('../lib/dbclass.php');
?>
<?php
error_reporting(0);





$workingKey    = CCA_WORKING_KEY; // Working Key should be provided here.
$encResponse   = $_POST ['encResp']; // This is the response sent by the CCAvenue Server
$rcvdString    = decryption($encResponse, $workingKey); // Crypto Decryption used as per the specified working key.
$order_status  = '';
$decryptValues = explode('&', $rcvdString);
$dataSize      = sizeof($decryptValues);
for ($i = 0; $i < $dataSize; $i++) {
    $information                          = explode('=', $decryptValues [$i]);
    $Transaction_idMap [$information [0]] = $information [1];
}
$order_status   = $Transaction_idMap ['order_status'];
$Transaction_id = 0;



if ($order_status == 'Success' || $orderStatus == 'Shipped') {
    $Transaction_id  = $Transaction_idMap['bank_ref_no'];
    $order_id        = $Transaction_idMap['order_id'];
    $order_time      = new DateTime($Transaction_idMap['order_date_time']);
    $order_date_time = $order_time->format('Y-m-d H:i:s');
    updateQuery("update tbl_transaction set Transid='$Transaction_id',Received=Amount,is_Razor_payment_gateway=0,dateadded='$order_date_time' WHERE orderid='$order_id'");
}













?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Web Page</title>
</head>
<body>
    <?php
    if ($Transaction_id > 0) {
        ?>
     
<script>
spge = '<?php echo $Transaction_id ;?>';


// Simulating a JSON object sent to Flutter
const jsonData = JSON.stringify({
  Status: "True",
  data: "'+spge +'"
});

// Call the Flutter handler
window.flutter_inappwebview.callHandler('Android.sendJsonData',jsonData);
       


</script>
    <?php
    } else {
        ?>
     <script>
      
       

       
       // Simulating a JSON object sent to Flutter
const jsonData = JSON.stringify({
  Status: "false",
  data: "0"
});

// Call the Flutter handler
window.flutter_inappwebview.callHandler('Android.sendJsonData',jsonData);
    </script>
   <?php
    }
?>
</body>
</html>




