Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/public_html/ |
<?php use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;use PHPMailer\PHPMailer\SMTP; session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?> - Payment Result</title>
<?php
if (isset($_POST['full_coverage'])){
$order_id = mysqli_real_escape_string($con,$_POST['order_id']);
$action = "Full Payment from Wallet";
//get percentage off
$stmt40 = $con -> prepare('SELECT * FROM top_stuff');
$stmt40 -> execute();
$stmt40 -> store_result();
$stmt40 -> bind_result($id43,$first_order_percentage);
$numrows40 = $stmt40 -> num_rows();
if($numrows40 > 0){
while ($stmt40 -> fetch()) {
}}
$stmt_order = $con -> prepare('SELECT * FROM my_orders WHERE order_id=?');
$stmt_order -> bind_param('s',$order_id);
$stmt_order -> execute();
$stmt_order -> store_result();
$stmt_order -> bind_result($id,$user_id_db,$order_id,$grand_total,$nice_date,$horrible_date,$order_status,$email_succesful,$email_delivered,$delivery_zone_complete,$payment_method);
$numrows_order = $stmt_order -> num_rows();
if($numrows_order > 0){
while ($stmt_order -> fetch()) { }
}
$divided = explode('-',$delivery_zone_complete,2);
$delivery_zone_id = $divided[0];
$delivery_zone_fee = $divided[1];
$gt = $grand_total + $delivery_zone_fee;
$stmt_n = $con -> prepare('SELECT * FROM users WHERE user_id=?');
$stmt_n -> bind_param('s',$user_id_db);
$stmt_n -> execute();
$stmt_n -> store_result();
$stmt_n -> bind_result($id,$user_id,$first_name,$last_name,$email,$password,$phone,$address,$date_signed_up);
$numrows_n = $stmt_n -> num_rows();
if($numrows_n > 0){
$signed_in="Yes";
while ($stmt_n -> fetch()) { }
}
$stmt1 = $con -> prepare('SELECT * FROM cart_details WHERE order_id=?');
$stmt1 -> bind_param('s',$order_id);
$stmt1 -> execute();
$stmt1 -> store_result();
$stmt1 -> bind_result($id,$order_id,$product_id,$product_title,$product_price,$product_image,$qty);
$numrows1 = $stmt1 -> num_rows();
if($numrows1 > 0){
while ($stmt1 -> fetch()) {
$total_per_product = $qty * $product_price;
$total_array[] = $total_per_product;
}
}
$grand_total = array_sum($total_array);
//check if they have money in the wallet.
$total_wallet=0; $success = "Success"; $failed = "Failed";
$stmt_withdraw = $con -> prepare('SELECT * FROM wallet WHERE user_id = ? AND status = ?');
$stmt_withdraw -> bind_param('ss',$user_id,$success);
$stmt_withdraw -> execute();
$stmt_withdraw -> store_result();
$stmt_withdraw -> bind_result($w_id,$wallet_id,$user_id,$wallet_order_id,$wallet_amount,$amount_remaining,$wallet_type,$wallet_action,$wallet_status,$wallet_date);
$numrows_withdraw = $stmt_withdraw -> num_rows();
if($numrows_withdraw > 0){
while ($stmt_withdraw -> fetch()) {
if($wallet_type == "Credit"){
$total_wallet += $wallet_amount;
}
if($wallet_type == "Debit"){
$total_wallet -= $wallet_amount;
}
}
}
//find out if this is the first payment
$stmt4000 = $con -> prepare('SELECT id FROM my_orders WHERE user_id = ?');
$stmt4000 -> bind_param('s',$user_id);
$stmt4000 -> execute();
$stmt4000 -> store_result();
$stmt4000 -> bind_result($id43yy);
$numrows4000 = $stmt4000 -> num_rows();
if($numrows4000 > 1){
while ($stmt4000 -> fetch()) {$first_order = "false";}
}
else{$first_order = "true";}
//calculate first_order
if($first_order == "true"){
$percentInDecimal = $first_order_percentage / 100;
$first_order_off = $percentInDecimal * $grand_total;
}
else{
$first_order_off = 0;
}
//calculate bank charges
//$percentInDecimal = $percent_off / 100;
//$bank_charges = $percentInDecimal * $grand_total;
$bank_charges = 0;
//grand total
$gt = $grand_total + $delivery_zone_fee + $bank_charges - $first_order_off;
$transaction_date = date('Y-m-d H:i:s');
if($order_status !=="Completed"){
if($total_wallet >= $gt){
$wallet_id = substr(md5(rand()), 0, 20);
$fund_amount = $gt;
$amount_remaining=0;
$db_id=0;
$type="Debit";
$success = "Success";
$date_wallet = date('Y-m-d H:i:s');
$stmt_wa = $con -> prepare('INSERT INTO wallet VALUES (?,?,?,?,?,?,?,?,?,?)');
$stmt_wa -> bind_param('isssssssss', $db_id,$wallet_id,$user_id,$order_id,$fund_amount,$amount_remaining,$type,$action,$success,$date_wallet);
$stmt_wa -> execute();
//send email
$subject ="$first_name $last_name successfully paid online";
$message1="";
$message1 .= "
<div style='font-family:Calibri;'>
Name - <b>$first_name $last_name</b><br/>
Email - <b>$email</b><br/>
Amount - <b>$gt</b><br/>
Ref - <b>$wallet_id</b><br/>
Response - <b>Success</b><br/>
Date - <b>$transaction_date</b><br/>
Payment Method - <b>$action</b><br/>
Details of order <b style='color:cornflowerblue;'>$order_id</b><br/>
</div>
";
$che = mysqli_query($con,"SELECT * FROM cart_details WHERE order_id='$order_id'");
if (mysqli_num_rows($che) > 0) {
while ($get = mysqli_fetch_array($che)) {
$product_id = $get["product_id"];
$product_title = $get["product_title"];
$product_image = $get["product_image"];
$product_price = $get["product_price"];
$qty = $get["qty"];
$message1 .="
<img src='$link/$admin_no/assets/img/products/$product_image' alt='$product_title' style='width:70px;height:70px;'>
<h5 style='font-weight:700;font-size:14px;line-height:1px;'>$product_title</h5>
<p style='font-size:10px;line-height:1px;'>$currency$product_price.00</p>
<p style='font-size:10px;line-height:1px;'>Quantity - $qty</p>
<div style='color:gainsboro;opacity:0.5;'><hr/></div>
";
}
}
$message1 .="
<span style='font-weight:900;'>$currency$delivery_zone_fee.00</span> - Shipping Fee<br/>
<span style='font-weight:900;'>$currency$bank_charges.00</span> - Shipping Fee<br/>
<span style='font-weight:900;'>$currency$gt.00</span> - Total<br/><br/>
";
date_default_timezone_set('Africa/Lagos');
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'PHPMailer/src/Exception.php';
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.titan.email"; // sets the SMTP server
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Set encryption to STARTTLS
$mail->Port = 587; // Use port 587 for TLS
$mail->Username = "$no_reply_email"; // SMTP account username
$mail->Password = "$no_reply_password"; // SMTP account password
$mail->SetFrom("$no_reply_email", "$company_name");//Use a fixed address in your own domain as the from address
$mail->AddReplyTo("$company_email","$company_name"); //Put the submitter's address in a reply-to header
$mail->Subject = "$subject";
$mail->MsgHTML("<html><body>$message1</body></html>");
$mail->AddAddress("$company_email", 'Payment Page');//Send the message to yourself, or whoever should receive contact for submissions
//$mail->AddAttachment(""); // attachment
if(!$mail->Send()) {
//echo "Mailer Error: " . $mail->ErrorInfo;
$msg = 'Email not sent, please try again';
}
else {
//echo "Thanks for getting in touch, we will get back to ASAP";
$msg = "Hey $first_name thanks for getting in touch, we will get back to you ASAP!";
}
//email an autoresponse to the person too
$mail->clearAddresses();
$mail->clearReplyTos();
$subject = "$first_name thank you for your order $order_id";
$message="";
$button_link="$link/sign_in.php";
$button_text="Log in";
$email_topic="Your order has been successfully paid for.";
include("email_header.php");
$message .= "
Dear $first_name,<br/><br/>
Thank you for shopping up with us at $company_name.Your payment has been received and your order is now being processed.<br/>If you have any questions please contact our dedicated support staff at $company_email<br/><br/>
The $company_name Team.<br/><br/>
Please find the details of your order below:<br/>";
$che = mysqli_query($con,"SELECT * FROM cart_details WHERE order_id='$order_id'");
if (mysqli_num_rows($che) > 0) {
while ($get = mysqli_fetch_array($che)) {
$product_id = $get["product_id"];
$product_title = $get["product_title"];
$product_image = $get["product_image"];
$product_price = $get["product_price"];
$qty = $get["qty"];
$message .="
<img src='$link/$admin_no/assets/img/products/$product_image' alt='$product_title' style='width:70px;height:70px;'>
<h5 style='font-weight:700;font-size:14px;line-height:1px;'>$product_title</h5>
<p style='font-size:10px;line-height:1px;'>$currency$product_price.00</p>
<p style='font-size:10px;line-height:1px;'>Quantity - $qty</p>
<div style='color:gainsboro;opacity:0.5;'><hr/></div>
";
}
}
$message.="$email_logo<br/><br/>
";
include("email_footer.php");
$mail->SetFrom("$no_reply_email", "$company_name");//Use a fixed address in your own domain as the from address
$mail->AddAddress("$email", "$email");//Send the message to yourself, or whoever should receive contact for submissions
$mail->AddReplyTo("$company_email","$company_name"); //Put the submitter's address in a reply-to header
$mail->Subject = "$subject";
$mail->MsgHTML("$message");
if(!$mail->Send()) {
//echo "Mailer Error: " . $mail->ErrorInfo;
$msg = 'Email not sent, please try again';
}
else {
//echo "Thanks for getting in touch, we will get back to ASAP";
$msg = "Hey $first_name thanks for getting in touch, we will get back to you ASAP.";
}
//send notification
$content ="Your order $order_id has been successfully paid for";
$sender ="System";
$receiver = "$user_id";
$seen ="No";
$date_notification = date("D,dS M, Y g:ia");
mysqli_query($con,"INSERT INTO notifications VALUES(
'0',
'$content',
'$sender',
'$receiver',
'$seen',
'$date_notification'
)")or die(mysqli_error($con));
$completed="Completed";
$stmt_com = $con -> prepare('UPDATE my_orders SET status = ? WHERE order_id = ?');
$stmt_com -> bind_param('ss', $completed,$order_id);
$stmt_com -> execute();
}
}else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";exit();}
?>
<!-- Start All Title Box -->
<div class="all-title-box">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h2>Payment Result</h2>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">Payment Result</li>
</ul>
</div>
</div>
</div>
</div>
<!-- End All Title Box -->
<!-- Start About Page -->
<div class="about-box-main">
<div class="container">
<div class="row">
<div>
Your order has been successfully paid for. <br>
<form action='your_account.php' action='post'>
<div style='text-align: center;'>
<button class="btn hvr-hover" style='background:$color;color:white;' type='submit'>Back</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- End About Page -->
<?php include("footer.php"); ?>