diff --git a/src/checkout.el b/src/checkout.el
index e8f7c52..bb75081 100644
--- a/src/checkout.el
+++ b/src/checkout.el
@@ -703,6 +703,9 @@ fn checkout_page(plan: String, pub_key: String) -> String {
return;
}
+ // Capture the PI id so we can attach a Customer at submit time
+ window._neuronPiId = data.id || (data.client_secret ? data.client_secret.split('_secret_')[0] : '');
+
waitForStripe(function() {
stripe = Stripe(STRIPE_PK);
@@ -815,10 +818,24 @@ fn checkout_page(plan: String, pub_key: String) -> String {
setLoading(true);
document.getElementById('payment-message').style.display = 'none';
+ // Link a Stripe Customer to this PaymentIntent and to the Supabase waitlist row
+ // (so the buyer shows up as a named customer, not Guest, and the account page
+ // can find their plan via stripe_customer_id). Non-blocking - if it fails, the
+ // webhook still links them server-side after payment_intent.succeeded fires.
+ if (window._neuronPiId) {
+ try {
+ await fetch('/api/link-customer', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ pi_id: window._neuronPiId, email: email, name: name, plan: PLAN })
+ });
+ } catch(e) { /* non-blocking */ }
+ }
+
var result = await stripe.confirmPayment({
elements: elements,
confirmParams: {
- return_url: window.location.origin + '/marketplace/success',
+ return_url: window.location.origin + '/account?welcome=1',
payment_method_data: {
billing_details: { name: name, email: email }
},
diff --git a/src/main.el b/src/main.el
index c6897fc..a89af61 100644
--- a/src/main.el
+++ b/src/main.el
@@ -288,54 +288,7 @@ body::before{content:'';position:fixed;inset:0;pointer-events:none;z-index:0;bac
Try Neuron ↗
-
+