First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Demo: simulates a SCHOOL'S OWN external website embedding the Pay button.
|
||||
*
|
||||
* In reality the school pastes the <script> snippet shown on the onboarding
|
||||
* success page into their site. Here we resolve a connected school, ensure it
|
||||
* has a public embed key, and render that exact snippet so you can test the
|
||||
* full cross-site flow (embed.js → pay-frame.php → order-api.php) locally.
|
||||
*
|
||||
* ?school=Name to force one, ?amount=25.00 to set the amount.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/lib/SquareClient.php';
|
||||
require_once __DIR__ . '/lib/MerchantStore.php';
|
||||
|
||||
$config = require __DIR__ . '/config.php';
|
||||
$store = new MerchantStore($config);
|
||||
|
||||
$requested = isset($_GET['school']) ? trim((string)$_GET['school']) : '';
|
||||
$school = null;
|
||||
if ($requested !== '' && ($store->getMeta($requested)['merchant_id'] ?? null)) {
|
||||
$school = $requested;
|
||||
} else {
|
||||
foreach ($store->merchantSchools() as $s) { $school = $s; break; }
|
||||
}
|
||||
|
||||
$amount = isset($_GET['amount']) && is_numeric($_GET['amount']) ? number_format((float)$_GET['amount'], 2, '.', '') : '25.00';
|
||||
$key = $school !== null ? $store->merchantKey($school) : '';
|
||||
$base = rtrim($config['base_url'], '/') . '/';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Greenfield Academy — Lunch Payments (demo external site)</title>
|
||||
<style>
|
||||
body { font-family:Georgia, 'Times New Roman', serif; background:#fbfaf7; color:#2d2a26;
|
||||
margin:0; line-height:1.6; }
|
||||
.banner { background:#234d20; color:#fff; padding:22px 0; text-align:center; }
|
||||
.banner h1 { margin:0; font-size:24px; letter-spacing:.5px; }
|
||||
.wrap { max-width:680px; margin:0 auto; padding:32px 20px 60px; }
|
||||
.card { background:#fff; border:1px solid #e7e3da; border-radius:8px; padding:26px; margin-top:24px; }
|
||||
.note { font-size:13px; color:#8a8378; margin-top:8px; }
|
||||
code { background:#f0ede6; padding:2px 6px; border-radius:4px; font-size:13px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="banner"><h1>🌳 Greenfield Academy</h1></div>
|
||||
<div class="wrap">
|
||||
<p style="font-style:italic;color:#6b655c;">(This page imitates a school's own website. The only Square-specific
|
||||
thing on it is the one script tag below.)</p>
|
||||
|
||||
<div class="card">
|
||||
<h2>Pay for School Lunch</h2>
|
||||
<p>Amount due: <strong>CAD <?= htmlspecialchars($amount) ?></strong> — <?= htmlspecialchars($school ?? 'no connected school') ?></p>
|
||||
|
||||
<?php if ($school === null): ?>
|
||||
<p style="color:#b03030;">No Square-connected school found. Complete <code>onboard.php</code> first.</p>
|
||||
<?php else: ?>
|
||||
<!-- ▼▼▼ This is the snippet a school pastes onto their site ▼▼▼ -->
|
||||
<script src="<?= htmlspecialchars($base) ?>embed.js"
|
||||
data-square-key="<?= htmlspecialchars($key) ?>"
|
||||
data-amount="<?= htmlspecialchars($amount) ?>"
|
||||
data-currency="CAD"
|
||||
async></script>
|
||||
<!-- ▲▲▲ nothing else required ▲▲▲ -->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<p class="note">Embed key in use: <code><?= htmlspecialchars($key ?: '(none)') ?></code></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user