0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 18.118.32.6


Current Path : /var/www/student/sikkim/src/
Upload File :
Current File : /var/www/student/sikkim/src/razorpay_order_api.php

<?php
/**
* import checksum generation utility
* You can get this utility from https://developer.paytm.com/docs/checksum/
*/
ini_set('display_errors', 'On');
error_reporting(E_ALL);
ini_set('max_execution_time', 300);
ini_set("memory_limit","500M");
header("Content-Type: text/html");
include ("consts.php");

require('razorpay/razorpay-php/Razorpay.php');

use Razorpay\Api\Api;

$servername = SERVERNAME;
$username = USERNAME;
$password = PASSWORD;
$databse = 'logisys3_comexam';

$conn = new  mysqli($servername,$username,$password,$databse);
if(!$conn) 
{
	die("Connection failed: " . mysqli_connect_error());
}
$get_data = "select distinct d.funivcode, d.fdbname, d.funivname, m.fkey, m.fworkingid from maspg m inner join dbname d 
on d.funivcode = m.funivcode
 where m.fbank = 'razorpay' and ifnull(fsuspend,'') <> 'T'";
    //var_dump($get_data);
$result_univ=$conn->query($get_data); 

if (mysqli_num_rows($result_univ) > 0) 
{
	while($row = mysqli_fetch_assoc($result_univ)) 
	{
		$key    =    $row['fkey'];
		$mid    =    $row['fworkingid'];
        $dbname = $row['fdbname'];
        $funivcode = $row['funivcode'];

        $pconn = new  mysqli($servername,$username,$password,$dbname);
        if(!$pconn) 
        {
            die("Connection failed: " . mysqli_connect_error());
        }

        $get_data = "select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select appno from appcandsum where ifnull(fackdate,'') = '' and ifnull(fpaymentstatus,'') <> 'success') a inner join pgdet p on a.appno = p.appno 
        and ifnull(p.fstatus,'') <> 'captured' and ifnull(p.fstatus,'') <> 'attempted'
        and ifnull(p.fstatus,'') <> 'created' 
        and fpaygateway = 'razorpay' and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
        union 
        select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select appno from appcandsum where ifnull(fackdate,'') = '' and ifnull(fpaymentstatus,'') <> 'success') a inner join pgdet p on a.appno = p.appno 
        and ifnull(p.fstatus,'') = 'attempted'
        and fpaygateway = 'razorpay' and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
        and p.fcreatedate > DATE_SUB(now(), interval 3 DAY)";
            //var_dump($get_data);
        $result_stat=$pconn->query($get_data); 

        if (mysqli_num_rows($result_stat) > 0) 
        {
             // Set Content-Type
            while (@ob_end_flush());

            while($txn = mysqli_fetch_assoc($result_stat)) 
            {
                
                $api = new Api($key, $mid);
                //var_dump($api);

                $txnid = "404";
                $status = "";
                $res_final_set = new stdClass();
                $orderid = "";
                $productinfo = "";
                $orderId = "";
                $res_msg = " - ";
                
                $productinfo = $txn['appno'];
                $orderId = $txn['forderid'];
               
                
                $res_set = $api->order->fetch($orderId);
               

                $status  = $res_set->status;
                
              
                if($status != 'created')
                {
                    $res_final_set = $api->order->fetch($orderId)->payments();
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $res_msg = $res_final_set->items[0]->error_description;
                    $txndate = $res_final_set->items[0]->created_at;
                    
                }
               
               $update_pg = "update pgdet set ftxnid = '{$txnid}', fstatus = '{$status}', fupddate = now() 
                    where appno = '{$productinfo}' and forderid = '{$orderId}' and fpaygateway = 'Razorpay'
                    and ftype = 'EXAM'";
               
               $result_pg=$pconn->query($update_pg);
                
                                
                if(strtolower($status) == 'captured' || strtolower($status) == 'paid'){
                    
                  
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $txndate = $res_final_set->items[0]->created_at;
                    $date = date("Y-m-d H:i:s", $txndate);
                var_dump("Date: ".$date);
                    
                    $firstname = "Razorpay";
                   
                    $update="update appcandsum set FPAYMENTREMARKS='{$txnid}',FPAYMENTSTATUS='success',
                    FPAYMENTCONFIRM='success',FACKDATE='{$date}',FACKUSER='{$firstname}',
                    fremarks  = 'RAZORPAY-ORDER-API',
                    FPAYGATEWAY = '{$firstname}',
                    frecptdate = '{$date}'
                    where APPNO='{$productinfo}'";
                    $result=$pconn->query($update); 
                    
                    // /*$get_app_cand_det="SELECT FDEGREE,FEXAMNO,FCOLLCODE,FREGNO,FSUBCODE,FINSERTED,FPRESENT,FYEAR,FEXAMTYPE
                    // FROM appcanddet
                    // WHERE APPNO='{$productinfo}'";	
                    // $result = $conn->query($get_app_cand_det);*/ 
                    
                    // $get_app_cand_det="SELECT a.FDEGREE,a.FEXAMNO,a.FCOLLCODE,c.FFRESHEXAM,
                    // a.FREGNO,a.FSUBCODE,a.FINSERTED,a.FPRESENT,a.FYEAR,a.FEXAMTYPE,concat('Message from Bengaluru Central University : ', 
                    // ' Dear ',s.fname,' (Reg. no. : ',s.fregno,' , Stud. id. : ',s.fstudid,'),', 
                    // ' Rs.',FLOOR(c.FTOTALFEE),'/- is received at university. Your application no. is ',c.appno,
                    // '. keep this information for future reference.',' Sent Time: ',time(now())) as message
                    // FROM appcanddet a inner join student s on a.fdegree = s.fdegree
                    // and s.fcollcode = a.fcollcode and
                    // a.fregno = s.fregno  inner join appcandsum c on a.fdegree = c.fdegree
                    // and a.fcollcode = c.fcollcode and a.fregno = c.fregno and a.appno = c.appno
                    // WHERE c.APPNO='{$productinfo}'"; 
                    $get_app_cand_det="SELECT c.FDEGREE,c.FEXAMNO,c.FCOLLCODE,ifnull(c.FFRESHEXAM,'') as FFRESHEXAM,
                    c.FREGNO,c.FYEAR,c.FEXAMTYPE,'' as message
                    FROM appcandsum c
                    WHERE c.APPNO='{$productinfo}'";
                    $result = $pconn->query($get_app_cand_det);

                    if (mysqli_num_rows($result) > 0) 
                    {
                        while($row = mysqli_fetch_assoc($result)) 
                        {
                            $collcode = $row['FCOLLCODE'];
                            $degree = $row['FDEGREE'];
                            $regno = $row['FREGNO'];
                            $text = $row['message'];
                            $FFRESHEXAM = $row['FFRESHEXAM'];
                        }
                    }
                        
                   
                
                    // $update_cand_sum = "UPDATE appcandsum a,candsum c
                    // SET 
                    // c.FEXAMFEEA=if(ifnull(c.FEXAMFEEA,0) <=0,ifnull(a.FEXAMFEEA,0),ifnull(c.FEXAMFEEA,0)),
                    // c.FEXAMFEEB=if(ifnull(c.FEXAMFEEB,0) <=0,ifnull(a.FEXAMFEEB,0),ifnull(c.FEXAMFEEB,0)),
                    // c.FEXAMFEEC=if(ifnull(c.FEXAMFEEC,0) <=0,ifnull(a.FEXAMFEEC,0),ifnull(c.FEXAMFEEC,0)),
                    // c.FEXAMFEED=if(ifnull(c.FEXAMFEED,0) <=0,ifnull(a.FEXAMFEED,0),ifnull(c.FEXAMFEED,0)),
                    // c.FEXAMFEEE=if(ifnull(c.FEXAMFEEE,0) <=0,ifnull(a.FEXAMFEEE,0),ifnull(c.FEXAMFEEE,0)),
                    // c.FEXAMFEEF=if(ifnull(c.FEXAMFEEF,0) <=0,ifnull(a.FEXAMFEEF,0),ifnull(c.FEXAMFEEF,0)),
                    // c.FEXAMFEEG=if(ifnull(c.FEXAMFEEG,0) <=0,ifnull(a.FEXAMFEEG,0),ifnull(c.FEXAMFEEG,0)),
                    // c.FEXAMFEEH=if(ifnull(c.FEXAMFEEH,0) <=0,ifnull(a.FEXAMFEEH,0),ifnull(c.FEXAMFEEH,0)),
                    // c.FEXAMFEEI=if(ifnull(c.FEXAMFEEI,0) <=0,ifnull(a.FEXAMFEEI,0),ifnull(c.FEXAMFEEI,0)),
                    // c.FEXAMFEEJ=if(ifnull(c.FEXAMFEEJ,0) <=0,ifnull(a.FEXAMFEEJ,0),ifnull(c.FEXAMFEEJ,0)),
                    // c.FTOTALFEE=a.FTOTALFEE,
                    // c.frecptdate = date(now())
                    // WHERE a.fregno=c.FREGNO
                    // AND a.APPNO='{$productinfo}' and a.FCOLLCODE='{$collcode}'";

                    $update_cand_sum = "UPDATE (SELECT c.FDEGREE AS fdegree, c.FREGNO AS fregno, c.FCOLLCODE AS fcollcode,
                    sum(ifnull(c.FEXAMFEEA,0)) AS fexamfeea,
                    sum(ifnull(c.FEXAMFEEB,0)) AS fexamfeeb,
                    sum(ifnull(c.FEXAMFEEC,0)) AS fexamfeec,
                    sum(ifnull(c.FEXAMFEED,0)) AS fexamfeed,
                    sum(ifnull(c.FEXAMFEEE,0)) AS fexamfeee,
                    sum(ifnull(c.FEXAMFEEF,0)) AS fexamfeef,
                    sum(ifnull(c.FEXAMFEEG,0)) AS fexamfeeg,
                    sum(ifnull(c.FEXAMFEEH,0)) AS fexamfeeh,
                    sum(ifnull(c.FEXAMFEEI,0)) AS fexamfeei,
                    sum(ifnull(c.FEXAMFEEJ,0)) AS fexamfeej,
                    sum(ifnull(c.FTOTALFEE,0)) AS ftotalfee,
                    FRECPTDATEA,
                    FRECPTDATEB,
                    FRECPTDATEC,
                    FRECPTDATED,
                    FRECPTDATEE,
                    FRECPTDATEF,
                    FRECPTDATEG,
                    FRECPTDATEH,
                    FRECPTDATEI,
                    FRECPTDATEJ
                    FROM appcandsum c where ((c.FPAYMENTSTATUS = 'success') 
                    and (ifnull(c.FTOTALFEE,0) > 0) and (ifnull(c.FRECPTDATE,'') <> '')) 
                    and c.fregno = '{$regno}'
                    group by c.FDEGREE,c.FREGNO,c.FCOLLCODE) a,candsum c
                        SET 
                        c.FEXAMFEEA = a.FEXAMFEEA,
                        c.FEXAMFEEB = a.FEXAMFEEB,
                        c.FEXAMFEEC = a.FEXAMFEEC,
                        c.FEXAMFEED = a.FEXAMFEED,
                        c.FEXAMFEEE = a.FEXAMFEEE,
                        c.FEXAMFEEF = a.FEXAMFEEF,
                        c.FEXAMFEEG = a.FEXAMFEEG,
                        c.FEXAMFEEH = a.FEXAMFEEH,
                        c.FEXAMFEEI = a.FEXAMFEEI,
                        c.FEXAMFEEJ = a.FEXAMFEEJ,
                        c.FTOTALFEE = a.FTOTALFEE,
                        c.FRECPTDATEA = a.FRECPTDATEA,
                        c.FRECPTDATEB = a.FRECPTDATEB,
                        c.FRECPTDATEC = a.FRECPTDATEC,
                        c.FRECPTDATED = a.FRECPTDATED,
                        c.FRECPTDATEE = a.FRECPTDATEE,
                        c.FRECPTDATEF = a.FRECPTDATEF,
                        c.FRECPTDATEG = a.FRECPTDATEG,
                        c.FRECPTDATEH = a.FRECPTDATEH,
                        c.FRECPTDATEI = a.FRECPTDATEI,
                        c.FRECPTDATEJ = a.FRECPTDATEJ,
                        c.frecptdate = '{$date}'
                        WHERE a.fregno=c.FREGNO
                        AND c.fregno = '{$regno}'";
                    
                    $result = $pconn->query($update_cand_sum); 

                    $update_caste = "update candsum c, student s
                        set c.fcategory = s.fcaste,
                        c.ffeetype = if(ifnull(c.fconstype,'0123456789') <> '0123456789', 'Low Income', 'Normal Fee')
                        where s.fregno = c.fregno
                        and s.fregno = '{$regno}'";
                    $result = $pconn->query($update_caste); 
                    
                    $update_cand_appCand = "update canddet c, appcanddet t  
                    set c.finserted = t.finserted,
                    c.fpresent = t.fpresent
                    where c.fdegree = t.fdegree
                    and c.fexamno = t.fexamno
                    and c.fregno = t.fregno
                    and c.fsubcode = t.fsubcode
                    and c.fdegree = '{$degree}' and  c.fregno = '{$regno}' 
                    and t.APPNO='{$productinfo}' and ifnull(c.fpresent,'') <> 'P'";
                    
                    $result = $pconn->query($update_cand_appCand); 
                    
                    $insert_canddet ="insert into canddet(fdegree,FEXAMNO, FCOLLCODE, FREGNO, FSUBCODE, FINSERTED, FPRESENT, FYEAR, FEXAMTYPE)
                    select fdegree, FEXAMNO, FCOLLCODE,FREGNO, FSUBCODE,FINSERTED, FPRESENT, FYEAR,FEXAMTYPE from appcanddet where 
                    fregno = '{$regno}' and appno ='{$productinfo}' and CONCAT(fdegree,fexamno,fregno,fsubcode) 
                    not in(select CONCAT(fdegree,fexamno,fregno,fsubcode) from canddet where  fregno = '{$regno}')
                    ";
                    
                    $result = $pconn->query($insert_canddet); 
                    
                    
                    $query = "insert ignore into marks (FDEGREE, FEXAMNO, FCOLLCODE, FREGNO, FSUBCODE, fmarks, fyear, fexamtype)
                    select c.fdegree,c.fexamno,c.fcollcode,c.fregno,
                    s.fcsubcode,'-1', c.fyear,c.fexamtype
                    from canddet c inner join 
                    subject s on c.fdegree = s.fdegree and c.fexamno = s.fexamno 
                    and c.fsubcode = s.FSUBCODE	
                    where c.fregno = '{$regno}' and c.fexamno = '{$FFRESHEXAM}' 
                    and c.fcollcode = '{$collcode}' and c.fdegree = '{$degree}'
                    and s.fintass = 'T' and s.fretain = 'T'";
                    $res = $pconn->query($query); 

                    $query = "insert ignore into marks_pr (FDEGREE, FEXAMNO, FCOLLCODE, FOCOLLCODE,FREGNO, FSUBCODE, fmarks11, fyear, fexamtype)
                    select cd.fdegree,cd.fexamno,cd.fcollcode,cd.fcollcode,cd.fregno,s.fcsubcode,'-1', 
                    cd.fyear,cd.fexamtype
                    from subject s inner join canddet cd on s.fdegree = cd.fdegree 
                    and s.fsubcode = cd.FSUBCODE 
                    and cd.fregno = '{$regno}'
                    and ifnull(cd.fpassmth,'') = '' 
                    and ifnull(cd.fthpr,'') <> 'F'
                    where s.fdegree = '{$degree}' 
                    and cd.fcollcode = '{$collcode}'
                    and s.ftheory = 'F'
                    and ifnull(s.fintass,'F') <> 'T'";
                    $res = $pconn->query($query); 
                    
                    // $update_studfee = "update studfee s, appstudfee a
                    // set s.famount = a.famount,
                    // s.flogdate = a.flogdate
                    // where s.fdegree = a.fdegree
                    // and s.fexamno = a.fexamno
                    // and s.fregno = a.fregno
                    // and s.ffeecode = a.ffeecode
                    // and  s.fregno = '{$regno}'
                    // and  s.famount <= 0
                    // and a.appno ='{$productinfo}'";
                    $update_studfee = "update studfee s, (select a.appno, a.fregno, a.fdegree, a.fexamno, a.fcollcode, a.ffeecode, sum(a.famount) as famount,
                        a.fyear, a.fexamtype, a.flogdate
                        from appstudfee a inner join appcandsum b on a.fregno = b.fregno and a.appno = b.appno
                        where ifnull(b.fpaymentstatus,'') = 'success' 
                        and ifnull(fackdate,'') <> '' and b.fregno = '{$regno}'
                        group by a.fdegree, a.fexamno, a.fcollcode, a.fregno, a.ffeecode) a
                        set s.famount = a.famount,
                        s.flogdate = a.flogdate,
                        s.fyear = a.fyear,
                        s.fexamtype = a.fexamtype
                        where s.fdegree = a.fdegree
                        and s.fexamno = a.fexamno
                        and s.fregno = a.fregno
                        and s.ffeecode = a.ffeecode
                        and  s.fregno = '{$regno}'";
                    
                    $result = $pconn->query($update_studfee);
                    
                    $insert_studfee = "insert into studfee(fdegree,fexamno,fcollcode,fregno,ffeecode,famount,flogdate,fyear,fexamtype)
                    select fdegree,fexamno,fcollcode,fregno,ffeecode,famount,flogdate,fyear,fexamtype from appstudfee where 
                    fregno = '{$regno}' and appno ='{$productinfo}' and CONCAT(fdegree,fexamno,fregno,ffeecode) 
                    not in(select CONCAT(fdegree,fexamno,fregno,ffeecode) from studfee where  fdegree = '{$degree}' 
                    and fregno = '{$regno}')";
                    $result = $pconn->query($insert_studfee);
                }

                if($status != 'created')
                echo "Univ.: $funivcode ---AppNo: $productinfo ---OrderID: $orderId ---Status: $status --Reason : $res_msg<br/>";
                flush();
            }
        }

        $query = "select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select distinct appno from res_stud where ifnull(fackdate,'') = '' and ifnull(fpaymentstatus,'') <> 'success') a inner join pgdet p on a.appno = p.appno 
       and ifnull(p.fstatus,'') <> 'captured' and ifnull(p.fstatus,'') <> 'attempted'
        and ifnull(p.fstatus,'') <> 'created' 
        and fpaygateway = 'Razorpay' and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
        union
        select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select distinct appno from res_stud where ifnull(fackdate,'') = '' and ifnull(fpaymentstatus,'') <> 'success') a inner join pgdet p on a.appno = p.appno 
       and ifnull(p.fstatus,'') = 'attempted'
       and fpaygateway = 'Razorpay' and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
       and p.fcreatedate > DATE_SUB(now(), interval 3 DAY)";
        $res_rv=$pconn->query($query);

        if (mysqli_num_rows($res_rv) > 0) 
        {
            
            while (@ob_end_flush());

            while($txn = mysqli_fetch_assoc($res_rv)) 
            {
                $api = new Api($key, $mid);
                //var_dump($api);
                $txnid = "404";
                $status = "";
                $res_final_set = new stdClass();
                $orderid = "";
                $productinfo = "";
                $orderId = "";
                $res_msg = " - ";
                
                $productinfo = $txn['appno'];
                $orderId = $txn['forderid'];
               
                
                $res_set = $api->order->fetch($orderId);
               

                $status  = $res_set->status;
                
              
                if($status != 'created')
                {
                    $res_final_set = $api->order->fetch($orderId)->payments();
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $res_msg = $res_final_set->items[0]->error_description;
                   
                }
                
               $update_pg = "update pgdet set ftxnid = '{$txnid}', fstatus = '{$status}', fupddate = now() 
                    where appno = '{$productinfo}' and forderid = '{$orderId}' and fpaygateway = 'Razorpay'
                    and ftype = 'RVRT'";
               
               $result_pg=$pconn->query($update_pg);
                
                                
                if(strtolower($status) == 'captured' || strtolower($status) == 'paid'){
                    
                  
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $txndate = $res_final_set->items[0]->created_at;
                    $date = date("Y-m-d H:i:s", $txndate);
                   
                    $firstname = "Razorpay_Order_API";
                    $update = "update res_stud set FPAYMENTREMARKS='{$txnid}',FPAYMENTSTATUS='success',
                    FPAYMENTCONFIRM='success', fackdate = '{$date}', funivrecdate = '{$date}', 
                    fackuser = '{$firstname}', FCHALLANNO = '{$orderId}'
                    where APPNO='{$productinfo}'";
                    $result = $pconn->query($update); 
                }  

                if($status != 'created')
                echo "RV :- Univ.: $funivcode ---AppNo: $productinfo ---OrderID: $orderId ---Status: $status --Reason : $res_msg<br/>";
                flush();

            } 
        } 

        $query = "select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select distinct fappno from regcandsum where ifnull(fpaymentstatus,'') <> 'success') a 
        inner join pgdet p on a.fappno = p.appno 
       and ifnull(p.fstatus,'') <> 'captured' and ifnull(p.fstatus,'') <> 'attempted'
        and ifnull(p.fstatus,'') <> 'created' 
        and fpaygateway = 'Razorpay' 
        and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
        union
        select p.ftype, p.appno, p.fregno, p.forderid, p.fstatus, p.fpaygateway, 
        p.fcreatedate, DATE_SUB(now(), interval 10 MINUTE) from
        (select distinct fappno from regcandsum where ifnull(fpaymentstatus,'') <> 'success') a inner join pgdet p on a.fappno = p.appno 
       and ifnull(p.fstatus,'') = 'attempted'
       and fpaygateway = 'Razorpay' and p.fcreatedate < DATE_SUB(now(), interval '10:0' MINUTE_SECOND)
       and p.fcreatedate > DATE_SUB(now(), interval 3 DAY)";
        $res_rv=$pconn->query($query);

        if (mysqli_num_rows($res_rv) > 0) 
        {
            
            while (@ob_end_flush());

            while($txn = mysqli_fetch_assoc($res_rv)) 
            {
                $api = new Api($key, $mid);
                //var_dump($api);
                $txnid = "404";
                $status = "";
                $res_final_set = new stdClass();
                $orderid = "";
                $productinfo = "";
                $orderId = "";
                $res_msg = " - ";
                
                $productinfo = $txn['appno'];
                $orderId = $txn['forderid'];
               
                
                $res_set = $api->order->fetch($orderId);
               

                $status  = $res_set->status;
                
              
                if($status != 'created')
                {
                    $res_final_set = $api->order->fetch($orderId)->payments();
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $res_msg = $res_final_set->items[0]->error_description;
                   
                }
                
               $update_pg = "update pgdet set ftxnid = '{$txnid}', fstatus = '{$status}', fupddate = now() 
                    where appno = '{$productinfo}' and forderid = '{$orderId}' and fpaygateway = 'Razorpay'
                    and ftype = 'REGN'";
               
               $result_pg=$pconn->query($update_pg);
                
                                
                if(strtolower($status) == 'captured' || strtolower($status) == 'paid'){
                    
                  
                    $productinfo = $res_final_set->items[0]->notes->appno;
                    $txnid = $res_final_set->items[0]->id;
                    $txndate = $res_final_set->items[0]->created_at;
                    $date = date("Y-m-d H:i:s", $txndate);
                   
                    $firstname = "Razorpay_Order_API";
                    $update = "update regcandsum set ftranid='{$txnid}',fpaymentstatus='success',
                    fpaymentdate = now(), forderapi = '{$firstname}'
                    where fappno='{$productinfo}'";
                    $result = $pconn->query($update); 
                }  

                if($status != 'created')
                echo "REGN :- Univ.: $funivcode ---AppNo: $productinfo ---OrderID: $orderId ---Status: $status --Reason : $res_msg<br/>";
                flush();

            } 
        } 

	}
}