, so the capture * settles directly in the school's PayPal account, and then books the * payment into the user_account ledger (idempotent on capture_id). */ // -- Attach to the main app session (same domain, session name 'hotlunch') ----- if (session_status() !== PHP_SESSION_ACTIVE) { @session_name('hotlunch'); @session_start(); } $ctx = $_SESSION['ppp_checkout'] ?? null; $ctxValid = is_array($ctx) && (float)($ctx['total_amount'] ?? 0) > 0 && trim((string)($ctx['school_name'] ?? '')) !== '' && (time() - (int)($ctx['created_at'] ?? 0)) < 3600; // -- Confirm the school is still connected & ready before rendering payment ---- $schoolReady = false; if ($ctxValid) { $merchantsFile = __DIR__ . '/data/school_merchants.json'; if (is_file($merchantsFile)) { $merchants = json_decode((string)file_get_contents($merchantsFile), true) ?: []; $record = $merchants[$ctx['school_name']] ?? null; if ($record && !empty($record['merchant_id'])) { $schoolReady = !isset($record['paypal_ready']) || (bool)$record['paypal_ready']; } } } if ($ctxValid) { $schoolName = (string)$ctx['school_name']; $symbol = (string)($ctx['currency_symbol'] ?? '$'); $baseAmount = (string)$ctx['base_amount']; $feeAmount = (string)($ctx['fee_amount'] ?? '0.00'); $total = (string)$ctx['total_amount']; $baseLabel = (string)($ctx['base_label'] ?? 'Account balance'); $feeLabel = (string)($ctx['fee_label'] ?? 'Transaction fee'); $returnUrl = (string)($ctx['return_url'] ?? '/'); $buyerEmail = (string)($ctx['buyer_email'] ?? ''); $hasFee = (float)$feeAmount > 0; $currency = strtoupper((string)($ctx['currency'] ?? 'USD')); // -- Contract for paypal-checkout-widget.php ------------------------------- $items = [[ 'name' => $baseLabel, 'quantity' => '1', 'unit_amount' => ['currency_code' => $currency, 'value' => $baseAmount], ]]; if ($hasFee) { $items[] = [ 'name' => $feeLabel, 'quantity' => '1', 'unit_amount' => ['currency_code' => $currency, 'value' => $feeAmount], ]; } $ppCheckout = [ 'school_name' => $schoolName, 'amount' => $total, 'currency' => $currency, 'items' => $items, 'buyer_email' => $buyerEmail, 'page_type' => 'checkout', 'order_api_url' => './order-api.php', 'success_url' => $returnUrl, 'cancel_url' => '', 'user_num' => (int)($ctx['user_num'] ?? 0), ]; } else { $schoolName = ''; $returnUrl = is_array($ctx) ? (string)($ctx['return_url'] ?? '/') : '/'; } ?>
For your security, checkout sessions only stay open for a short while. Head back to your account page and click Pay with PayPal again — it only takes a second.
Back to my account= htmlspecialchars($schoolName) ?> can't accept PayPal payments at the moment. Please go back and choose another payment method, or contact the school office.
Back to my accountYou're paying = htmlspecialchars($schoolName) ?> through PayPal's secure checkout.
Payment to = htmlspecialchars($schoolName) ?>
Paying as = htmlspecialchars($buyerEmail) ?>
All payments are processed by PayPal — your card details never touch our servers.
← Go back and choose a different payment method
Questions about a charge? Contact the school office at = htmlspecialchars($schoolName) ?>.
A PayPal receipt will be emailed to you after payment.