Fix checkout: show free-success when logged in; init Stripe without auth on paid plans
Dev — Build & local smoke test / build-smoke (pull_request) Failing after 1m47s
Dev — Build & local smoke test / build-smoke (pull_request) Failing after 1m47s
- 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
This commit is contained in:
+18
-2
@@ -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('', '');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user