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 : 3.16.50.1


Current Path : /var/www/html/cuk/orms_nt_stop/razorpay/
Upload File :
Current File : /var/www/html/cuk/orms_nt_stop/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'];
$userid     = $_POST['userid'];
    
$servername = "97.74.228.93";
$username   = 'logisys3_logu';
$password  = "Logisys@2106";
$dbname = 'logisys3_orms_nt';

$conn = new mysqli($servername, $username, $password, $dbname);  

// $get_data = "select cs.fcucetno as fregno, (IFNULL(cs.famount,0)) as ftotalfee,
// cs.fmobileno as fmobileno
// ,cs.fname as fname,cs.femail as femail
// from student cs
// where cs.fappno = '{$appno}'";

$get_data = "SELECT p.fuserid as fregno,s.fname,p.fappno,s.fmobile as fmobileno,femailid as femail,
		if(s.fpwd = 'TRUE',0,c.famount) as ftotalfee
				  FROM perdetl s INNER JOIN mascat c ON s.fcatcode  = c.fcatid
				  INNER JOIN postdet p ON s.fuserid = p.fuserid 
                  where p.fuserid = '{$userid}' and p.fappno = '{$appno}'";
                  
//var_dump($get_data);
$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'];
        
    }
}

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



//$ftotalfee
//$ftotalfee = 1;
$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 postdet set fpaymentorderid = '{$razorpayOrderId}'
where fappno = '{$appno}' and fuserid = '{$userid}'";

$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"              => "Central University of Karnataka",
    "description"       => "Non-Teaching Recruitment Sept-2019",
    "image"             => "http://universitysolutions.in/cuk/orms/images/logo.jpg",
    "prefill"           => [
    "name"              => $fname,
    "email"             => $femail,
    "contact"           => $fmobileno,
    ],
    "notes"             => [
    "appno"             => $appno,
    "userid"             => $userid
    ],
    "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");