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


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

<?php

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

// Create the Razorpay Order

use Razorpay\Api\Api;

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

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

$servername = "97.74.228.93";
$username = "logisys3_logu";
$password = "Logisys@2106";

/*$servername = "localhost";
$username = "root";
$password = "";*/
$dbname = "logisys3_comexam";
$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'];
    }
}

mysqli_close($conn);
    
$servername = "97.74.228.93";
$username = "logisys3_logu";
$password = "Logisys@2106";

/*$servername = "localhost";
$username = "root";
$password = "";*/
$dbname = $dbnames[$funivcode];

$conn = new mysqli($servername, $username, $password, $dbname);  
//IFNULL(cs.ftotalfee,0)
/*$get_data = "select cs.fregno, 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}'";

$result=$conn->query($get_data); */

$get_data = "select cs.fcollcode as fregno, (IFNULL(cs.famount,0)+IFNULL(c.fexfine,0)) as ftotalfee,control.funivname,pdf_logo_path, '999999999' as fmobileno
,'99999' as fname,'999999@gmail.com' as femail
from control, collfundtransfer cs 
inner join college c on cs.fcollcode = c.fcollcode
where fid = '{$appno}'";

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

if (mysqli_num_rows($result) > 0) 
{
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) 
    {
        $fregno    =    $row['fregno'];
        $ftotalfee =    $row['ftotalfee'];
        $fname     =    $row['fname'];
        $fmobileno =    $row['fmobileno'];
        $femail    =    $row['femail'];
        $funivname =    $row['funivname'];
        $logo      =    $row['pdf_logo_path'];        
    }
}

$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'];

$query = "update collfundtransfer set forderid = '{$razorpayOrderId}', fpaymenttype = 'razorpay' 
where fid = '{$appno}'";

$result1 =$conn->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'];
}

//var_dump($checkout);die();

$data = [
    "key"               => $keyId,
    "amount"            => $amount,
    "name"              => $funivname,
    "description"       => "College Fund Transfer",
    "image"             => "http://studentportal.universitysolutions.in/bcu/img/logo.jpg",
    "prefill"           => [
    "name"              => $fname,
    "email"             => $femail,
    "contact"           => "9999999999",
    ],
    "notes"             => [
    "appno"             => $appno,
    "univcode"          => $funivcode,
    "regno"             => $fregno
    ],
    "theme"             => [
    "color"             => "#F37254"
    ],
    "order_id"          => $razorpayOrderId,
];

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

$json = json_encode($data);

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