carlos / platform Public

plan 2a: Checkout return URL change moves to Task 9 (pre-flight)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4fb6e37d83d612ba1b4b31de2c4e3ebb3516b8f4 parent 40ca6f7
1 file changed, +1 −1
  • docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md +1 −1
diff --git a/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md b/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
index 1c4cedfdc..a72964583 100644
--- a/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
+++ b/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
@@ -144,7 +144,6 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
Behaviour changes, each its own CAS transition as in Plan 1:
- **Start (r1 1, r1 4):** `contact.New` → `AddSavedContact`. `contact.ID` not the account's → 422 `code:"contact"`. The purchase's `details` take `ContactID`, `ContactVersion`, `Contact` and, when the saved contact has one, `OwnerHandle` = its `Handle`. The paid-plan rule and daily cap apply whether or not an app is chosen (§11.4). `CreateDomainPurchase` moves inside the billing hold (before `release()` at `domainbuy.go:207`), preceded under that hold by a re-read of the account that refuses (`domainBuyUnavailable`) when it is gone or retiring. Account deletion already holds the same hold from `retireForDeletion` through `DeleteAccount` (`ownership.go:139`), so a purchase row either exists before deletion's check (Task 6) or is never written.
- **Checkout step** (`purchaseCheckoutStep`, replacing the `DomainContact`/`SetDomainContact` read and write): `OwnerHandle` already set → no registrar call. Empty → `EnsureContact(ctx, "", details.Contact)`, store the handle in the purchase, then `SetSavedContactHandle(accountID, ContactID, ContactVersion, handle)` (a false result is fine: the contact was edited meanwhile). Legacy purchases (empty `ContactID`) keep Plan 1's behaviour on their own frozen `Contact`, without writing `domain_contacts`. `TouchSavedContact` on success.
- - **Checkout return URLs (r3 6):** `domainPurchaseURL` (`appdomainbuy.go:83`) becomes `domainPurchaseURL(account, id string)` returning `/a/{sqid}/domains/purchases/{id}`; every caller (Checkout's success and cancel URLs at `domainbuy.go:384`, the card links) switches. Checkouts prepared before this ship keep their old app path, which Task 9 redirects without needing the app.
- **`authorised` step:** `SetManaged(zone, purchaseManagedSet(p))`.
- **`registered`:** `registeredPurchase` stores `Registrant = details.Contact` (the frozen copy). When the registration row already exists (the insert-before-state-update crash window, `domainbuy.go:738`) and its registrant is `'{}'`, it updates it (r1 2).
- **`captured` step:** `App == ""` → `done`, no attach. App not in `AppsIn(acct.ID)` (purged or in Trash, my call: attaching to a trashed app would serve nothing): first release anything an earlier attempt attached (r3 1): for the apex and `www.` + domain, `s.detachDomainClaim(ctx, host, acct.Sqid, p.App)` (owner-checked, so another holder's claim is never touched; idempotent), and `provision` first-route records for those hosts under the old app if `attachDomainAs` wrote any (`domainattach.go:1-50`; the builder finds the matching removal the detach door uses). Any failure leaves the purchase `captured` for the next pass. Then `SetManaged(zone, ManagedSet{})`, then `done` with `App = ""` and `Reason = "app_gone"`. Buying is off while the HostClaim gate is on (Global Constraints), so this never runs against an armed gate (r2 4).
@@ -275,6 +274,7 @@ Waits on Paul's look at Task 1 (or his "go on" on the discussion).
- `GET /a/{sqid}/domains/buy?step=name|app|pay&name=&app=&notyet=` and `POST /a/{sqid}/domains/buy/check` (step 1 → quote → step 2), `POST /a/{sqid}/domains/buy` (step 3 → `startDomainPurchase` → Checkout). Step state travels in the query and hidden fields; the quote is re-checked at pay (Plan 1's `price_changed` path). `app=` preselects (from app Settings) and stays changeable; "Not yet" is `notyet=1` with `app` empty, so an empty value is never a silent default.
- `GET /a/{sqid}/domains/purchases/{id}` and `.../status` (the Plan 1 card and JSON, account-scoped; another account's ID → 404 identical to unknown).
- Old app-scoped routes: `GET .../apps/{app}/domains/buy` → 303 to `/a/{sqid}/domains/buy?app=<app>`; `GET .../apps/{app}/domains/purchases/{id}[/status]` → 303 to the account paths (`fetch` follows a 303 for an open page). These redirect routes check only account membership and the purchase's account, never that `{app}` still exists, so a Checkout return after the app was purged still lands (r3 6); the old `POST .../domains/check` and `POST .../domains/buy` (stale forms only) → 303 to the new buy page with `app` preselected, starting nothing (r1 14).
+ - **Checkout return URLs (r3 6):** `domainPurchaseURL` (`appdomainbuy.go:83`) becomes `domainPurchaseURL(account, id string)` returning `/a/{sqid}/domains/purchases/{id}`; every caller (Checkout's success and cancel URLs at `domainbuy.go:384`, the card links) switches. Checkouts prepared before this ship keep their old app path, which the redirects above handle without needing the app.
- `POST /a/{sqid}/domains/contacts` (add), `POST /a/{sqid}/domains/contacts/{id}` (edit), `POST /a/{sqid}/domains/contacts/{id}/remove`.
- Step 3's "Registered to" is a searchable list of saved contacts with the most recently used preselected, ending with "Add a new contact" (fields in place, saved by the purchase).