Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ecampus.ncriptech.com/application/libraries/../libraries/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); require_once APPPATH.'third_party/vendor/autoload.php'; use Razorpay\Api\Api; use Razorpay\Api\Errors\SignatureVerificationError; class Razorpay { public function rzRedirect($param){ header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); if(!empty($param)){ if((isset($param['key']) && isset($param['key_secret'])) && (!empty($param['key']) && !empty($param['key_secret']))){ $api = new Api($param['key'], $param['key_secret']); if(isset($param['order_amount']) && $param['order_amount']>0){ $orderData = [ 'receipt' => $param['reciept_no'], 'amount' => $param['order_amount'] * 100, // 1 rupees in paise 'currency' => 'INR', 'payment_capture' => 1 // auto capture ]; $razorpayOrder = $api->order->create($orderData); if(!empty($razorpayOrder) && $razorpayOrder['status']=='created'){ $razorpayOrderId = $razorpayOrder['id']; $data = [ "key" => $param['key'], "amount" => $param['order_amount'], "name" => $param['order_name'], "description" => $param['order_description'], "image" => $param['order_logo'], "prefill" => [ "name" => $param['order_name'], "email" => $param['order_cust_email'], "contact" => $param['order_cust_ph'], ], "notes" => [ "address" => $param['order_address'], "merchant_order_id" => $param['order_id'], ], "theme" => [ "color" => $param['order_screen_color'] ], "order_id" => $razorpayOrderId, ]; // if ($displayCurrency !== 'INR') // { // $data['display_currency'] = $displayCurrency; // $data['display_amount'] = $displayAmount; // } $json = json_encode($data); //print_obj($json);die; ?> <button id="rzp-button1" style="display: none;">Pay with Razorpay</button> <form name='razorpayform' action="<?php echo $param['order_action_url'];?>" method="POST"> <input type="hidden" name="razorpay_order_code" id="razorpay_order_code" value="<?php echo $param['order_id'];?>"> <input type="hidden" name="razorpay_order_id" id="razorpay_order_id" value="<?php echo $razorpayOrderId;?>"> <input type="hidden" name="razorpay_payment_id" id="razorpay_payment_id"> <input type="hidden" name="razorpay_signature" id="razorpay_signature" > </form> <script> // Checkout details as a json var options = <?php echo $json?>; /** * The entire list of Checkout fields is available at * https://docs.razorpay.com/docs/checkout-form#checkout-fields */ options.handler = function (response){ document.getElementById('razorpay_payment_id').value = response.razorpay_payment_id; document.getElementById('razorpay_signature').value = response.razorpay_signature; document.razorpayform.submit(); }; // Boolean whether to show image inside a white frame. (default: true) options.theme.image_padding = false; options.modal = { ondismiss: function() { //alert("This code runs when the popup is closed"); // localStorage.setItem('razorpay_status','cancelled'); //_load_install_ments_form(stu_id,admission_id,inst_id,course_id,session_id); window.location.reload(); $('#rzdiv').html(''); }, // Boolean indicating whether pressing escape key // should close the checkout form. (default: true) escape: false, // Boolean indicating whether clicking translucent blank // space outside checkout form should close the form. (default: false) backdropclose: false }; var rzp = new Razorpay(options); document.getElementById('rzp-button1').onclick = function(e){ rzp.open(); e.preventDefault(); //localStorage.setItem('razorpay_status','initiated'); } </script> <?php }else{ return 'Uncaught error occurred.Try after some time.'; } }else{ return 'Payment can not be proceed either payment amount not set or it is zero based amount given.'; } }else{ return 'Keys are missing'; } }else{ return 'Parameters are empty'; } } public function rzResponse($param){ // header("Pragma: no-cache"); // header("Cache-Control: no-cache"); // header("Expires: 0"); $success = true; if(!empty($param)){ if((isset($param['key']) && isset($param['key_secret'])) && (!empty($param['key']) && !empty($param['key_secret']))){ $api = new Api($param['key'], $param['key_secret']); if((isset($param['order_id']) && isset($param['order_payment_id']) && isset($param['order_signature'])) && (!empty($param['order_id']) && !empty($param['order_payment_id']) && !empty($param['order_signature']))){ try { // Please note that the razorpay order ID must // come from a trusted source (session here, but // could be database or something else) $attributes = array( 'razorpay_order_id' => $param['order_id'], 'razorpay_payment_id' => $param['order_payment_id'], 'razorpay_signature' => $param['order_signature'] ); $verification=$api->utility->verifyPaymentSignature($attributes); // print_obj($verification);die; } catch(SignatureVerificationError $e) { $success = false; $return['error'] = 'Razorpay Error : ' . $e->getMessage(); } if ($success === true) { $paymentId=$param['order_payment_id']; $payment_response=$api->payment->fetch($paymentId); //print_obj($payment_response);die; $payment_data=array( 'status'=>$payment_response['status'], 'customer_email'=>$payment_response['email'], 'customer_ph'=>$payment_response['contact'], 'payment_id'=>$payment_response['id'], 'order_id'=>$payment_response['order_id'], 'payment_signature'=>$param['order_signature'], 'invoice_id'=>$payment_response['invoice_id'], 'payment_amount'=>$payment_response['amount']/100 ); $return['payment_response']=$payment_data; } else { $return['error']='Razorpay Error'; } }else{ $return['error']='Order Id & Payment Id are required.'; } }else{ $return['error']='Keys are missing'; } }else{ $return['error']='Prameters are empty'; } return json_encode($return); } public function rzSettlements($param){ header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); if(!empty($param)){ if((isset($param['key']) && isset($param['key_secret'])) && (!empty($param['key']) && !empty($param['key_secret']))){ $api = new Api($param['key'], $param['key_secret']); if($param['type']==='recon'){ $response=$api->settlement->settlementRecon(array('year' => $param['year'], 'month' => $param['month'], 'day'=>$param['day'])); }else if($param['type']==='all'){ $options=null; $response=$api->settlement->all($options); } print_obj($response); }else{ return 'Keys are missing'; } }else{ return 'Parameters are empty'; } } public function rzFetchPayments($param){ header("Pragma: no-cache"); header("Cache-Control: no-cache"); header("Expires: 0"); if(!empty($param)){ if((isset($param['key']) && isset($param['key_secret'])) && (!empty($param['key']) && !empty($param['key_secret']))){ $api = new Api($param['key'], $param['key_secret']); if(isset($param['fetch_type']) && $param['fetch_type']==='all'){ $options=null; $response=$api->payment->all($options); }else if(isset($param['fetch_type']) && $param['fetch_type']==='single'){ if(isset($param['payment_id']) && $param['payment_id']!==null){ $response=$api->payment->fetch($param['payment_id']); return $response; }else{ return 'Payment id is missing'; } } }else{ return 'Keys are missing'; } }else{ return 'Parameters are empty'; } } }