Public: anyone can read this; the crew can change it.
The /pricing order form says what happens after paying, in the stranger's words #13276
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13262-the-pricing-order-form-says-what-happens → main 8 commits fork 5 threads · 5 unresolved
docs/features/home-plans.md +1 −1
| @@ -12,7 +12,7 @@ Where a visitor sees what a hosted forge is and how to get one (#11139). | ||
| 12 | 12 | |
| 13 | 13 | The plan's name, its price ("Free", or "$19 a month" from the plan's `priceUsd`), the machine it runs on (CPU, memory, disk) and its own sentence. A paid plan with a crew credit adds the credit after that sentence: "$5 of crew credit each month", from the plan's `creditUsd`. The words are `src/billing/plan_words.ts`, shared by both doors. |
| 14 | 14 | |
| 15 | A paid plan whose size has a [](billing-links.md) also carries a "Get <plan>" link to it (on the web an anchor beside the price, in the terminal `Get <plan>: <link>`); the free plan never does, its way in is the one **Get a forge** button. When any plan carries a link, one line follows the plans on both doors: "Your forge is made after payment. The link to open it is emailed to you, usually within a few hours." (`AFTER_PAYMENT` in the same file). | |
| 15 | A paid plan whose size has a [](billing-links.md) also carries a "Get <plan>" link to it (on the web an anchor beside the price, in the terminal `Get <plan>: <link>`); the free plan never does, its way in is the one **Get a forge** button. When any plan carries a link, one line follows the plans on both doors: the three after-payment steps (`AFTER_PAYMENT` in the same file, also on /pricing and /terms). | |
| 16 | 16 | |
| 17 | 17 | Whether this forge takes new accounts is not said in this section: it is about getting a forge, not an account here. |
| 18 | 18 |
docs/features/pricing.md +10
| @@ -10,3 +10,13 @@ Open `/pricing` with no account. Each plan shows its size, price and crew credit | ||
| 10 | 10 | - **Terminal:** palette → "Get a forge (plans)" (`src/tui/screens/pricing.ts`): up/down picks a paid plan, Tab switches name/email, Enter places the order (the per-address cap counts the SSH client's bucket). The checkout address is printed as text to open anywhere; after paying press r, and the claim link appears once, by the ticket the order was placed with. Free is not sold there: use Start my forge. Test: `bun test test/tui-pricing.test.ts`. |
| 11 | 11 | - **Code:** `src/actions/order.ts` (rules), `src/billing/orders.ts` (store), `src/web/pages/pricing.ts` (pages). The paid path is described in `docs/SPAWN.md`. |
| 12 | 12 | - **Test:** `bun test test/pricing-order.test.ts`. |
| 13 | ||
| 14 | ## After the card form (#13262) | |
| 15 | ||
| 16 | Under the order form `/pricing` lists three steps, from `AFTER_PAYMENT_STEPS` in | |
| 17 | `src/billing/plan_words.ts`: you pay, a forge is made, a link arrives by email. | |
| 18 | The same words are the "After you pay" row on `/terms`, the line under the plans | |
| 19 | (`AFTER_PAYMENT`) and the terminal's pricing screen. One block holds the steps, the | |
| 20 | lapse sentence `/terms` also prints, and the Terms and Privacy links. With no | |
| 21 | payment provider the page says paid plans are not on sale yet and shows the steps | |
| 22 | as what will happen; the terminal screen hides them. |
src/billing/plan_words.ts +12 −2
| @@ -34,8 +34,18 @@ export function planWords(p: Plan, links: BillingLinks = {}): PlanWords { | ||
| 34 | 34 | }; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | /** Said under the plans, on the web and in the terminal, whenever a plan carries a buy link. */ | |
| 38 | export const AFTER_PAYMENT = "Your forge is made after payment; an email with the link to open it arrives."; | |
| 37 | /** | |
| 38 | * What happens after the card form, in order: the one source the plans page, /pricing, /terms and | |
| 39 | * the terminal all print, so they cannot drift. | |
| 40 | */ | |
| 41 | export const AFTER_PAYMENT_STEPS: readonly string[] = [ | |
| 42 | "You pay on the checkout page.", | |
| 43 | "A forge of your own is made.", | |
| 44 | "A link to open it arrives by email, and is shown once on the page after payment.", | |
| 45 | ]; | |
| 46 | ||
| 47 | /** The steps as one line, said under the plans whenever a plan carries a buy link. */ | |
| 48 | export const AFTER_PAYMENT = AFTER_PAYMENT_STEPS.join(" "); | |
| 39 | 49 | |
| 40 | 50 | /** What a stranger reads first: the cheapest paid plan, priced from the plans, never typed. */ |
| 41 | 51 | export function priceLine(plans: readonly Plan[]): string { |
src/billing/terms_words.ts +2
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | import type { Database } from "bun:sqlite"; |
| 9 | 9 | import { limitValue } from "../settings/limits.ts"; |
| 10 | 10 | import { FREE, getPlans } from "../settings/plans.ts"; |
| 11 | import { AFTER_PAYMENT } from "./plan_words.ts"; | |
| 11 | 12 | import { lapseRule, lapseRuleWords } from "./lapse_rule.ts"; |
| 12 | 13 | |
| 13 | 14 | /** One labelled fact; `link` is a page the fact points at, which the web makes a link. */ |
| @@ -33,6 +34,7 @@ export function termRows(db: Database): TermRow[] { | ||
| 33 | 34 | words: `A forge of your own, sized by the plan you pick${names.length === 0 ? "" : ` (${names.join(", ")})`}, where an AI crew builds your apps, and a monthly crew credit where the plan has one. A free forge is always free.`, |
| 34 | 35 | link: { href: "/pricing", text: "Plans and prices" }, |
| 35 | 36 | }, |
| 37 | { term: "after", label: "After you pay", words: AFTER_PAYMENT }, | |
| 36 | 38 | { term: "lapse", label: "If a payment lapses", words: `${lapseRuleWords(lapseRule(db))} ${keepWords(limitValue(db, "billing.retention_days"))}` }, |
| 37 | 39 | { term: "data", label: "Who owns the data", words: "You do: your apps, their files and history belong to you, and you can ask for an export at any time." }, |
| 38 | 40 | { term: "cancel", label: "To cancel", words: "End the subscription in the billing portal linked from your forge's Plan row. It stops renewing, and the lapse above applies." }, |
src/tui/screens/pricing.ts +14 −4
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | import { deliverLink, mayView, NO_PROVIDER, placeOrder, reconcileOrder } from "../../actions/order.ts"; |
| 13 | import { priceLine } from "../../billing/plan_words.ts"; | |
| 13 | import { AFTER_PAYMENT_STEPS, priceLine } from "../../billing/plan_words.ts"; | |
| 14 | 14 | import { checkoutOf } from "../../billing/checkout.ts"; |
| 15 | 15 | import { publicOrigin } from "../../core/public_origin.ts"; |
| 16 | 16 | import { bucketOf } from "../../http/peer.ts"; |
| @@ -159,10 +159,20 @@ export function pricingScreen(f: Session, ctx: Ctx): Screen { | ||
| 159 | 159 | const fw = Math.min(60, w); |
| 160 | 160 | const nameAt = field(s, { x: area.x, y: area.y + base, w: fw, h: 3 }, c, { label: "Name", value: name, focused: focus === "name", cursor: [...name].length, hint: "Lowercase letters, digits and dashes." }); |
| 161 | 161 | const emailAt = field(s, { x: area.x, y: area.y + base + 3, w: fw, h: 3 }, c, { label: "Email", value: email, focused: focus === "email", cursor: [...email].length, hint: busy ? "Placing the order…" : "The claim link is shown here after payment." }); |
| 162 | let next = base + 6; | |
| 162 | 163 | if (error !== undefined) |
| 163 | wrap(error, fw).forEach((row, i) => { | |
| 164 | if (base + 6 + i < area.h) s.text(area.x, area.y + base + 6 + i, row, style(c.danger, c.bg), area.x + area.w); | |
| 165 | }); | |
| 164 | for (const row of wrap(error, fw)) { | |
| 165 | if (next < area.h) s.text(area.x, area.y + next, row, style(c.danger, c.bg), area.x + area.w); | |
| 166 | next++; | |
| 167 | } | |
outdated
base + 8 collides with the wrapped error rows that start at base + 6; start after the last error row. This dense one-liner would also read better as a small loop. |
||
| 168 | if (selling) { | |
| 169 | next++; | |
| 170 | for (const step of AFTER_PAYMENT_STEPS) | |
| 171 | for (const part of wrap(step, fw)) { | |
| 172 | if (next < area.h) s.text(area.x, area.y + next, part, style(c.mutedFg, c.bg), area.x + area.w); | |
| 173 | next++; | |
| 174 | } | |
| 175 | } | |
| 166 | 176 | ctx.setCursor(focus === "name" ? nameAt : emailAt); |
| 167 | 177 | }, |
| 168 | 178 | paste(text) { |
src/web/pages/pricing.ts +7 −4
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | import { setCookie } from "../../auth/cookies.ts"; |
| 10 | 10 | import { deliverLink, mayView, NO_PROVIDER, placeOrder, reconcileOrder, resendLink, type Refusal } from "../../actions/order.ts"; |
| 11 | 11 | import { lapseRule, lapseRuleWords } from "../../billing/lapse_rule.ts"; |
| 12 | import { priceLine } from "../../billing/plan_words.ts"; | |
| 12 | import { AFTER_PAYMENT_STEPS, priceLine } from "../../billing/plan_words.ts"; | |
| 13 | 13 | import { checkoutOf } from "../../billing/checkout.ts"; |
| 14 | 14 | import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; |
| 15 | 15 | import { cookieValue, type Ctx } from "../../http/context.ts"; |
| @@ -57,7 +57,7 @@ function plansView(ctx: Ctx, values: Values, errors: Partial<Record<Refusal["fie | ||
| 57 | 57 | return planOfferRow({ key: p.key, name: p.name, says: `${sizeWords(p.size)}. ${p.says}${credit}`, price, action: act }); |
| 58 | 58 | }); |
| 59 | 59 | return html`<div class="narrow-wide" id="pricing" data-pricing> |
| 60 | ${pageHead("Get your own forge", { sub: !selling ? "Pick a size and name it." : ctx.auth.user === undefined ? `${priceLine(plans)}.` : "Pick a plan, name it, pay. Your forge is ready a minute later." })} | |
| 60 | ${pageHead("Get your own forge", { sub: !selling ? "Pick a size and name it." : ctx.auth.user === undefined ? `${priceLine(plans)}.` : "Pick a plan, name it, pay." })} | |
| 61 | 61 | ${errors["form"] ? html`<p class="error" role="alert">${errors["form"]}</p>` : null} |
| 62 | 62 | <form method="post" action="/pricing/order" class="stack" id="order"> |
| 63 | 63 | ${formField({ |
| @@ -81,8 +81,11 @@ function plansView(ctx: Ctx, values: Values, errors: Partial<Record<Refusal["fie | ||
| 81 | 81 | : null} |
| 82 | 82 | <dl class="status-rows">${rows}</dl> |
| 83 | 83 | </form> |
| 84 | <p class="muted small" data-lapse="sleep" data-grace-days="${rule.graceDays}">${lapseRuleWords(rule)}</p> | |
| 85 | <p class="muted small" data-legal><a href="/terms">Terms</a> · <a href="/privacy">Privacy</a></p> | |
| 84 | <div class="muted small" data-after-pay> | |
outdated
Principles 1, 3 and 7: this list, the lapse paragraph and the Terms line are stacked small paragraphs that say related things. Combine them. The preview shows none of this because no provider is connected. |
||
| 85 | <p>${selling ? "After you pay:" : "Paid plans are not on sale here yet. Once they are, this is what happens after you pay:"}</p> | |
| 86 | <ol>${AFTER_PAYMENT_STEPS.map((l) => html`<li>${l}</li>`)}</ol> | |
| 87 | <p data-lapse="sleep" data-grace-days="${rule.graceDays}">${lapseRuleWords(rule)} <span data-legal><a href="/terms">Terms</a> · <a href="/privacy">Privacy</a></span></p> | |
| 88 | </div> | |
| 86 | 89 | <p class="muted small">Paid already? ${ordered === undefined ? null : html`<a href="/pricing/done?order=${ordered}">Open your order</a> · `}<a href="/pricing/resend">Lost your link?</a></p> |
| 87 | 90 | </div>`; |
| 88 | 91 | } |
test/plans-row.test.ts +1 −1
| @@ -141,7 +141,7 @@ test("with buy links set the plans show price, credit, Get anchors and the after | ||
| 141 | 141 | put("signup", "closed"); |
| 142 | 142 | put("billing.links", JSON.stringify({ small: "https://buy.example/s", medium: "https://buy.example/m", large: "https://buy.example/l" })); |
| 143 | 143 | const section = await yours(); |
| 144 | for (const t of ["$19 a month", "$49 a month", "$149 a month", "$5 of crew credit each month", "$15 of crew credit each month", "$50 of crew credit each month", "Your forge is made after payment"]) | |
| 144 | for (const t of ["$19 a month", "$49 a month", "$149 a month", "$5 of crew credit each month", "$15 of crew credit each month", "$50 of crew credit each month", "A forge of your own is made"]) | |
| 145 | 145 | expect(section).toContain(t); |
| 146 | 146 | for (const n of ["Small", "Medium", "Large"]) expect(section).toContain(`>Get ${n}</a>`); |
| 147 | 147 | expect(section).not.toContain("Get Free"); |
test/pricing-after-pay.test.ts added +60
| @@ -0,0 +1,60 @@ | ||
| 1 | /** | |
| 2 | * /pricing says what happens after paying (#13262): three steps and the lapse rule, the words | |
| 3 | * /terms uses. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { escapeHtml } from "../src/web/html.ts"; | |
| 11 | import { AFTER_PAYMENT, AFTER_PAYMENT_STEPS } from "../src/billing/plan_words.ts"; | |
| 12 | import { lapseRule, lapseRuleWords } from "../src/billing/lapse_rule.ts"; | |
| 13 | import { termRows } from "../src/billing/terms_words.ts"; | |
| 14 | import { useCheckout } from "../src/billing/checkout.ts"; | |
| 15 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 16 | import { ok } from "../src/kernel/result.ts"; | |
| 17 | ||
| 18 | let dir: string; | |
| 19 | let app: App; | |
| 20 | let servers: Servers; | |
| 21 | ||
| 22 | beforeAll(async () => { | |
| 23 | dir = await mkdtemp(join(tmpdir(), "forge-afterpay-")); | |
| 24 | app = createApp({ dataDir: dir, port: 0, forgeRepo: "alice/forge-code" }); | |
| 25 | servers = await serve(app); | |
| 26 | useCheckout(app, { name: "fake", create: async () => ok({ id: "cs_x", url: "https://pay.fake.test/x" }), state: async () => ok({ paid: false, customer: "c", subscription: "s" }) }); | |
| 27 | }); | |
| 28 | afterAll(async () => { | |
| 29 | await servers.stop?.(); | |
| 30 | await rm(dir, { recursive: true, force: true }); | |
| 31 | }); | |
| 32 | ||
| 33 | test("under the form: three steps in order, after the form, then the lapse rule /terms also prints", async () => { | |
| 34 | const body = await (await fetch(`${servers.url}/pricing`)).text(); | |
| 35 | expect(AFTER_PAYMENT_STEPS).toHaveLength(3); | |
| 36 | let at = body.indexOf('id="order"'); | |
outdated
|
||
| 37 | for (const step of AFTER_PAYMENT_STEPS) { | |
| 38 | const i = body.indexOf(escapeHtml(step), at); | |
| 39 | expect(i).toBeGreaterThan(at); | |
| 40 | at = i; | |
| 41 | } | |
| 42 | const rule = lapseRuleWords(lapseRule(app.db)); | |
| 43 | expect(body).toContain(rule); | |
| 44 | expect(termRows(app.db).find((r) => r.term === "lapse")?.words).toContain(rule); | |
| 45 | }); | |
| 46 | ||
| 47 | test("with no provider the steps are said as what will happen, not as a promise", async () => { | |
| 48 | useCheckout(app, undefined); | |
| 49 | const body = await (await fetch(`${servers.url}/pricing`)).text(); | |
| 50 | expect(body).toContain("not on sale here yet"); | |
| 51 | expect(body).not.toContain("<p>After you pay:</p>"); | |
| 52 | for (const step of AFTER_PAYMENT_STEPS) expect(body).toContain(escapeHtml(step)); | |
| 53 | }); | |
| 54 | ||
| 55 | test("/terms and the plans line print the same steps as /pricing", async () => { | |
| 56 | expect(termRows(app.db).find((r) => r.term === "after")?.words).toBe(AFTER_PAYMENT); | |
| 57 | const terms = await (await fetch(`${servers.url}/terms`)).text(); | |
| 58 | expect(terms).toContain(escapeHtml(AFTER_PAYMENT)); | |
| 59 | for (const step of AFTER_PAYMENT_STEPS) expect(AFTER_PAYMENT).toContain(step); | |
| 60 | }); |
test/terms-page.test.ts +1 −1
| @@ -40,7 +40,7 @@ describe("/terms", () => { | ||
| 40 | 40 | expect(text.length - main.length).toBeLessThan(10_000); |
| 41 | 41 | expect(text).toContain("<title>Terms"); |
| 42 | 42 | expect(text).toContain("<h1>Terms of a paid forge</h1>"); |
| 43 | expect(text.match(/<dt>/g)!.length).toBe(5); | |
| 43 | expect(text.match(/<dt>/g)!.length).toBe(6); | |
| 44 | 44 | expect(text).toContain(TERMS_DESCRIPTION); |
| 45 | 45 | expect(text).toContain("/privacy"); |
| 46 | 46 | expect(text.match(/<main[\s\S]*?<\/main>/)![0]).not.toContain("<script"); |
test/tui-pricing.test.ts +18
| @@ -292,3 +292,21 @@ test("an address longer than the screen is cut into rows that read back as it", | ||
| 292 | 292 | await f.press(h, "wrapped-address\[email protected]\r"); |
| 293 | 293 | expect(sessionOf(h)).toMatch(/^cs_fake_/); |
| 294 | 294 | }); |
| 295 | ||
| 296 | test("the form shows each after-payment step whole, as the page does (#13262)", async () => { | |
| 297 | const { AFTER_PAYMENT_STEPS } = await import("../src/billing/plan_words.ts"); | |
| 298 | const f = await fixture(); | |
| 299 | const h = f.open("203.0.113.40"); | |
| 300 | await settleApp(h.tui); | |
Only the first four words of each step are checked, so a changed ending would pass. Check the whole step (wrapped rows joined), and add the no-provider case. |
||
| 301 | const text = flat(h); | |
| 302 | for (const step of AFTER_PAYMENT_STEPS) expect(text).toContain(step); | |
| 303 | }); | |
| 304 | ||
| 305 | test("with no provider the form shows none of the after-payment steps (#13262)", async () => { | |
| 306 | const { AFTER_PAYMENT_STEPS } = await import("../src/billing/plan_words.ts"); | |
| 307 | const f = await fixture({ sell: false }); | |
| 308 | const h = f.open("203.0.113.41"); | |
| 309 | await settleApp(h.tui); | |
| 310 | const text = flat(h); | |
| 311 | for (const step of AFTER_PAYMENT_STEPS) expect(text).not.toContain(step.split(" ").slice(0, 4).join(" ")); | |
| 312 | }); |
Box 2: these words live only here; /terms and the plans page do not read them. Share one source. Also 'a minute later' (principle 8) is an unbacked promise, and line 3 repeats AFTER_PAYMENT just above (principle 1).