Fix free tier checkout and Stripe duplicate customers
Free tier: - checkout-stripe.el bails out immediately for plan=free (no Stripe init) - checkout-auth.el skips payment section reveal and initStripe for free plan - checkout-free.el shows #free-success panel after auth (no card ever shown) - /api/payment-intent returns early for free plan — no Stripe call Stripe dedup (all paid plans): - Stripe init now deferred to window.initStripe(email, name), called by checkout-auth.el after sign-in — email is known before intent is created - /api/payment-intent finds-or-creates Stripe Customer by email before creating the PaymentIntent/SetupIntent and attaches customer upfront - Eliminates the window between intent creation and /api/link-customer that was producing duplicate guest customers
This commit is contained in:
+11
-1
@@ -97,7 +97,7 @@ fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
<div id=\"auth-section\" " + (if is_free { "" } else { "style=\"display:none;\"" }) + ">
|
||||
" + (if is_free { "
|
||||
<p class=\"label\" style=\"margin-bottom: 1.5rem; color: var(--navy);\">Create your account.</p>
|
||||
<p class=\"checkout-auth-hint\" style=\"margin-bottom: 2rem;\">No charge today. Add your card to reserve your spot - you won't be billed until you upgrade.</p>
|
||||
<p class=\"checkout-auth-hint\" style=\"margin-bottom: 2rem;\">No card required. Your account is free, forever.</p>
|
||||
" } else { "
|
||||
<p class=\"label\" style=\"margin-bottom: 1.25rem;\">Sign in (optional)</p>
|
||||
<p class=\"checkout-auth-hint\">Sign in to link this purchase to an existing account. Or skip and create one later - we'll match it to your email.</p>
|
||||
@@ -135,6 +135,16 @@ fn checkout_page(plan: String, pub_key: String) -> String {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Free-tier success panel: shown after account creation, no card needed -->
|
||||
" + (if is_free { "
|
||||
<div id=\"free-success\" style=\"display:none; text-align:center; padding: 2.5rem 1rem;\">
|
||||
<div style=\"font-size:2.5rem; margin-bottom:1.25rem;\">✓</div>
|
||||
<p class=\"label\" style=\"margin-bottom:.75rem; color:var(--navy);\">You're in.</p>
|
||||
<p class=\"checkout-auth-hint\" style=\"margin-bottom:2rem;\">Your free account is ready. Download Neuron to get started.</p>
|
||||
<a href=\"/marketplace\" class=\"checkout-submit\" style=\"display:inline-block; text-decoration:none; padding:.875rem 2rem;\">Go to your account →</a>
|
||||
</div>
|
||||
" } else { "" }) + "
|
||||
|
||||
<!-- Payment form (visible immediately - no auth wall) -->
|
||||
<div id=\"payment-section\" " + (if is_free { "style=\"display:none;\"" } else { "" }) + ">
|
||||
<div id=\"auth-badge\" style=\"display:none; margin-bottom: 1.5rem;\"></div>
|
||||
|
||||
Reference in New Issue
Block a user