MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/indiatoursol/backup/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/indiatoursol/backup/admin/function.php
<?php 
function ShipRocketToken($conn) {
	   $sqlsh=mysqli_query($conn,"select * from tbl_shiprocket_token") or die(mysqli_query($conn));
	   	$rowsh=mysqli_fetch_assoc($sqlsh);
	   	date_default_timezone_set('Asia/Kolkata');
	    $add_on=strtotime($rowsh['added_on']);
	   	$current_time=strtotime(date('Y-m-d h:i:s'));
	    $diff_time=$current_time-$add_on;
        if($diff_time>86400)
        {
            $token=GenerateShiprocketToken($conn);
        }
        else
        {
             $token=$rowsh['token'];
        }
        return  $token;
	}
	function GenerateShiprocketToken($conn) {
	    $curl = curl_init();
          curl_setopt_array($curl, array(
            CURLOPT_URL => "https://apiv2.shiprocket.in/v1/external/auth/login",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS =>"{\n    \"email\": \"support@lensoz.com\",\n    \"password\": \"Lensoz@#331\"\n}",
            CURLOPT_HTTPHEADER => array(
              "Content-Type: application/json"
            ),
          ));
          $SR_login_Response = curl_exec($curl);
          curl_close($curl);
          $SR_login_Response_out = json_decode($SR_login_Response);
          $token = $SR_login_Response_out->{'token'};
          date_default_timezone_set('Asia/Kolkata');
          $added_on=date('Y-m-d h:i:s');
          $query=mysqli_query($conn,"update tbl_shiprocket_token set added_on='$added_on',token='$token' where id='1'");
          return $token;
	}
	
	   function PlaceShipRocketOrder($token,$orderid,$conn) {
	       
	      $sqlsh=mysqli_query($conn,"select view_user_order_details.*,tbl_product.productname from view_user_order_details,tbl_product where view_user_order_details.orderId='$orderid' and view_user_order_details.product_id=tbl_product.productid") or die(mysqli_query($conn));
	
	        	$rowsh=mysqli_fetch_assoc($sqlsh);
    	        $order_date=$rowsh['orderDate'];
    	       
    	        $username=$rowsh['fName'];  
	        	$address=$rowsh['address'];
	        	$city=$rowsh['city'];
	        	$state=$rowsh['state'];
	        	$country=$rowsh['country'];
	        	$email=$rowsh['email'];
	        	$phone=$rowsh['phone'];
	            $pineCode=$rowsh['pinCode'];
	            $productname=$rowsh['productname'];
	            $skucode=$rowsh['sku'];
	            $grandTotal=$rowsh['grandTotal'];
	            $paymentType=$rowsh['paymentType'];
	            if($paymentType=='COD')
	            {
	                 $paymenttype='COD';
	            }
	            else if($paymentType=='Online Payment')
	            {
	                 $paymenttype='Prepaid';
	            }
	             
	          $curl = curl_init();
              curl_setopt_array($curl, array(
                CURLOPT_URL => "https://apiv2.shiprocket.in/v1/external/orders/create/adhoc",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => "",
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 0,
                CURLOPT_FOLLOWLOCATION => true,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => "POST",
                CURLOPT_POSTFIELDS =>'{"order_id": "'.$orderid.'",
              "order_date": "'.$order_date.'",
              "pickup_location": "Primary",
              "billing_customer_name": "'.$username.'",
              "billing_last_name": "",
              "billing_address": "'.$address.'",
              "billing_address_2": "",
              "billing_city": "'.$city.'",
              "billing_pincode": "'.$pineCode.'",
              "billing_state": "'.$state.'",
              "billing_country": "India",
              "billing_email": "'.$email.'",
              "billing_phone": "'.$phone.'",
              "shipping_is_billing": true,
              "shipping_customer_name": "",
              "shipping_last_name": "",
              "shipping_address": "",
              "shipping_address_2": "",
              "shipping_city": "",
              "shipping_pincode": "",
              "shipping_country": "",
              "shipping_state": "",
              "shipping_email": "",
              "shipping_phone": "",
              "order_items": [
                {
                  "name": "'.$productname.'",
                  "sku": "'.$skucode.'",
                  "units": 1,
                  "selling_price": "'.$grandTotal.'",
                  "discount": "",
                  "tax": "",
                  "hsn": 9004
                }
              ],
              "payment_method": "'.$paymenttype.'",
                  "shipping_charges": 0,
                  "giftwrap_charges": 0,
                  "transaction_charges": 0,
                  "total_discount": 0,
                  "sub_total": "'.$grandTotal.'",
                  "length": 10,
                  "breadth": 4,
                  "height": 14,
                  "weight": 0.5
                	}',
                CURLOPT_HTTPHEADER => array(
                  "Content-Type: application/json",
            	   "Authorization: Bearer $token"
                ),
              ));
              $SR_login_Response = curl_exec($curl);
              curl_close($curl);
              //$SR_login_Response_out = json_decode($SR_login_Response);
            //   echo '<pre>';
            //   print_r($SR_login_Response);
	   }

?>

MMCT - 2023