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.188.211.58


Current Path : /var/www/html/pgadm/razorpay/
Upload File :
Current File : /var/www/html/pgadm/razorpay/pay.php

<?php
include ("../database.php");

$funivcode = $_POST['funivcode'];
$appno = $_POST['appno'];

// $servername = "localhost";
// $username = "root";
// $password = "";

$dbname = "logisys3_comexam";
// $conn = new mysqli($servername, $username, $password, $dbname);
$conn = new mysqli(SERVERNAME, USERNAME, PASSWORD, $dbname);
$get_data = "select * from dbname";

$result1=$conn->query($get_data); 

if (mysqli_num_rows($result1) > 0) 
{
    // output data of each row
    $dbnames = array();
    while($row = mysqli_fetch_assoc($result1)) 
    {
        $dbnames[$row['FUNIVCODE']] = $row['FDBNAME'];
    }
}
$dbname = $dbnames[$funivcode];
$get_query = "select * from {$dbname}.maspg where funivcode = '{$funivcode}' and fbank = 'Razorpay'";

$result1=$conn->query($get_query); 

$pgcred = mysqli_fetch_assoc($result1);


define("RAZORPAY_KEY_ID", $pgcred['fkey']);
define("RAZORPAY_KEY_SECRET", $pgcred['fworkingid']);

mysqli_close($conn);

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

use Razorpay\Api\Api;

$api = new Api($keyId, $keySecret);

$dbname = $dbnames[$funivcode];

$pconn = new mysqli(SERVERNAME, USERNAME, PASSWORD, $dbname);  
//IFNULL(cs.ftotalfee,0)

$fdigi = substr($appno,0,1);
// var_dump($fdigi);
$type = "";

if($fdigi == '1'){
    $type = 'EXAM';
} else if($fdigi == '2'){
    $type = 'RVRT';
}else if($fdigi == '4'){
    $type = 'OSER';
}else if($fdigi == '5'){
    $type = 'REGN';
}else if($fdigi == '8'){
    $type = 'ADM';
}else if($fdigi == '9'){
    $type = 'ADDCOR';
}else if($fdigi == '7'){
    $type = 'ADMFEE';
}

// var_dump($appno, $type);

$get_data = "";

if($type == 'EXAM') {

    $get_data = "select cs.fregno, cs.fdegree, cs.fcollcode, cs.fyear, cs.fexamtype, 
    IFNULL(cs.ftotalfee,0) as ftotalfee, s.fname,control.funivname,pdf_logo_path,
    IFNULL(s.fmobileno,'') as fmobileno,IFNULL(s.femail,'') as femail  
    from control, appcandsum cs 
    inner join student s on cs.fregno = s.fregno
    where appno = '{$appno}'";
} else if($type == 'RVRT') {
    $get_data = "select cs.fregno as fregno, IFNULL(cs.FTOTAL,0) as ftotalfee,
    control.funivname,pdf_logo_path, '999999999' as fmobileno
    ,'99999' as fname,'999999@gmail.com' as femail,cs.fdegree,cs.fcollcode,cs.fyear,cs.fexamtype
    from control, res_stud cs
    inner join college c on cs.fcollcode = c.fcollcode
    where appno = '{$appno}'";
} else if($type == 'OSER') {
    $get_data = "select FREGNO as fregno,FTOTAL as ftotalfee, fname, fmobile as fmobileno
	,femail as femail,fdegree,fcollcode,'' as fyear,'' as fexamtype from servtran where FAPPNO = '{$appno}'";
} else if($type == 'REGN') {
    $get_data = "select cs.fregno, cs.fdegree, cs.fcollcode, cs.fyear, cs.fexamtype, 
    IFNULL(cs.ftotalfee,0) as ftotalfee, s.fname,control.funivname,pdf_logo_path,
    IFNULL(s.fmobileno,'') as fmobileno,IFNULL(s.femail,'') as femail  
    from control, regcandsum cs 
    inner join student s on cs.fregno = s.fregno
    where fappno = '{$appno}'";
}else if($type == 'ADM') {
    $get_data = "select cs.fappno as fregno, 
    IFNULL(cs.FTOTFEE,0) as ftotalfee,control.funivname,pdf_logo_path, 
    fmobileno as fmobileno
    ,fname as fname, femail as femail,
    'PGET' as fdegree,
    'PGET' as fcollcode,
    '2020' as fyear,
    '2' as fexamtype
    from control, entstudadm cs 
    where fappno = '{$appno}'";
} else if ($type == 'ADDCOR'){
    $get_data = "select cs.faddappno as fregno, 
    IFNULL(cs.FTOTALFEE,0) as ftotalfee,control.funivname,pdf_logo_path, 
    fmobileno as fmobileno
    ,fname as fname, femail as femail,
    'PGET' as fdegree,
    'PGET' as fcollcode,
    '2020' as fyear,
    '2' as fexamtype
    from control, entaddcourse cs, entstudadm s
    where faddappno = '{$appno}' and cs.fappno = s.fappno";

}else if($type == 'ADMFEE') {
    $get_data = "select cs.fappno as fregno, 
    IFNULL(s.fadmfee,0) as ftotalfee,control.funivname,pdf_logo_path, 
    fmobileno as fmobileno
    ,fname as fname, femail as femail,
    cs.fdegree,
    cs.fcollcode,
    '2020' as fyear,
    '2' as fexamtype
    from control, entseatallot s  inner join entstudadm cs
	on cs.fappno = s.fappno and 
	cs.fround = s.fallotround
    where fallotno = '{$appno}'";
} 

// var_dump($get_data);

$result=$pconn->query($get_data); 

if (mysqli_num_rows($result) > 0) 
{
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) 
    {
        $fregno    =    $row['fregno'];
        $fdegree   =    $row['fdegree'];
        $fcollcode =    $row['fcollcode'];
        $fyear     =    $row['fyear'];
        $fexamtype =    $row['fexamtype'];
        $ftotalfee =    $row['ftotalfee'];
        $fname     =    $row['fname'];
        $fmobileno =    $row['fmobileno'];
        $femail    =    $row['femail'];
        $funivname =    $row['funivname'];
        $logo      =    $row['pdf_logo_path'];        
    }
}
else {
    echo "Some thing went wrong";
    die();
}

$number = rand(10000001,99999999);
//
// We create an razorpay order using orders api
// Docs: https://docs.razorpay.com/docs/orders

//
$orderData = [
    'receipt'         => $number,
    'amount'          => $ftotalfee * 100, // 2000 rupees in paise
    'currency'        => 'INR',
    'payment_capture' => 1 // auto capture
];

$razorpayOrder = $api->order->create($orderData);

$razorpayOrderId = $razorpayOrder['id'];

$_SESSION['razorpay_order_id'] = $razorpayOrderId;

$displayAmount = $amount = $orderData['amount'];
$description = "";
if($type == 'EXAM')
{
    $query = "update appcandsum set forderid = '{$razorpayOrderId}', FPAYGATEWAY = 'Razorpay', FPAYMENTYPE = 'Razorpay'
    where appno = '{$appno}'";
    $description = "Examination Fee Payment";
}else if($type == 'RVRT')
{
    $query = "update res_stud set forderid = '{$razorpayOrderId}', fpaymenttype = 'Razorpay', FPAYMENTYPE = 'OTHER BANKS'
    where appno = '{$appno}'";
    $description = "Re-Valuation / Re-Totalling Fee";
}else if($type == 'OSER')
{
    $query = "update servtran set forderid = '{$razorpayOrderId}', fpaymenttype = 'Razorpay'
    where fappno = '{$appno}'";
    $description = "Online Application Fee";
}else if($type == 'REGN')
{
    $description = "University Registration Fee";
    $query = "update regcandsum set forderid = '{$razorpayOrderId}', fpaymenttype = 'Razorpay'
    where fappno = '{$appno}'";
}else if($type == 'ADM')
{
    $description = "PG Registration Fee";
    $query = "update entstudadm set FORDERID = '{$razorpayOrderId}', FPAYTYPE = 'Razorpay' 
    where fappno = '{$appno}'";
}
else if($type == 'ADDCOR')
{
    $description = "PG Registration Addition Course Fee";
    $query = "update entaddcourse set FORDERID = '{$razorpayOrderId}', FPAYTYPE = 'Razorpay' 
    where faddappno = '{$appno}'";
}else if($type == 'ADMFEE')
{
    $description = "PG Registration Admission Fee";
    $query = "update entseatallot set FORDERID = '{$razorpayOrderId}', FPAYTYPE = 'Razorpay' 
    where fallotno = '{$appno}'";
}

$result1 =$pconn->query($query);

$query = "insert into pgdet(ftype, appno, fappdate, fpaygateway, fregno, fdegree, fcollcode, famount, 
forderid, fyear, fexamtype, fcreatedate)
values('{$type}', '{$appno}', current_date(), 'Razorpay', '{$fregno}', '{$fdegree}', '{$fcollcode}', '{$ftotalfee}',
'{$razorpayOrderId}', '{$fyear}', '{$fexamtype}', now())";
// var_dump($query);
$result1 =$pconn->query($query);

if ($displayCurrency !== 'INR')
{
    $url = "https://api.fixer.io/latest?symbols=$displayCurrency&base=INR";
    $exchange = json_decode(file_get_contents($url), true);

    $displayAmount = $exchange['rates'][$displayCurrency] * $amount / 100;
}

$checkout = 'manual';

if (isset($_GET['checkout']) and in_array($_GET['checkout'], ['automatic', 'manual'], true))
{
    $checkout = $_GET['checkout'];
}

$data = [
    "key"               => $keyId,
    "amount"            => $amount,
    "name"              => $funivname,
    "description"       => $description,
    "prefill"           => [
    "name"              => $fname,
    "email"             => $femail,
    "contact"           => $_SESSION['MOBILE'],
    ],
    "notes"             => [
    "appno"             => $appno,
    "univcode"          => $funivcode,
    "regno"             => $fregno
    ],
    "theme"             => [
    "color"             => "#F37254"
    ],
    "order_id"          => $razorpayOrderId,
    "continue"          => "http://192.168.0.32/verify.php?funivcode=023"
];

if ($displayCurrency !== 'INR')
{
    $data['display_currency']  = $displayCurrency;
    $data['display_amount']    = $displayAmount;
}

$json = json_encode($data);

require("checkout/{$checkout}.php");