<?php
            $opBal=getBal($userid);
		    $clBal=$opBal+$DebitAmount;
		    
			$quRefund="INSERT INTO wallet (Userid,OpBal,Txn,ClBal,TxnType,TxnWith,TxnId,Remarks,Date,Time)
			VALUES ('$userid','$opBal','$DebitAmount','$clBal','RECHARGE_REFUND','SELF','$newrechid','Refund For Failed Recharge','$date','$time')";
			if(mysqli_query($con,$quRefund))
			{
				$refundewalletid=mysqli_insert_id($con);
				
                $query9="UPDATE retailer SET Balance='$clBal' WHERE Userid='$userid'";
				mysqli_query($con,$query9);
				
            	$quFailed="UPDATE recharge SET Creditewalletid='$refundewalletid', Status='FAILED', Operatorid='$Printmsg' where Id='$newrechid'";
			    mysqli_query($con,$quFailed);
						    									
				$deleteComm="DELETE FROM commwallet WHERE Rechargeid='$newrechid'";
				mysqli_query($con,$deleteComm);
				
				$error_msg="Your Recharge Has Been Failed !";
	            echo "<div class='msg-div'>
			        <form method='post'>
				        <h3>".$error_msg."</h3><br>
				        <i class='fa fa-ban' aria-hidden='true' id='NotokIcon'></i><br><br>
				        <button type='submit' class='btnPopup'>OK</button><br><br>
			        </form>
		        </div>";
			}

?>