35067-vm/success.php
Flatlogic Bot b200618254 eco-grow
2025-10-20 06:45:18 +00:00

81 lines
2.4 KiB
PHP

<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
require_once 'razorpay-config.php';
require_once 'vendor/autoload.php';
use Razorpay\Api\Api;
use Razorpay\Api\Errors\SignatureVerificationError;
$success = false;
$error = "Payment Failed";
if (empty($_GET['payment_id']) === false)
{
$api = new Api($razorpay_key_id, $razorpay_key_secret);
try
{
// Please note that the razorpay order ID must
// come from a trusted source (session here, but
// could be database or something else)
$attributes = array(
'razorpay_order_id' => $_SESSION['razorpay_order_id'],
'razorpay_payment_id' => $_GET['payment_id'],
'razorpay_signature' => $_GET['signature']
);
$api->utility->verifyPaymentSignature($attributes);
$success = true;
}
catch(SignatureVerificationError $e)
{
$success = false;
$error = 'Razorpay Error : ' . $e->getMessage();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Payment Status - EcoGrow</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css">
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container my-5">
<div class="row">
<div class="col-md-6 offset-md-3 text-center">
<?php if ($success): ?>
<div class="card border-success">
<div class="card-body">
<h1 class="text-success">Payment Successful</h1>
<p>Thank you for your purchase!</p>
<p><strong>Payment ID:</strong> <?php echo htmlspecialchars($_GET['payment_id']); ?></p>
<a href="products.php" class="btn btn-success">Continue Shopping</a>
</div>
</div>
<?php else: ?>
<div class="card border-danger">
<div class="card-body">
<h1 class="text-danger">Payment Failed</h1>
<p><?php echo htmlspecialchars($error); ?></p>
<a href="products.php" class="btn btn-danger">Try Again</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</body>
</html>