<?php
require_once '../../private/db.php';
require_once '../../private/auth.php';
require_login();
$pi=trim((string)($_GET['pi']??''));
$stmt=$pdo->prepare("SELECT * FROM orders WHERE stripe_payment_intent=? ORDER BY id DESC LIMIT 1");
$stmt->execute([$pi]);
$order=$stmt->fetch();
if(!$order){die('<h2>Check Your Emal For Receipt</h2>');}
?><!DOCTYPE html><html><head><meta charset='UTF-8'><title>Receipt</title></head><body onload='window.print()'><h1>Executive Protection Institute</h1><p><strong>Invoice:</strong> <?= htmlspecialchars($order['order_number']) ?></p><p><strong>Total:</strong> $<?= number_format((float)$order['total'],2) ?></p><p><strong>Status:</strong> <?= htmlspecialchars($order['status']) ?></p><button onclick='window.print()'>Print Receipt</button></body></html>