dev → stage: free plan $0 PaymentIntent #126
+3
-17
@@ -1,20 +1,6 @@
|
|||||||
// checkout-free.el -- Free plan: show success panel after auth completes.
|
// checkout-free.el -- RETIRED. Free plan now uses the standard Stripe
|
||||||
// Watches the auth-badge element; when it becomes visible, hides the auth
|
// payment flow (checkout-stripe.el) with a $0 PaymentIntent for age
|
||||||
// section and shows the free-success panel. No card required for free tier.
|
// verification. This file is no longer compiled or loaded.
|
||||||
// Compiled with: elc --target=js --bundle --minify --obfuscate
|
|
||||||
|
|
||||||
fn main() -> Void {
|
fn main() -> Void {
|
||||||
native_js("(function() {
|
|
||||||
var success = document.getElementById('free-success');
|
|
||||||
var auth = document.getElementById('auth-section');
|
|
||||||
if (!success) return;
|
|
||||||
var timer = setInterval(function() {
|
|
||||||
var badge = document.getElementById('auth-badge');
|
|
||||||
if (badge && badge.offsetParent !== null) {
|
|
||||||
if (auth) auth.style.display = 'none';
|
|
||||||
success.style.display = '';
|
|
||||||
clearInterval(timer);
|
|
||||||
}
|
|
||||||
}, 150);
|
|
||||||
})()")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ fn main() -> Void {
|
|||||||
if (submitLabel) {
|
if (submitLabel) {
|
||||||
submitLabel.textContent = window._neuronMode === 'setup'
|
submitLabel.textContent = window._neuronMode === 'setup'
|
||||||
? 'Save my card - no charge today →'
|
? 'Save my card - no charge today →'
|
||||||
: 'Complete purchase →';
|
: PLAN === 'free' ? 'Verify age & get started →' : 'Complete purchase →';
|
||||||
}
|
}
|
||||||
waitForStripe(function() {
|
waitForStripe(function() {
|
||||||
if (!stripe) stripe = Stripe(STRIPE_PK);
|
if (!stripe) stripe = Stripe(STRIPE_PK);
|
||||||
|
|||||||
+11
-13
@@ -697,23 +697,21 @@ fn handle_request_inner(method: String, path: String, headers: Map, body: String
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free tier: creates a SetupIntent for age verification (18+ requirement).
|
// Free tier: $0 PaymentIntent for age verification (18+ requirement).
|
||||||
// No charge — but the user must provide a valid payment method.
|
// Card is verified and saved (setup_future_usage=off_session). No charge.
|
||||||
if str_eq(plan, "free") {
|
if str_eq(plan, "free") {
|
||||||
let free_si_body: String = "automatic_payment_methods[enabled]=true"
|
let free_pi_body: String = "amount=0"
|
||||||
+ "&usage=off_session"
|
+ "¤cy=usd"
|
||||||
|
+ "&payment_method_types[]=card"
|
||||||
|
+ "&setup_future_usage=off_session"
|
||||||
+ "&metadata[plan]=free"
|
+ "&metadata[plan]=free"
|
||||||
+ "&metadata[purpose]=age_verification"
|
+ "&metadata[purpose]=age_verification"
|
||||||
let free_si_body = if !str_eq(pi_cus_id, "") { free_si_body + "&customer=" + pi_cus_id } else { free_si_body }
|
let free_pi_body = if !str_eq(pi_cus_id, "") { free_pi_body + "&customer=" + pi_cus_id } else { free_pi_body }
|
||||||
let free_si_resp: String = http_post_form_auth(
|
let free_pi_resp: String = http_post_form_auth(
|
||||||
"https://api.stripe.com/v1/setup_intents",
|
"https://api.stripe.com/v1/payment_intents",
|
||||||
free_si_body,
|
free_pi_body,
|
||||||
auth_header)
|
auth_header)
|
||||||
if str_starts_with(free_si_resp, "{") {
|
return free_pi_resp
|
||||||
let inner: String = str_slice(free_si_resp, 1, str_len(free_si_resp))
|
|
||||||
return "{\"setup_mode\":true,\"plan\":\"free\"," + inner
|
|
||||||
}
|
|
||||||
return free_si_resp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup-mode path: save payment method, do not charge. Only valid
|
// Setup-mode path: save payment method, do not charge. Only valid
|
||||||
|
|||||||
Reference in New Issue
Block a user