<?php
require 'db.php';
require 'functions.php';

$orderid = cleanInput($_GET['order'] ?? '');
$stmt = $pdo->prepare("SELECT po.*, v.fullname FROM paymentorder po
    JOIN villager v ON v.id = po.villagerid WHERE po.razorpayorderid = ? AND po.isdeleted = 0");
$stmt->execute([$orderid]);
$order = $stmt->fetch();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Payment Successful - Divar Ferry Pass App</title>
<link rel="icon" href="logo.png" type="image/png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="dfp-loginwrap" style="max-width:400px;">
  <img src="logo.png" class="logo" alt="logo">
  <?php if ($order && $order['status'] === 'paid'): ?>
    <h3 style="color:var(--clr-success);">Payment Successful</h3>
    <p><?php echo safeOut($order['fullname']); ?>, your ferry pass registration fee has been received.</p>
    <p>Your pass is now active. Please open the Divar Ferry Pass App to view your pass.</p>
  <?php else: ?>
    <h3>Processing</h3>
    <p>We are confirming your payment. This can take a few moments. Please check the app shortly.</p>
  <?php endif; ?>
</div>
</body>
</html>
