diff --git a/src/checkout.el b/src/checkout.el index 2beec0d..a7a531f 100644 --- a/src/checkout.el +++ b/src/checkout.el @@ -93,47 +93,15 @@ fn checkout_page(plan: String, pub_key: String) -> String {
- " + (if is_free { " -

Create your account.

-

Create an account to reserve your free tier spot. You'll receive your download link and setup instructions at launch.

- -
-
- - -
- -
- -
- or create an account with email -
- -
- - - -

Already have an account? Sign in

-
-
- " } else { " - -
+ +
+ " + (if is_free { " +

Create your account.

+

No charge today. Add your card to reserve your spot - you won't be billed until you upgrade.

+ " } else { "

Sign in (optional)

Sign in to link this purchase to an existing account. Or skip and create one later - we'll match it to your email.

+ " }) + "
- -
- or create an account + or " + (if is_free { "create an account with email" } else { "create an account" }) + "
- +

Already have an account? Sign in

@@ -172,7 +138,9 @@ fn checkout_page(plan: String, pub_key: String) -> String {
+ " + (if is_free { "" } else { "

Already have an account? Sign in to link your purchase.

+ " }) + " " + (if is_founding { " @@ -189,8 +157,8 @@ fn checkout_page(plan: String, pub_key: String) -> String {
" } else { "" }) + " - - " + (if !is_founding { " + + " + (if !is_founding && !is_free { "

When would you like to be charged?

@@ -239,7 +207,7 @@ fn checkout_page(plan: String, pub_key: String) -> String {
@@ -253,7 +221,6 @@ fn checkout_page(plan: String, pub_key: String) -> String {
- " }) + "
diff --git a/src/main.el b/src/main.el index 22ba3cf..ac0e8d0 100644 --- a/src/main.el +++ b/src/main.el @@ -579,8 +579,29 @@ fn handle_request(method: String, path: String, body: String) -> String { if str_contains(body, "\"professional\"") { plan = "professional" } + if str_contains(body, "\"free\"") { + plan = "free" + } let timing: String = json_get_string(body, "timing") if str_eq(timing, "") { let timing = "now" } + // Free tier: SetupIntent — save card details without charging. + // Card is stored on a Stripe Customer; billing begins only if the + // user later upgrades to a paid plan. + if str_eq(plan, "free") { + let si_body: String = "automatic_payment_methods[enabled]=true" + + "&usage=off_session" + + "&metadata[plan]=free" + let auth_header: String = "Bearer " + stripe_key + let si_resp: String = http_post_form_auth( + "https://api.stripe.com/v1/setup_intents", + si_body, + auth_header) + if str_starts_with(si_resp, "{") { + let inner: String = str_slice(si_resp, 1, str_len(si_resp)) + return "{\"setup_mode\":true,\"plan\":\"free\"," + inner + } + return si_resp + } // Hard cap: block founding checkouts when 1,000 spots are filled if str_eq(plan, "founding") { let current_sold: Int = get_sold()