0 && (int)($ctx['school_num'] ?? 0) > 0 && (time() - (int)($ctx['created_at'] ?? 0)) < 3600; $schoolReady = false; $schoolName = ''; $returnUrl = is_array($ctx) ? (string)($ctx['return_url'] ?? '/') : '/'; $readyIssues = []; if ($ctxValid) { require_once __DIR__ . '/lib/MerchantStore.php'; require_once __DIR__ . '/lib/SquareClient.php'; $cfg = require __DIR__ . '/config.php'; $store = new MerchantStore($cfg); $client = new SquareClient($cfg); $num = (int)$ctx['school_num']; $meta = $store->getMetaByNum($num); $schoolName = (string)($ctx['school_name'] ?: ($store->schoolNameByNum($num) ?? '')); $readyIssues = is_array($meta['status_issues'] ?? null) ? $meta['status_issues'] : []; // Same rule as the button: only an onboarded school can be paid. $schoolReady = $store->isOnboarded($num, $client); if (!$schoolReady) { $meta = $store->getMetaByNum($num); $readyIssues = is_array($meta['status_issues'] ?? null) ? $meta['status_issues'] : []; } $symbol = (string)($ctx['currency_symbol'] ?? '$'); $baseAmount = (string)$ctx['base_amount']; $total = (string)$ctx['total_amount']; $baseLabel = (string)($ctx['base_label'] ?? 'Account balance'); $buyerEmail = (string)($ctx['buyer_email'] ?? ''); $currency = strtoupper((string)($ctx['currency'] ?? ($meta['currency'] ?? 'CAD'))); if (!preg_match('/^[A-Z]{3}$/', $currency)) $currency = 'CAD'; $sqCheckout = [ 'school_name' => $schoolName, 'school_num' => $num, 'user_num' => (int)($ctx['user_num'] ?? 0), // First-party checkout is bound to the session; never fall back to the // public embed key, or a paid checkout could be resubmitted as an embed. 'merchant_key' => '', 'amount' => $total, 'currency' => $currency, 'buyer_email' => $buyerEmail, 'order_api_url' => './order-api.php', 'success_url' => $returnUrl, ]; } ?>
For your security, checkout sessions only stay open for a short while. Head back to your account page and click Pay with Square again.
Back to my account= htmlspecialchars($schoolName) ?> can't accept Square payments at the moment. Please go back and choose another payment method, or contact the school office.
= htmlspecialchars(implode(' ', array_map('strval', $readyIssues))) ?>
Back to my accountYou're paying = htmlspecialchars($schoolName) ?> through Square. Funds go to the school's Square account.
Payment to = htmlspecialchars($schoolName) ?>
Paying as = htmlspecialchars($buyerEmail) ?>
Card details are tokenized by Square and never touch our servers.
← Go back and choose a different payment methodQuestions about a charge? Contact the school office at = htmlspecialchars($schoolName) ?>.