First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Demo: standalone "Pay with Square" checkout page (Phase 3 test harness).
|
||||
*
|
||||
* Auto-resolves to a Square-connected school so the card form actually renders.
|
||||
* Pass ?school=Name to force one, and ?amount=25.00 to set the amount.
|
||||
*
|
||||
* In your real app, $school / $amount / $buyerEmail come from session + DB and
|
||||
* you simply `require square-checkout-widget.php` with a $sqCheckout array.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/lib/SquareClient.php';
|
||||
require_once __DIR__ . '/lib/MerchantStore.php';
|
||||
|
||||
$config = require __DIR__ . '/config.php';
|
||||
$store = new MerchantStore($config);
|
||||
|
||||
// Resolve a connected school: explicit ?school=, else the first connected one.
|
||||
$requested = isset($_GET['school']) ? trim((string)$_GET['school']) : '';
|
||||
$school = null;
|
||||
if ($requested !== '' && ($store->getMeta($requested)['merchant_id'] ?? null)) {
|
||||
$school = $requested;
|
||||
} else {
|
||||
$all = $store->merchantSchools();
|
||||
if (!empty($all)) $school = $all[0];
|
||||
}
|
||||
|
||||
$amount = isset($_GET['amount']) && is_numeric($_GET['amount']) ? number_format((float)$_GET['amount'], 2, '.', '') : '25.00';
|
||||
$schoolLabel = $school ?? '(no connected school found)';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Pay — <?= htmlspecialchars($schoolLabel) ?></title>
|
||||
<style>
|
||||
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
|
||||
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
|
||||
background:#eef2f7; min-height:100vh; display:flex; align-items:center;
|
||||
justify-content:center; padding:24px; }
|
||||
.wrap { width:100%; max-width:520px; }
|
||||
.summary { background:#fff; border:1.5px solid #e2e8f0; border-radius:12px;
|
||||
padding:20px; margin-bottom:18px; }
|
||||
.summary h1 { font-size:18px; color:#1a202c; margin-bottom:6px; }
|
||||
.summary p { color:#718096; font-size:13px; }
|
||||
.summary .row { display:flex; justify-content:space-between; margin-top:14px;
|
||||
padding-top:14px; border-top:1px solid #edf2f7; font-weight:600; color:#1a202c; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<div class="summary">
|
||||
<h1>School Lunch Payment</h1>
|
||||
<p>Paying <strong><?= htmlspecialchars($schoolLabel) ?></strong></p>
|
||||
<div class="row"><span>Total</span><span>CAD <?= htmlspecialchars($amount) ?></span></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($school === null) {
|
||||
echo '<div style="background:#fff5f5;border:1px solid #feb2b2;color:#c53030;'
|
||||
. 'border-radius:10px;padding:16px;font-size:14px;">'
|
||||
. 'No Square-connected school found. Complete onboarding first '
|
||||
. '(onboard.php), then reload this page.</div>';
|
||||
} else {
|
||||
$sqCheckout = [
|
||||
'school_name' => $school,
|
||||
'amount' => $amount,
|
||||
'currency' => 'CAD',
|
||||
'order_api_url' => './order-api.php',
|
||||
'success_url' => './demo-checkout.php?school=' . urlencode($school),
|
||||
];
|
||||
require __DIR__ . '/square-checkout-widget.php';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user