Files
Critters/processing.php
pauljd 6afdd80bfc
pauljd/davidson-ci: Davidson CI / quality (push) Successful in 16s
pauljd/davidson-ci: Davidson CI / ai-review (push) Successful in 59s
Davidson CI testing & AI refinement
2026-09-11 11:04:36 +01:00

46 lines
1.8 KiB
PHP

<?php
require __DIR__ . '/session.php';
start_app_session();
// Anchor completion checks to when this page actually loaded rather than a sliding
// window from "now" at poll time, so a delayed navigation or a browser tab that's
// backgrounded and resumed later still sees credits that were added while it wasn't
// polling. Reset on every fresh load of this page (not on the polling requests below,
// which hit a separate endpoint) so a later, unrelated visit doesn't inherit a stale
// anchor. The 10-second backdate also covers a webhook that finishes just before this
// redirect lands.
$_SESSION['purchase_wait_since'] = gmdate('Y-m-d H:i:s', time() - 10);
$pageTitle = 'Processing';
?>
<!DOCTYPE html>
<html lang="en">
<?php require __DIR__ . '/lib/head.php'; ?>
<body class="bg-amber-50 min-h-screen flex flex-col">
<?php require __DIR__ . '/lib/header.php'; ?>
<div class="flex-1 flex flex-col items-center justify-center text-center px-4">
<p class="text-lg text-gray-700 mb-4">Your credits are being processed. Please wait.</p>
<div class="h-10 w-10 border-4 border-gray-300 border-t-gray-900 rounded-full animate-spin"></div>
</div>
<?php require __DIR__ . '/lib/footer.php'; ?>
<script>
function checkPurchaseStatus() {
fetch('/api/purchase-boolean.php')
.then(function (response) { return response.json(); })
.then(function (data) {
if (data.result) {
window.location.href = '/';
} else {
setTimeout(checkPurchaseStatus, 3000);
}
})
.catch(function () {
setTimeout(checkPurchaseStatus, 3000);
});
}
checkPurchaseStatus();
</script>
</body>
</html>