<?php
       
	$opBal=getBal($userid);
    $clBal=$opBal+$DebitAmount;
	
	$txnType="Recharge_Refund";
	if(0==chk_dup_wallet_txn($userid,$newrechid,$txnType))
	{
	    $quRefund="INSERT INTO wallet (Date,Time,Userid,OpBal,Txn,ClBal,TxnId,TxnType,TxnWith,Remarks)
	    VALUES ('$date','$time','$userid','$opBal','$DebitAmount','$clBal','$newrechid','Recharge_Refund','$IP','Recharge_Refund')";
	    if(mysqli_query($con,$quRefund))
	    {
	        if(empty($msg))
	        {
	            $Printmsg=$Printmsg;  
	        }
	        else
	        {
	            $Printmsg=$msg;
	        }
	        
    	    $quFailed="UPDATE recharge SET Status='FAILED', ApiBal='$ApiBal', OpId='$Printmsg' WHERE Id='$newrechid'";
	        mysqli_query($con,$quFailed);
	    
		    if($usrType=="API")
		    {
		        $rechStatus = "FAILED";
		        require'../LinkFile/respoApi.php';
		    }
		    else
		    {
		        $respoStatus = "FAILED";
		        $msg         = "Recharge Failed !";
		        require'../LinkFile/respoPanel.php';
		    }
	    }
	}
?>