<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
 
                 
                        
                       
                         
                            $stmt=$conn->prepare("insert into  test (name) values(:name)  ");  
                            $stmt->bindValue(':name', json_encode($_POST) , PDO::PARAM_STR);
                            $stmt->execute();   
                        
                       
                        
                                        
                			if(isset($_POST['PssSub']))
                			{    
                			  
                                $myIdset = $_POST['PyId'];  
                			    if($_POST['type']==1)
                			    {
                			         
                                        $stmt=$conn->prepare("select  * from  UI__TxnFailUsers where id=:id  ");  
                                        $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);
                                        $stmt->execute(); 
                                        $Mydetails = $stmt->fetch(PDO::FETCH_OBJ);
                                        $userId = $Mydetails->custId;
                                         
                                        
                                        
                                        $stmt =  $conn->prepare("select phm,eml from  UI__Rgst  where  cuurentId=:cuurentId     ");   
                                        $stmt->bindValue(':cuurentId', $Mydetails->custId, PDO::PARAM_STR); 
                                        $stmt->execute();  
                                        $phm = $stmt->fetch(PDO::FETCH_OBJ);   
                                        
                                        
                                        $stmt =  $conn->prepare("select accName from  UI__AddAccount  where  custId=:custId  and accno=:accno and  ifsc=:ifsc   ");   
                                        $stmt->bindValue(':custId', $Mydetails->custId, PDO::PARAM_STR);
                                        $stmt->bindValue(':accno', $Mydetails->accno , PDO::PARAM_STR);
                                        $stmt->bindValue(':ifsc', $Mydetails->ifsc , PDO::PARAM_STR);
                                        $stmt->execute(); 
                                        $AccDetails = $stmt->fetch(PDO::FETCH_OBJ); 
                                        
                                             
                                        $client_id = mt_rand(100000, 999999);
                                        $amount=round($Mydetails->amt-$deduction);
                                        $beneficiary_accountno =  $Mydetails->accno;
                                        $beneficiary_name =  $AccDetails->accName;  
                                        $beneficiary_ifsc = $Mydetails->ifsc;
                                 
                                        
                                        $mobile_number = $phm->phm;
                                        $amount = $amount;
                                        $email = $phm->eml;
                                        $beneficiary_name = $beneficiary_name;
                                        $account_number = $beneficiary_accountno;
                                        $beneficiary_ifsc = $Mydetails->ifsc;
                                        $channel_id = 2;
                                        $client_id = $client_id;
                                        $provider_id = 143;  
                                       

                			    }else
                			    if( ($_POST['type']==2) || ($_POST['type']==3) )
                			    {
                			        
                                    
                                        $stmt =  $conn->prepare("select * from  UI__TxnFailUsersPay2   where  id=:id     ");   
    									$stmt->bindValue(':id', $myIdset , PDO::PARAM_STR); 
    									$stmt->execute();  
    									$UI__TxnFailUsersPay2 = $stmt->fetch(PDO::FETCH_OBJ); 
    									$userId = $UI__TxnFailUsersPay2->custId;
    									
    									  
    									
    									$stmt =  $conn->prepare("select * from  UI__Rgst   where  cuurentId=:cuurentId     ");   
    									$stmt->bindValue(':cuurentId', $UI__TxnFailUsersPay2->custId , PDO::PARAM_STR); 
    									$stmt->execute();  
    									$phm = $stmt->fetch(PDO::FETCH_OBJ);   
    									
    								 
									          
    								    $stmt =  $conn->prepare("select * from  UI__AddAccount  where  custId=:custId  and accno=:accno and  ifsc=:ifsc   ");   
										$stmt->bindValue(':custId', $UI__TxnFailUsersPay2->custId , PDO::PARAM_STR);
										$stmt->bindValue(':accno', $UI__TxnFailUsersPay2->accno , PDO::PARAM_STR);
										$stmt->bindValue(':ifsc', $UI__TxnFailUsersPay2->ifsc , PDO::PARAM_STR);
    									$stmt->execute(); 
    									$AccDetails = $stmt->fetch(PDO::FETCH_OBJ);  
    									
    							        
                                
                                        $amount = ($UI__TxnFailUsersPay2->amt-$deduction) ; 
                                        $mobile_number = $phm->phm;
                                        $amount = $amount;
                                        $email = $phm->eml;
                                        $beneficiary_name =  $AccDetails->accName;   
                                        $account_number = $AccDetails->accno;
                                        $beneficiary_ifsc = $AccDetails->ifsc;
                                        $beneficiary_accountno =  $account_number;
                                        
                                   
                                        $channel_id = 2;
                                        $client_id = mt_rand(100000, 999999);  
                                        $provider_id = 143;  
                                    
                			    }
                			    
                			   
                			    
                               
                			     
                			    if(trim($_POST['pdddF'])=="Ram2008#")
                			    { 
                			       
                			        
                                    $stmt=$conn->prepare("select *  from UI__UpiManage   where typ=2");  
                                    $stmt->execute();      
                                    $RstUxd = $stmt->fetch(PDO::FETCH_OBJ); 
                                    
                                    
                           
                                
                                    if($_POST['payselect']==1)
                                    {   
                                        
                                        
                                        $Remail =  "dailypay2024@gmail.com";
                                        $Rd =  "gp6ZiH";  
                                        $access_token = '{"email":"'.$Remail.'","password":"'.$Rd.'"}'; 
                                        $ch = curl_init('https://erp.pay2all.in/api/token'); 
                                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                                        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                                        'x-tera-tenant-region: IN', 
                                        'Content-Type: application/json', 
                                        'Content-Length: ' . strlen($access_token))                                                                       
                                        );       																		 
                                        $response = curl_exec($ch); 
                                        $json_response = json_decode($response);    
                                        $RechargeAccess_token = $json_response->token; 
                                       
												    
                                        $data_string = '{"mobile_number": "'.$phm->phm.'","amount": "'.$amount.'","beneficiary_name": "'.$beneficiary_name.'","account_number": "'.$beneficiary_accountno.'","ifsc": "'.$beneficiary_ifsc.'","client_id": "'.$client_id.'","provider_id": "160","wallet_id":"0"}';      
                                        
                                        
                                    
                            
                                           
                                        $ch = curl_init();
                                        curl_setopt($ch, CURLOPT_URL, 'https://erp.pay2all.in/api/v1/payout/bank_transfer');
                                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
                                        curl_setopt($ch, CURLOPT_POST, 1);
                                        $headers = array();
                                        $headers[] = "Accept: application/json";
                                        $headers[] = "Authorization: Bearer ".$RechargeAccess_token;
                                        $headers[] = "Content-Type: application/json";
                                        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                                        $res = curl_exec($ch);  
                                        
                                        $stmt=$conn->prepare("insert into UI__MoneY(Uid,request,response,Tdate) values(:Uid,:request,:calBack,:Tdate)"); 
                                        $stmt->bindValue(':Uid',  $userId , PDO::PARAM_STR);    
                                        $stmt->bindValue(':request', $data_string , PDO::PARAM_INT);    
                                        $stmt->bindValue(':calBack', $res , PDO::PARAM_INT);    
                                        $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);     
                                        $stmt->execute(); 

                                        $Data = json_decode($res); 
                                        
                                        if(!empty($Data->report_id))
                                            $report_id = $Data->report_id;
                                        else
                                            $report_id = "NA";  
                                            
                                         if($_POST['type']==1)
                                          {
                                                $stmt=$conn->prepare("update UI__TxnFailUsers set   client_id=:client_id  where id=:id  ");  
                                                $stmt->bindValue(':client_id', $client_id , PDO::PARAM_STR); 
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();    
                                              
                                          }else
                                          {    
                                                $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set   client_id=:client_id  where id=:id  ");  
                                                $stmt->bindValue(':client_id', $client_id , PDO::PARAM_STR); 
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();      
                                          }
                                       
                               
                                        if($Data->utr)
                                        { 
                                            if($Data->utr)
                                            $UTR = $Data->utr;
                                            else
                                            $UTR = "XXXXX";  
                                            
                                            if (array_key_exists("status_id",$Data))
                                            {
                                            if(($Data->status_id==0) || ($Data->status_id==1))
                                            {
                                            $moneytransfer_status='Success';
                                            $status=1;
                                            //$_SESSION['moneytransfer_success'.$rand_no]=1;
                                            }
                                            else if(($Data->status_id==2) || ($Data->status_id==4))
                                            {
                                            $moneytransfer_status='Fail';
                                            $status=0;    
                                            }
                                            else if($Data->status_id==3)
                                            {
                                            $moneytransfer_status='Pending'; 
                                            $status=2; 
                                            }  
                                            
                                            if(!empty($Data->orderid))
                                            {
                                            $orderid=$Data->orderid;   
                                            $Dataorderid = $Data->orderid;
                                            $Datareport_id = $Data->report_id;
                                            }else 
                                            {
                                            $errorMsg = $Data->message;
                                            $Dataorderid = '';
                                            $Datareport_id = '';
                                            $orderid = ''; 
                                            }
                                            
                                            }else
                                            {
                                            $moneytransfer_status='Fail';
                                            $status=0;  
                                            $errorMsg = "Error in transaction";
                                            $Dataorderid = '';
                                            $Datareport_id = '';
                                            $orderid = '';    
                                            }  
                                             
                                            if( ($status==1) || ($status==2) ) 
                                            {
                                                $Datareport_id = mt_rand(3455456,45455);
                                            }else
                                                $Datareport_id = mt_rand(3455456,45455);
                                                
                                             
                                         

                                                
                                            if($_POST['type']==1)
                                            {             
                                                    if($status!=0) 
                                                    {  
                                                        
                                                        $stmt=$conn->prepare("update UI__TxnFailUsers set status=:status,report_id=:report_id, UTR=:UTR,paidDateTime=:paidDateTime,status=1,Byfrom=1  where id=:id  ");  
                                                        $stmt->bindValue(':status', $status , PDO::PARAM_STR);
                                                        $stmt->bindValue(':report_id', $report_id , PDO::PARAM_STR);  
                                                        $stmt->bindValue(':UTR', $Datareport_id , PDO::PARAM_STR);
                                                        $stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
                                                        $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                        $stmt->execute();
                                                    }
                                            }else
                                            {
                                                    if($status!=0) 
                                                    { 
                                                        $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set UTR=:UTR,paidDateTime=:paidDateTime,status=1  where id=:id  ");  
                                                        $stmt->bindValue(':UTR', $Datareport_id , PDO::PARAM_STR);
                                                        $stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
                                                        $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                        $stmt->execute();   
                                                    } 
                                            }    
                                            
                                            $stmt=$conn->prepare("select  impnft from  UI__TxnFailUsers where id=:id  ");  
                                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);
                                            $stmt->execute(); 
                                            $Mydetails = $stmt->fetch(PDO::FETCH_OBJ);
                                            
                                          
                                        }
                                        else
                                        {
                                            if($_POST['type']==1)
                                            {             
                                                $stmt=$conn->prepare("update UI__TxnFailUsers set report_id=:report_id,response=:response,Byfrom=1  where id=:id  ");  
                                                $stmt->bindValue(':response', $res , PDO::PARAM_STR); 
                                                $stmt->bindValue(':report_id', $report_id , PDO::PARAM_STR);  
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();
                                            }else
                                            {    
                                                $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set response=:response  where id=:id  ");  
                                                $stmt->bindValue(':response', $res , PDO::PARAM_STR); 
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();
                                            }  
                                        }
                                    
                                      if($Mydetails->impnft==0)   
                                        {
                                            header("Location: ".ROOTPATH."/admin/usereReqt/UsdtxnFaild.php");   
                                            die;
                                        }
                                        else
                                        {
                                            header("Location: payout-manage.php");
                                            die;
                                        }    
									}
									
									else if( ($_POST['payselect']==2) ||  ($_POST['payselect']==3) ) 
									{   
									   
									   if($_POST['payselect']==2) 
									   {
									        $Remail = "HdL32mhRkJU7rbUwmXIvRHGqP53Bkwg8FRRWpZ7MNfryg35EiX5ESyJrk7KB";
									        $Byfrom = 1;
									   }
									   else  {
									         $Remail =   "RdVFLtRb83jLrxM5mafitjRW6Gp4zbfiwYXfhr6FEg6n3w4RQXfC9pNkhEMd"; 
									         $Byfrom = 2;
									   }
									  
                                        $access_token = '{"api_token":"'.$Remail.'","email":"'.$email.'","beneficiary_name":"'.$beneficiary_name.'","mobile_number":"'.$mobile_number.'","amount":"'.$amount.'","ifsc_code":"'.$beneficiary_ifsc.'","client_id":"'.$client_id.'","account_number":"'.$account_number.'","channel_id":"2"}';
                                     
                                        
                                        $stmt=$conn->prepare("insert into  test (name) values(:name)  ");  
                                        $stmt->bindValue(':name', "before".$access_token, PDO::PARAM_STR);
                                        $stmt->execute();  

                                        $ch = curl_init('https://grappay.com/api/payout/v2/transfer-now');                                             
                                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                                        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                                        'x-tera-tenant-region: IN', 
                                        'Content-Type: application/json', 
                                        'Content-Length: ' . strlen($access_token))                                                                       
                                        );       																		 
                                        $response = curl_exec($ch);   
                                        
                                        
                                        $stmt=$conn->prepare("insert into UI__MoneY(Uid,response,Tdate,request) values(:Uid,:calBack,:Tdate,:request)"); 
                                        $stmt->bindValue(':Uid',  $userId , PDO::PARAM_STR);    
                                        $stmt->bindValue(':calBack', $response.":: GrepPay" , PDO::PARAM_INT);    
                                        $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);     
                                        $stmt->bindValue(':request',  $access_token , PDO::PARAM_STR);     
                                        
                                        
                                        $stmt->execute();  
                                        $Data = json_decode($response);  
                                        
                                        $UTR = "XXXXX";
                                        
                                      if($_POST['type']==1)
                                      {
                                            $stmt=$conn->prepare("update UI__TxnFailUsers set   client_id=:client_id  where id=:id  ");  
                                            $stmt->bindValue(':client_id', $client_id , PDO::PARAM_STR); 
                                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                            $stmt->execute();    
                                          
                                      }else
                                      {    
                                            $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set   client_id=:client_id  where id=:id  ");  
                                            $stmt->bindValue(':client_id', $client_id , PDO::PARAM_STR); 
                                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                            $stmt->execute();      
                                      }
                               
                                   
                                        if (array_key_exists("status",$Data))
                                        {        
                                                if (array_key_exists("status",$Data))
                                                {
                                                        if($Data->status=='success')
                                                        {
                                                            $moneytransfer_status='Success';
                                                            $status=1; 
                                                            $UTR = $Data->utr;
                                                        }
                                                        else if($Data->status=='pending')
                                                        {
                                                            $moneytransfer_status='Pending';
                                                            $status=2;   
                                                        }  
                                                        else  
                                                        {
                                                            $moneytransfer_status='Failed'; 
                                                            $status=0;   
                                                        }  
                                                }
                                                else
                                                {
                                                $moneytransfer_status='Fail';
                                                $status=0;  
                                                $errorMsg = "Error in transaction";
                                                $Dataorderid = '';
                                                $Datareport_id = '';
                                                $orderid = ''; 
                                                }  
                                            
                                            
                                            if($_POST['type']==1)
                                            {             
                                                    if($status!=0) 
                                                    {
                                                        $stmt=$conn->prepare("update UI__TxnFailUsers set UTR=:UTR,paidDateTime=:paidDateTime,status=1,Byfrom=$Byfrom  where id=:id  ");  
                                                        $stmt->bindValue(':UTR', $UTR , PDO::PARAM_STR);
                                                        $stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
                                                        $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                        $stmt->execute();
                                                    }
                                            }else
                                            {
                                                    if($status!=0) 
                                                    { 
                                                        $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set UTR=:UTR,paidDateTime=:paidDateTime,status=1  where id=:id  ");  
                                                        $stmt->bindValue(':UTR', $UTR , PDO::PARAM_STR);
                                                        $stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
                                                        $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                        $stmt->execute();   
                                                    } 
                                            } 
                                            
                                            
                                            $stmt=$conn->prepare("select  impnft from  UI__TxnFailUsers where id=:id  ");  
                                            $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);
                                            $stmt->execute(); 
                                            $Mydetails = $stmt->fetch(PDO::FETCH_OBJ);
                                            
                                           
                                        }
                                        else
                                        {
                                            if($_POST['type']==1)
                                            {             
                                                $stmt=$conn->prepare("update UI__TxnFailUsers set response=:response,Byfrom=$Byfrom  where id=:id  ");  
                                                $stmt->bindValue(':response', $res , PDO::PARAM_STR); 
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();
                                            }else
                                            {    
                                                $stmt=$conn->prepare("update UI__TxnFailUsersPay2 set response=:response  where id=:id  ");  
                                                $stmt->bindValue(':response', $res , PDO::PARAM_STR); 
                                                $stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
                                                $stmt->execute();
                                            }  
                                        }
                                        
                                        if($Mydetails->impnft==0)   
                                        {
                                            header("Location: ".ROOTPATH."/admin/usereReqt/UsdtxnFaild.php");   
                                            die;
                                        }
                                        else
                                        {
                                            header("Location: payout-manage.php");
                                            die;
                                        } 
                                        
									} 
									
									else if(($_POST['payselect']==4)) 
									{   
									   
										$Remail =   "RdVFLtRb83jLrxM5mafitjRW6Gp4zbfiwYXfhr6FEg6n3w4RQXfC9pNkhEMd"; 
										$Byfrom = 2;  
										 
										$ch = curl_init('https://api.payout.v1.runpaisa.com/payout/token');                                             
										curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
										curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
										curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
										curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
										'x-tera-tenant-region: IN', 
										'client_id: 67bc15a2d007e',  
										'client_secret: b16411207668bf8a6f742910f5cbd203', 
										'content-type: application/json', 
										'Content-Length: ' . strlen($access_token))                                                                       
										);       																		 
										$response = curl_exec($ch);   
										$Data = json_decode($response); 
										$Token = $Data->data->token;   
 

										$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 
										$length_of_string = 32;
										$orderId  = substr(str_shuffle($str_result),0, $length_of_string); 
										//$orderId = mt_rand(23435,23232323);  
									    $access_token = '{"beneficiary_name":"'.$beneficiary_name.'","order_id":"'.$orderId.'","amount":"'.$amount.'","ifsc_code":"'.$beneficiary_ifsc.'","account_number":"'.$account_number.'","payment_mode":"IMPS"}';    
                                        
                                        
                                       
										$ch = curl_init('https://api.payout.v1.runpaisa.com/payout/payment');                                             
										curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
										curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
										curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
										curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
										'x-tera-tenant-region: IN', 
										'token: '.$Token, 
										'Content-Type: application/json', 
										'Content-Length: ' . strlen($access_token))                                                                       
										);       																		 
										$response = curl_exec($ch);  
										$Decode  = json_decode($response);  
										
									 
                                        
                                        $stmt=$conn->prepare("insert into UI__MoneY(Uid,response,Tdate,request) values(:Uid,:calBack,:Tdate,:request)"); 
                                        $stmt->bindValue(':Uid',  $userId , PDO::PARAM_STR);    
                                        $stmt->bindValue(':calBack', $response.":: GrepPay" , PDO::PARAM_INT);    
                                        $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);     
                                        $stmt->bindValue(':request',  $access_token , PDO::PARAM_STR);        
                                        $stmt->execute();  
                                        $Data = json_decode($response);   
                                        $UTR = "XXXXX"; 
									 
									
										if($_POST['type']==1)
										{
											$stmt=$conn->prepare("update UI__TxnFailUsers set   client_id=:client_id  where id=:id  ");  
											$stmt->bindValue(':client_id', $orderId , PDO::PARAM_STR); 
											$stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
											$stmt->execute();  
										}else
										{    
											$stmt=$conn->prepare("update UI__TxnFailUsersPay2 set   client_id=:client_id  where id=:id  ");  
											$stmt->bindValue(':client_id', $orderId , PDO::PARAM_STR); 
											$stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
											$stmt->execute();      
										}
											
										
										if($Decode->code=='RP000') 
											$status = 1;  
										else if($Decode->code=='RP001')
											$status = 0;
										else
											$status = 2;  
										
											if($_POST['type']==1)
											{             
													if($status!=0) 
													{  	    
                                                       
                                                        $access_token = '{"order_id":"'.$orderId.'"}';  
                                                        $ch = curl_init('https://api.payout.v1.runpaisa.com/payout/status');                                             
                                                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                                                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                                                        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                                                        'x-tera-tenant-region: IN', 
                                                        'token: '.$Token, 
                                                        'Content-Type: application/json', 
                                                        'Content-Length: ' . strlen($access_token))                                                                       
                                                        );       																		 
                                                        $response = curl_exec($ch);   
                                                        $Data = json_decode($response);  
                                                        $UTR =$Data->utr_no;   

														$stmt=$conn->prepare("update UI__TxnFailUsers set UTR=:UTR,paidDateTime=:paidDateTime,status=1,Byfrom=$Byfrom  where id=:id  ");  
														$stmt->bindValue(':UTR', $UTR , PDO::PARAM_STR);
														$stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
														$stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
														$stmt->execute();
													}
											}else
											{
													if($status!=0) 
													{ 
														
														$access_token = '{"order_id":"'.$orderId.'"}';  
                                                        $ch = curl_init('https://api.payout.v1.runpaisa.com/payout/status');                                             
                                                        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
                                                        curl_setopt($ch, CURLOPT_POSTFIELDS, $access_token);                                                                  
                                                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
                                                        curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                                                        'x-tera-tenant-region: IN', 
                                                        'token: '.$Token, 
                                                        'Content-Type: application/json', 
                                                        'Content-Length: ' . strlen($access_token))                                                                       
                                                        );       																		 
                                                        $response = curl_exec($ch);   
                                                        $Data = json_decode($response);  
                                                        $UTR =$Data->utr_no;   
														
														$stmt=$conn->prepare("update UI__TxnFailUsersPay2 set UTR=:UTR,paidDateTime=:paidDateTime,status=1  where id=:id  ");  
														$stmt->bindValue(':UTR', $UTR , PDO::PARAM_STR);
														$stmt->bindValue(':paidDateTime', date("d-M-Y H:i") , PDO::PARAM_STR);
														$stmt->bindValue(':id', $myIdset , PDO::PARAM_STR);  
														$stmt->execute();   
													} 
											}    
											header("Location: payout-manage.php");
                                            die;  
									  }  
                			    }
            			}  
                       
?>