false, 'error' => 'School not found or not connected']); exit(); } $s = $client->getSellerStatus($config['partner_merchant_id'], $merchantId); $merchants[$school] = array_merge($merchants[$school], [ 'paypal_ready' => $s['paypal_ready'], 'email_confirmed' => $s['email_confirmed'], 'payments_receivable' => $s['payments_receivable'], 'oauth_ok' => $s['oauth_ok'], 'seller_email' => $s['seller_email'], 'status_issues' => $s['issues'], 'status_checked_at' => time(), ]); file_put_contents($merchantsFile, json_encode($merchants, JSON_PRETTY_PRINT)); echo json_encode(array_merge(['success' => true], $s)); exit(); } if ($_POST['action'] === 'check_all') { $refreshed = 0; foreach ($merchants as $school => &$data) { $mid = $data['merchant_id'] ?? null; if (!$mid) continue; $s = $client->getSellerStatus($config['partner_merchant_id'], $mid); $data = array_merge($data, [ 'paypal_ready' => $s['paypal_ready'], 'email_confirmed' => $s['email_confirmed'], 'payments_receivable' => $s['payments_receivable'], 'oauth_ok' => $s['oauth_ok'], 'seller_email' => $s['seller_email'], 'status_issues' => $s['issues'], 'status_checked_at' => time(), ]); $refreshed++; } unset($data); file_put_contents($merchantsFile, json_encode($merchants, JSON_PRETTY_PRINT)); echo json_encode(['success' => true, 'refreshed' => $refreshed]); exit(); } } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); } exit(); } // ── Load data (only needed for authenticated view) ───────────────────────── $merchants = []; $pending = []; $total = 0; $ready = 0; $withIssues = 0; $pendingCount = 0; if ($_SESSION['admin'] ?? false) { $merchantsFile = $dataDir . '/school_merchants.json'; if (file_exists($merchantsFile)) { $merchants = json_decode(file_get_contents($merchantsFile), true) ?: []; } $pendingFile = $dataDir . '/pending_onboarding.json'; if (file_exists($pendingFile)) { $pending = json_decode(file_get_contents($pendingFile), true) ?: []; } $total = count($merchants); foreach ($merchants as $m) { if ($m['paypal_ready'] ?? false) $ready++; if (!empty($m['status_issues'])) $withIssues++; } foreach ($pending as $p) { if (in_array($p['status'] ?? '', ['pending', 'waiting_for_paypal', 'incomplete_onboarding'])) { $pendingCount++; } } } ?> PayPal Admin Dashboard

Welcome back

Sign in to manage your PayPal merchant connections.

🏫
Total Schools
✅
PayPal Ready
⚠️
With Issues
⏳
Pending
Connected Schools
Schools that have completed PayPal onboarding
🏫

No schools connected yet. Use the onboarding page to connect a school.

$m): $ready = $m['paypal_ready'] ?? null; $emailConf = $m['email_confirmed'] ?? null; $paymentsRecv = $m['payments_receivable'] ?? null; $oauthOk = $m['oauth_ok'] ?? null; $sellerEmail = $m['seller_email'] ?? null; $issues = $m['status_issues'] ?? []; $connectedAt = isset($m['connected_at']) ? date('M j, Y', $m['connected_at']) : '—'; $checkedAt = isset($m['status_checked_at']) ? date('M j, Y g:i a', $m['status_checked_at']) : 'Never'; $statusBadge = $ready === null ? '⚪ Unknown' : ($ready ? '✔ Ready' : '✖ Issues'); $flag = fn($v) => $v === null ? '?' : ($v ? '✓' : '✗'); ?>
School PayPal Email Status Flags Connected Last Checked Actions
Email / Pay / OAuth
in_array($p['status'] ?? '', ['pending','waiting_for_paypal','incomplete_onboarding'])); ?>
⏳ Pending Onboarding ( school 1 ? 's' : '' ?>)
$p): ?>
Status: · Started:
⏳