From 0263e514072c08ef7cd2131979370c70a7194ab6 Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Sun, 10 May 2026 16:59:51 -0500 Subject: [PATCH] Fix checkout: show free-success when logged in; init Stripe without auth on paid plans MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - revealPaymentForm: for free plan, show #free-success panel (was doing nothing, leaving page blank when user already had a Supabase session) - checkExistingSession: for paid plans with no session, call initStripe immediately — auth is optional, the payment form shouldn't wait indefinitely - Guard _formRevealed: prevent double-call from handleAuthRedirect + checkExistingSession --- src/js/checkout-auth.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/js/checkout-auth.el b/src/js/checkout-auth.el index fd244eb..1c07878 100644 --- a/src/js/checkout-auth.el +++ b/src/js/checkout-auth.el @@ -29,12 +29,19 @@ fn main() -> Void { el.style.color = isError ? '#c0392b' : '#2ecc71'; } + var _formRevealed = false; function revealPaymentForm(user) { + if (_formRevealed) return; + _formRevealed = true; if (user && user.id) { window._neuronSupaId = user.id; } var auth = document.getElementById('auth-section'); if (auth) auth.style.display = 'none'; var isFree = (window.NEURON_CFG || {}).plan === 'free'; - if (!isFree) { + if (isFree) { + // Free plan: show the success panel (user is signed in or just signed up) + var freeSuccess = document.getElementById('free-success'); + if (freeSuccess) freeSuccess.style.display = ''; + } else { var payment = document.getElementById('payment-section'); if (payment) payment.style.display = ''; } @@ -68,7 +75,16 @@ fn main() -> Void { function checkExistingSession() { initSupabase(function() { supabaseClient.auth.getUser().then(function(res) { - if (res.data && res.data.user) { revealPaymentForm(res.data.user); } + if (res.data && res.data.user) { + revealPaymentForm(res.data.user); + } else { + // No existing session — for paid plans, init Stripe immediately. + // Auth is optional on paid plans; the user can link their account later. + var isFree = (window.NEURON_CFG || {}).plan === 'free'; + if (!isFree && typeof window.initStripe === 'function') { + window.initStripe('', ''); + } + } }); }); } -- 2.52.0