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/domains/marisgoldunisexboutique.com/public_html/ |
<?php use PHPMailer\PHPMailer\PHPMailer;use PHPMailer\PHPMailer\Exception;use PHPMailer\PHPMailer\SMTP; session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("header.php"); ?>
<title><?php echo $company_name; ?>, Payment Result</title>
<main>
<div class="hero-area section-bg2">
<div class="container">
<div class="row">
<div class="col-xl-12">
<div class="slider-area">
<div class="slider-height2 slider-bg4 d-flex align-items-center justify-content-center">
<div class="hero-caption hero-caption2">
<h2>Payment Result</h2>
<nav aria-label="breadcrumb">
<ol class="breadcrumb justify-content-center">
<li class="breadcrumb-item"><a href="index.php">Home</a></li>
<li class="breadcrumb-item"><a href="#">Payment Result</a></li>
</ol>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row content">
<div class="col-lg-6 pt-4 pt-lg-0">
<?php
if($_SERVER['REQUEST_METHOD'] == 'GET' ){
$paystack_reference = mysqli_real_escape_string($con,$_GET['reference']);
$amount = mysqli_real_escape_string($con,$_GET['amount']);
$first_name = mysqli_real_escape_string($con,$_GET['first_name']);
$last_name = mysqli_real_escape_string($con,$_GET['last_name']);
$email = mysqli_real_escape_string($con,$_GET['email']);
$full_name = "$first_name $last_name";
$result = array();
//The parameter after verify/ is the transaction reference to be verified
$url = "https://api.paystack.co/transaction/verify/$paystack_reference";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(
$ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer sk_live_03dabce7f8a8c6f5180dfb670a161d1c536e0430']
);
$request = curl_exec($ch);
curl_close($ch);
if ($request) {
$result = json_decode($request, true);
//print_r($result);
if($result){
if($result['data']){
//something came in
if($result['data']['status'] == 'success'){
// the transaction was successful, you can deliver value
$status = $result['data']['status'];
$gateway_response = $result['data']['gateway_response'];
$transaction_date = $result['data']['transaction_date'];
echo"<span class='explanation'>Your transaction reference is </span><span class='blue'>$paystack_reference</span><br/>";
echo "<span class='explanation'>The transaction was <span class='blue'>successful.</span></span><br/>";
echo "<span class='explanation'>Transaction Date - <span class='blue'>$transaction_date.<span></span><br/>";
//send email
$subject ="$first_name $last_name donated";
$message1 = "
<div style='font-family:Calibri;'>
Name - <b>$first_name $last_name</b><br/>
Email - <b>$email</b><br/>
Amount - <b>$amount</b><br/>
Ref - <b>$paystack_reference</b><br/>
Response - <b>$gateway_response</b><br/>
Date - <b>$transaction_date</b><br/>
</div>
";
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 = "localhost"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "$no_reply_email"; // SMTP account username
$mail->Password = "$no_reply_password"; // SMTP account password
$mail->SetFrom("$company_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 donating!";
$message="";
include("email_header.php");
$message .= "
Dear $first_name $last_name,<br/><br/>
Thank you for donating. The money you have graciously donated will be put to the best use in reaching our ideals of making the world a better place.
<br/><br/>
The $company_name Team.<br/>
$email_logo
";
include("email_footer.php");
$mail->SetFrom("$company_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 $name thanks for getting in touch, we will get back to you ASAP.";
}
$stmt = $con -> prepare('SELECT * FROM transactions WHERE paystack_reference=?');
$stmt -> bind_param('s',$paystack_reference);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$heading,$paragraph,$picture);
$numrows = $stmt -> num_rows();
if($numrows < 1){
$db_id=0;
$stmt = $con -> prepare('INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)');
$stmt -> bind_param('isssssss', $db_id,$email,$amount,$paystack_reference,$status,$gateway_response,$transaction_date,$full_name);
$stmt -> execute();
}
echo"
<form action='donate.php' action='post'>
<div style='text-align: center;'>
<button class='btn btn-medium' style='background:#1063c8;color:white;' type='submit'>Back</button>
</div>
</form>
";
}
else{
// the transaction was not successful, do not deliver value'
//print_r($result); //uncomment this line to inspect the result, to check why it failed.
$status = $result['data']['status'];
$gateway_response = $result['data']['gateway_response'];
$transaction_date = $result['data']['transaction_date'];
echo"<span class='explanation'>Your transaction reference is </span><span class='blue'>$paystack_reference</span><br/>";
echo "<span class='explanation'>The transaction was <span class='blue'> NOT successful.</span></span><br/>";
echo "<span class='explanation'>Gateway Response - <span class='blue'>$gateway_response.<span></span><br/>";
echo "<span class='explanation'>Transaction Date - <span class='blue'>$transaction_date.<span></span><br/>";
//insert transaction details into database
$stmt = $con -> prepare('SELECT * FROM transactions WHERE paystack_reference=?');
$stmt -> bind_param('s',$paystack_reference);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$heading,$paragraph,$picture);
$numrows = $stmt -> num_rows();
if($numrows < 1){
$db_id=0;
$stmt = $con -> prepare('INSERT INTO transactions VALUES (?,?,?,?,?,?,?,?)');
$stmt -> bind_param('isssssss', $db_id,$email,$amount,$paystack_reference,$status,$gateway_response,$transaction_date,$full_name);
$stmt -> execute();
}
echo"
<form action='donate.php' action='post'>
<div style='text-align: center;'>
<button class='btn btn-medium' style='background:#1063c8;color:white;' type='submit'>Back</button>
</div>
</form>
";
}
}
else{
echo $result['message'];
}
}
else{
//print_r($result);
die("Something went wrong. Please try again later.");
}
}
else{
//var_dump($request);
die("Something went wrong. Please try again later.");
}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=error.php\">";}
?>
</div>
</div>
</main><!-- End About Us Section -->
<?php include("footer.php"); ?>