BLACKSITE
:
216.73.217.4
:
104.37.75.190 / alpenpass.ca
:
Linux server3.pointsplan.com 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
:
/
home2
/
apca
/
www
/
Upload File:
files >> //home2/apca/www/rental_success.php
<?php session_start(); include('includes/config.php'); require '../vendor/autoload.php'; \Stripe\Stripe::setApiKey('sk_test_51QGPzg2K4CCTmLnJfSpCEOayDxZj6Cidz18qdEqZ19kcMIwWuOtfzTKNjW7xTc4OdAYGkRiATOFK0aHx9t2h0ujk00IXZmZnNA'); function getAllRentalCartItems($dbh, $user_id) { // Prepare and execute the query to get all rental items for the user $stmt = $dbh->prepare("SELECT * FROM rental_cart WHERE user_id = :user_id ORDER BY created_at DESC"); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->execute(); // Fetch all rows as an associative array return $stmt->fetchAll(PDO::FETCH_ASSOC); } $session_id = ($_GET['session_id'])? $_GET['session_id']:''; $customerName=$_POST['name']; if ($session_id) { $checkout_session = \Stripe\Checkout\Session::retrieve($session_id); $customer_email = $checkout_session->customer_email; $amount_total = $checkout_session->amount_total / 100; // Convert back to dollars } else { echo "<h1>Error</h1>"; echo "<p>Unable to retrieve payment details.</p>"; } if (isset($_GET['session_id'])) { $session_id = $_GET['session_id']; try { // Retrieve the checkout session $checkout_session = \Stripe\Checkout\Session::retrieve($session_id); // Access payment details $payment_intent = $checkout_session->payment_intent; $customer_email = $checkout_session->customer_email; // Optionally, retrieve payment intent details $payment_details = \Stripe\PaymentIntent::retrieve($payment_intent); } catch (Exception $e) { echo "Error retrieving session: " . htmlspecialchars($e->getMessage()); } } else { echo "No session ID provided."; } if(isset($session_id)){ $user_email=$_SESSION['login']; $user_id = $_SESSION['id']; // Fetch all rental cart details from the database $cart_items = getAllRentalCartItems($dbh, $user_id); if (!$cart_items) { die("Error: No rental cart found."); } // Debug output (optional) //echo "<pre>"; //print_r($cart_items); //echo "</pre>"; // Initialize totals $total_due = 0; $taxable_total = 0; $gst_total = 0; $pst_total = 0; // Loop through all rental items $grand_total=0; $grand_total_rental_fee=0; foreach ($cart_items as $item) { $total=0; $useremail=$_SESSION['login']; $fromdate = $item['from_date']; $todate = $item['to_date']; $vehicleName = $item['vehicle_name']; $vehicleID = $item['vehicle_id']; $message = $item['message']; $rateName = $item['rate_name']; $bookingno = $item['booking_no']; $deposit = $item['security_deposit']; $amount_charged = $item['amount_charged']; $insurance_fee= $item['insurance_fee']; $vehicle=$_SESSION['vehicleID']; $total=$deposit+$amount_charged+$insurance_fee; $GST=($total-$deposit)*.05; $PST=($total-$deposit)*.07; $taxableTotal=($total-$deposit); $grand_total+=$total+$gst+$pst; $grand_total_rental_fee+=$amount_charged; $grand_total_deposit+=$deposit; $totalDue=$grand_total; /** * * $fromdate=$_SESSION['fromdate']; * $todate=$_SESSION['todate']; * $vehicleName=$_SESSION['vehicleName']; * $vehicleID=$_SESSION['vehicleID']; * $message=$_SESSION['message']; * $useremail=$_SESSION['login']; * $rateName=$_SESSION['rateName']; * $bookingno=$_SESSION['bookingno']; * $vehicle=$_SESSION['vehicleID']; * $deposit=$_SESSION['deposit']; * $depositReturned=$_SESSION['depositReturned']; * $insurance=$_SESSION['insurance']; * $taxableTotal=$_SESSION['taxableTotal']; * $GST=$_SESSION['GST']; * $PST=$_SESSION['PST']; * * */ try { $dbh->beginTransaction(); // Start transaction $sql = "INSERT INTO tblbooking (BookingNumber, userEmail, VehicleId, FromDate, ToDate, message, Status, amountCharged, rateName,stripePaymentCode,vehicle, deposit, depositReturned, insurance, taxableTotal, GST,PST) VALUES (:bookingno, :useremail, :vhid, :fromdate, :todate, :message, :status, :amountCharged, :rateName,:stripePaymentCode,:vehicle, :deposit, :depositReturned, :insurance, :taxableTotal,:GST,:PST)"; $status = 0; $query = $dbh->prepare($sql); $query->bindParam(':bookingno', $bookingno, PDO::PARAM_STR); $query->bindParam(':useremail', $useremail, PDO::PARAM_STR); $query->bindParam(':vhid', $vehicleID, PDO::PARAM_STR); $query->bindParam(':fromdate', $fromdate, PDO::PARAM_STR); $query->bindParam(':todate', $todate, PDO::PARAM_STR); $query->bindParam(':message', $message, PDO::PARAM_STR); $query->bindParam(':status', $status, PDO::PARAM_STR); $query->bindParam(':vehicle',$vehicle, PDO::PARAM_STR); $query->bindParam(':deposit',$deposit, PDO::PARAM_STR); $query->bindParam(':depositReturned',$depositReturned, PDO::PARAM_STR); $query->bindParam(':insurance',$insurance, PDO::PARAM_STR); $query->bindParam(':taxableTotal',$taxableTotal, PDO::PARAM_STR); $query->bindParam(':GST',$GST, PDO::PARAM_STR); $query->bindParam(':PST',$PST, PDO::PARAM_STR); $amountCharged=$payment_details->amount_received / 100; $query->bindParam(':amountCharged',$amountCharged, PDO::PARAM_STR); $query->bindParam(':rateName',$rateName, PDO::PARAM_STR); $query->bindParam(':stripePaymentCode',$payment_intent, PDO::PARAM_STR); $query->execute(); $errorInfo = $query->errorInfo(); if ($errorInfo[0] != '00000') { // Check if there's an error echo "SQL Error: " . $errorInfo[2]; } if ($query->rowCount() > 0) { $lastInsertId = $dbh->lastInsertId(); $dbh->commit(); // Commit the transaction } else { $dbh->rollBack(); // Roll back the transaction on failure echo "Insert failed. No rows affected."; } } catch (PDOException $e) { $dbh->rollBack(); // Roll back the transaction on error echo "Error: " . $e->getMessage(); } /** if(!$lastInsertId){ echo "<script>alert('Something went wrong. Please try again. $myError');</script>"; // echo "<script type='text/javascript'> document.location = 'listing.php'; </script>"; } else{ echo "<script>alert('The $vehicleName is already booked for the time you selected. Please try another vehicle or another date and time');</script>"; //echo "<script type='text/javascript'> document.location = 'listing.php'; </script>"; } */ // Recipient Email //$to = "Info@alpenpass.ca"; $to="canadacoder@gmail.com"; // Email Subject $subject = "New Booking from the Alpenpass website"; // Email Headers $headers = "From: " . $email . "\r\n"; $headers .= "Reply-To: " . $email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; // Email Message (HTML format) $body = " <html> <head> <title>Alpenpass Booking</title> </head> <body> <p><strong>You have received the following booking from the Alpenpass Contact Us page:</strong></p> <table border='1' cellspacing='0' cellpadding='10'> <tr><td><strong>Booking No.:</strong></td><td>{$bookingno}</td></tr> <tr><td><strong>Vehicle:</strong></td><td>{$vehicle}</td></tr> <tr><td><strong>From:</strong></td><td>{fromdate}</td></tr> <tr><td><strong>To:</strong></td><td>{$todate}</td></tr> <tr><td><strong>Amount Paid:</strong></td><td>{$amountCharged}</td></tr> </table> <br> <p><br>Alpenpass Website</p> </body> </html> "; // Send the email $mailSuccess = mail($to, $subject, $body, $headers); // Check if the mail was sent successfully if ($mailSuccess) { $msg.= "Your message has been sent successfully!"; } else { $error.= "There was an issue sending your message. Please try again later."; } } $user_id=$_SESSION['id']; // Step 3: Delete rental cart items after saving order $stmt = $dbh->prepare("DELETE FROM rental_cart WHERE user_id = :user_id"); $stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR); $stmt->execute(); } $head.=" <style> .imageBox{ height: 450px; overflow:hidden; } .imageStyle{ width: 100%; object-fit: cover; min-height: 450px; } #rateList .currency{ text-align:right; } #rateList td{ font-weight: bold; } .fr{ text-align: right; padding-right: 20px; } .error-message { color: red; font-size: 0.9em; margin-top: 5px; display: none; position: relative; /* changed from absolute to relative */ } .form-group { position: relative; margin-bottom: 20px; } .form-group.has-error { margin-bottom: 40px; /* Increase margin when error is shown */ } </style>"; include("includes/head.php"); include("includes/header.php"); echo" <div class=\"container\"> <div class=\"row justify-content-center\"> <div class=\"col-sm-12\">"; echo "<h1><br /><br />Payment Successful!</h1>"; echo "<p>Thank you for your payment,".$_POST['name']." $customer_email.</p>"; echo "<p>Amount Paid: ".number_format($amount_total,2)." CAD</p>"; //echo "<p>Payment Intent: " . htmlspecialchars($payment_intent) . "<br>"; echo "<p>Customer Email: " . htmlspecialchars($customer_email) . "<br></p>"; echo "<p>Payment Status: " . htmlspecialchars($payment_details->status) . "<br>"; $retrievePaid=htmlspecialchars($payment_details->amount_received / 100); echo "<br /><strong>Amount Paid: ".number_format($retrievePaid,2)." CAD</strong><br></p>"; ?> </div> </div> </div>