One Hat Cyber Team
Your IP :
216.73.216.186
Server IP :
91.108.106.45
Server :
Linux in-mum-web1837.main-hosting.eu 5.14.0-503.34.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Mar 27 06:00:50 EDT 2025 x86_64
Server Software :
LiteSpeed
PHP Version :
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
u322583024
/
domains
/
awaha.in
/
public_html
/
View File Name :
place-and-order.php
<?php session_name('vaishnavi_awaha'); session_start(); $servername = "localhost"; // Change if needed $username = "u322583024_awaha"; // Change to your DB username $password = "AwahaSoap@2025"; // Change to your DB password $dbname = "u322583024_awaha"; // Change to your database name $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Get order_id from URL if (!isset($_GET['order_id']) || empty($_GET['order_id'])) { die("Order ID is required."); } $order_id = $_GET['order_id']; // Fetch order details from the database $sql = "SELECT orders.*, users.name AS customer_name, users.email AS billing_email FROM orders INNER JOIN users ON orders.user_id = users.id WHERE orders.order_id = '$order_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { $order = $result->fetch_assoc(); $token = $order['shiprocket_token']; // Ensure this column exists in your table // Decode products JSON from orders table $products = json_decode($order['products'], true); $order_items = []; // Fetch product details from products table foreach ($products as $item) { $product_id = $item['product_id']; $quantity = $item['quantity']; $discount_price = $item['product_discount_price']; $product_sql = "SELECT product_name, sku_id FROM products WHERE id = '$product_id'"; $product_result = $conn->query($product_sql); if ($product_result->num_rows > 0) { $product = $product_result->fetch_assoc(); $order_items[] = [ "name" => $product['product_name'], "sku" => $product['sku_id'], "units" => $quantity, "selling_price" => $discount_price, "discount" => "", "tax" => "", "hsn" => $product['sku_id'] ]; } } // Prepare order payload $order_data = [ "order_id" => $order['order_id'], "order_date" => date("Y-m-d H:i"), // Use current date-time or from DB "pickup_location" => $order['pickup_location'], "billing_customer_name" => $order['customer_name'], "billing_last_name" => $order['customer_name'], "billing_address" => $order['billing_address'], "billing_address_2" => $order['billing_address'], "billing_city" => $order['billing_city'], "billing_pincode" => $order['billing_zip'], "billing_state" => $order['billing_state'], "billing_country" => $order['billing_country'], "billing_email" => $order['billing_email'], "billing_phone" => $order['billing_phone'], "shipping_is_billing" => true, // Assuming shipping details are the same as billing "order_items" => $order_items, "payment_method" => $order['payment_method'], "shipping_charges" => 0, "giftwrap_charges" => 0, "transaction_charges" => 0, "total_discount" => 0, "sub_total" => $order['total_amount'], "length" => 10, "breadth" => 7, "height" => 7, "weight" => 0.5 ]; // Call Shiprocket API to place order $curl = curl_init(); curl_setopt_array($curl, [ 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 => json_encode($order_data), CURLOPT_HTTPHEADER => [ "Content-Type: application/json", "Authorization: Bearer $token" ], ]); $response = curl_exec($curl); curl_close($curl); // Decode API response $response_data = json_decode($response, true); if (isset($response_data['order_id'])) { // Redirect to success page with order_id header("Location: order-success.php?order_id=" . urlencode($order_id)); exit(); } else { echo "Order creation failed. Response: " . json_encode($response_data); } } else { echo "No order found with Order ID: $order_id"; } $conn->close(); ?>