Server IP : 103.53.40.154 / Your IP : 3.147.82.252 Web Server : Apache System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : ppcad7no ( 715) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home2/ppcad7no/sainicraneservice.in/../snackpoint.co.nz/../deergham.com/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php include_once('admin/config.php'); if ($_SERVER["REQUEST_METHOD"] === "POST") { if (isset($_POST['submit_btn'])) { $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $state = $_POST['state']; $pin = $_POST['pin']; $address = $_POST['address']; $book_by = $_POST['book_by']; $post_by = $_POST['post_by']; // $property_name = $_POST['property_name']; // $offer_rate = $_POST['product_prices']; $offer_rate = isset($_POST['product_prices']) ? implode(',', $_POST['product_prices']) : ''; $quantities = isset($_POST['product_quantities']) ? implode(',', $_POST['product_quantities']) : ''; $property_name = isset($_POST['product_names']) ? implode(',', $_POST['product_names']) : ''; $indianTimeZone = new DateTimeZone('Asia/Kolkata'); $indianDateTime = new DateTime('now', $indianTimeZone); $date_time = $indianDateTime->format('Y-m-d H:i:s'); $query = "INSERT INTO `tbl_booking`(`booking_name`, `state`, `pin`, `address`, `booking_for`, `contact`, `booking_email`, `booking_rate`, `date_time`, `quantities`, `payment_status`, `booking_status`, `booking_of`,`book_by`) VALUES ('$name','$state', '$pin', '$address', '$property_name', '$phone', '$email', '$offer_rate', '$date_time', '$quantities', 'Pending', 'Pending','$post_by','$book_by')"; $result = mysqli_query($db, $query) or die("Query unsuccessful"); if($result){ // echo "<script> // window.alert('Successfully Submit Your Query! We will contact you soon'); // window.location.href = 'thanks.html'; // </script>"; $insertedId = mysqli_insert_id($db); $payrate = $offer_rate * 100; try { $merchantKey = 'b0a94d38-06b4-402b-bce4-36dcf8a7b4dc'; $transactionId = uniqid('TXL', true); $arrayVar = [ "merchantId" => "M22A3V1UESO6F", "merchantTransactionId" => $transactionId, "merchantUserId" => "$insertedId", "amount" => $payrate, // "redirectUrl" => "https://www.deergham.com/thanks.html?amount=$offer_rate&payment_id=$transactionId&inserted_id=$insertedId", "redirectUrl" => "https://www.deergham.com/check.php?payment_request_id=$insertedId&amount=$offer_rate&transaction_id=$transactionId&ord_payment_gateway=PhonePe", "redirectMode" => "POST", "callbackUrl" => "https://www.deergham.com/webhook.php", "mobileNumber" => $phone, "paymentInstrument" => ["type" => "PAY_PAGE"], ]; // Encoding payment request data to JSON $jsonPayload = json_encode($arrayVar); // Encoding JSON payload to base64 $base64EncodedPayload = base64_encode($jsonPayload); // Calculating checksum $Checksum = hash('sha256', $base64EncodedPayload . "/pg/v1/pay" . $merchantKey) . '###1'; // PhonePe API URL $url = "https://api.phonepe.com/apis/hermes/pg/v1/pay"; // Setting request headers $headers = array( "Content-Type: application/json", "X-VERIFY: " . $Checksum, "accept: application/json" ); // Constructing request data array $data = json_encode(array( "request" => $base64EncodedPayload )); // Initiating cURL session $ch = curl_init(); // Setting cURL options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Executing cURL request $response = curl_exec($ch); // Checking for cURL errors if (curl_errno($ch)) { throw new Exception('Curl error: ' . curl_error($ch)); } // Closing cURL session curl_close($ch); // Decoding response JSON $responseData = json_decode($response, true); if (isset($responseData['success']) && $responseData['success'] == 1) { $paymentUrl = $responseData['data']['instrumentResponse']['redirectInfo']['url']; header("Location: $paymentUrl"); exit; } else { // Payment request failed $sql = "UPDATE tbl_booking SET payment_status='Failed' WHERE book_id='$insertedId'"; $res = db_query($sql); // Redirecting user to the failure page header("Location: https://www.deergham.com/failed.html"); exit; } } catch (Exception $e) { // Logging the error for debugging error_log($e->getMessage()); // Redirecting user to the failure page with error message header('Location: https://www.deergham.com/failed.html?error=' . urlencode($e->getMessage())); exit; } } } } ?>