domains: approved copy (Luna pass DOMAINS-1)
Co-Authored-By: Astra (gpt-6-astra) via Codex <noreply@openai.com>
10 files changed,
+355
−59
approved_domains_buy_copy_test.go+127 −0docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md+107 −0domains_buy_cli.go+7 −2domains_buy_cli_test.go+11 −5domains_buy_copy.go+29 −29internal/console/apidomainbuy_test.go+16 −0internal/console/domainbuy.go+1 −2internal/console/domainbuy_copy.go+49 −19internal/console/domainbuy_test.go+4 −2internal/console/templates/domain_buy.html+4 −0
diff --git a/approved_domains_buy_copy_test.go b/approved_domains_buy_copy_test.go| new file mode 100644 |
| index 000000000..770fd6f58 |
| --- /dev/null |
| +++ b/approved_domains_buy_copy_test.go |
| @@ -0,0 +1,127 @@ |
| +package main |
| + |
| +import ( |
| + "os" |
| + "testing" |
| +) |
| + |
| +// Approved by delegation (Luna), 2026-11-02, plus the four controller rulings. |
| +// Like approved_copy_test.go, compare decoded Go literals byte for byte. |
| +func TestApprovedDomainsBuyCopy(t *testing.T) { |
| + rows := []struct{ key, path, want string }{ |
| + {"browser.title", "internal/console/domainbuy_copy.go", "Buy a domain"}, |
| + {"browser.name", "internal/console/domainbuy_copy.go", "Domain"}, |
| + {"browser.check", "internal/console/domainbuy_copy.go", "Check availability"}, |
| + {"browser.quote", "internal/console/domainbuy_copy.go", "Price for one year"}, |
| + {"browser.paymentDetails", "internal/console/domainbuy_copy.go", "You will review the final payment details at checkout."}, |
| + {"browser.background", "internal/console/domainbuy_copy.go", "Your purchase will continue in the background. Reload this page to check its progress."}, |
| + {"browser.contact", "internal/console/domainbuy_copy.go", "Your contact details"}, |
| + {"browser.pay", "internal/console/domainbuy_copy.go", "Continue to checkout"}, |
| + {"browser.back", "internal/console/domainbuy_copy.go", "Back to domains"}, |
| + {"browser.contactError", "internal/console/domainbuy_copy.go", "Enter your name, email address, postal address, country code and phone number. Use digits for the phone number and calling code, and two uppercase letters for the country."}, |
| + {"browser.nameError", "internal/console/domainbuy_copy.go", "Enter a domain name that can be registered."}, |
| + {"browser.unavailable", "internal/console/domainbuy_copy.go", "buying domains is unavailable right now"}, |
| + {"browser.rate", "internal/console/domainbuy_copy.go", "Too many requests. Wait a minute and try again."}, |
| + {"browser.refused", "internal/console/domainbuy_copy.go", "Refused"}, |
| + {"browser.csrf", "internal/console/domainbuy_copy.go", "This request was blocked."}, |
| + {"browser.notOffered", "internal/console/domainbuy_copy.go", "This domain ending is not offered."}, |
| + {"browser.premium", "internal/console/domainbuy_copy.go", "Premium domains are not offered."}, |
| + {"browser.taken", "internal/console/domainbuy_copy.go", "This domain is not available."}, |
| + {"browser.progress", "internal/console/domainbuy_copy.go", "Your domain purchase"}, |
| + {"browser.pollError", "internal/console/domainbuy_copy.go", "We could not check progress. We will try again shortly."}, |
| + {"browser.awaiting_payment", "internal/console/domainbuy_copy.go", "Waiting for payment approval."}, |
| + {"browser.authorised", "internal/console/domainbuy_copy.go", "Payment approved. Preparing your domain."}, |
| + {"browser.zone_ready", "internal/console/domainbuy_copy.go", "Domain settings are ready."}, |
| + {"browser.registering", "internal/console/domainbuy_copy.go", "Registering your domain."}, |
| + {"browser.registered", "internal/console/domainbuy_copy.go", "Your domain is registered. Taking payment now."}, |
| + {"browser.captured", "internal/console/domainbuy_copy.go", "Payment taken. Connecting your domain to your app."}, |
| + {"browser.done", "internal/console/domainbuy_copy.go", "Your domain is connected. Waiting for HTTPS to be ready."}, |
| + {"browser.live", "internal/console/domainbuy_copy.go", "Your domain is live."}, |
| + {"browser.failed", "internal/console/domainbuy_copy.go", "We could not complete the purchase."}, |
| + {"browser.expired", "internal/console/domainbuy_copy.go", "Checkout expired before you completed it. Nothing was charged. Start a new purchase to try again."}, |
| + {"browser.unpaid", "internal/console/domainbuy_copy.go", "Your domain is registered, but the payment did not go through. We will contact you about paying for it."}, |
| + {"browser.FirstName", "internal/console/domainbuy_copy.go", "First name"}, |
| + {"browser.LastName", "internal/console/domainbuy_copy.go", "Last name"}, |
| + {"browser.Company", "internal/console/domainbuy_copy.go", "Company (optional)"}, |
| + {"browser.Email", "internal/console/domainbuy_copy.go", "Email"}, |
| + {"browser.PhoneCountryCode", "internal/console/domainbuy_copy.go", "Phone country code"}, |
| + {"browser.Phone", "internal/console/domainbuy_copy.go", "Phone number"}, |
| + {"browser.Street", "internal/console/domainbuy_copy.go", "Street"}, |
| + {"browser.HouseNumber", "internal/console/domainbuy_copy.go", "House number (optional)"}, |
| + {"browser.City", "internal/console/domainbuy_copy.go", "City"}, |
| + {"browser.State", "internal/console/domainbuy_copy.go", "State or region (optional)"}, |
| + {"browser.PostalCode", "internal/console/domainbuy_copy.go", "Postal code"}, |
| + {"browser.Country", "internal/console/domainbuy_copy.go", "Country (two uppercase letters)"}, |
| + {"browser.dailyCap", "internal/console/domainbuy_copy.go", "You have reached today's domain purchase limit. Try again tomorrow."}, |
| + {"browser.sharedRefused", "internal/console/appdomains.go", "Refused"}, |
| + {"door.hostUnavailable", "internal/console/apidomains.go", "hostname unavailable"}, |
| + {"door.customDomain", "internal/console/plancaps_copy.go", "custom domains need a paid plan. on this plan the app keeps its platform address"}, |
| + {"door.planCheckFailed", "internal/console/plancaps_copy.go", "could not check this account's plan. Try again"}, |
| + {"cli.help", "domains_buy_copy.go", " check <name> [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n"}, |
| + {"cli.checkUsage", "domains_buy_copy.go", "usage: carlos domains check <name> [--account <a>] [--account-id <id>] [--console <origin>]\n"}, |
| + {"cli.buyUsage", "domains_buy_copy.go", "usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n"}, |
| + {"cli.appFlag", "domains_buy_copy.go", "app the domain will serve"}, |
| + {"cli.accountFlag", "domains_buy_copy.go", "account (sqid or name)"}, |
| + {"cli.accountIDFlag", "domains_buy_copy.go", "account sqid, matched as a sqid only"}, |
| + {"cli.consoleFlag", "domains_buy_copy.go", "console to use (default: the only logged-in one)"}, |
| + {"cli.contactFileFlag", "domains_buy_copy.go", "JSON file containing your contact details"}, |
| + {"cli.yesFlag", "domains_buy_copy.go", "confirm the purchase without prompting"}, |
| + {"cli.noWaitFlag", "domains_buy_copy.go", "print the checkout link and return without waiting"}, |
| + {"cli.quote", "domains_buy_copy.go", "%s: %s, %s %s for one year\n"}, |
| + {"cli.available", "domains_buy_copy.go", "available"}, |
| + {"cli.unavailable", "domains_buy_copy.go", "unavailable"}, |
| + {"cli.confirm", "domains_buy_copy.go", "buy this domain? [y/N] "}, |
| + {"cli.confirmNonTTY", "domains_buy_copy.go", "use --yes to confirm the purchase when stdin is not a terminal"}, |
| + {"cli.cancelled", "domains_buy_copy.go", "purchase cancelled"}, |
| + {"cli.contactNonTTY", "domains_buy_copy.go", "%w; supply contact details with --contact-file contact.json"}, |
| + {"cli.contactFile", "domains_buy_copy.go", "read --contact-file: %w"}, |
| + {"cli.contactJSON", "domains_buy_copy.go", "--contact-file must contain one contact JSON object"}, |
| + {"cli.contactSize", "domains_buy_copy.go", "--contact-file is too large (maximum 16 KiB)"}, |
| + {"cli.contactPrompt", "domains_buy_copy.go", "enter your contact details"}, |
| + {"cli.firstName", "domains_buy_copy.go", "first name: "}, |
| + {"cli.lastName", "domains_buy_copy.go", "last name: "}, |
| + {"cli.company", "domains_buy_copy.go", "company (optional): "}, |
| + {"cli.email", "domains_buy_copy.go", "email: "}, |
| + {"cli.phoneCountryCode", "domains_buy_copy.go", "phone country code (digits only): "}, |
| + {"cli.phone", "domains_buy_copy.go", "phone number (digits only): "}, |
| + {"cli.street", "domains_buy_copy.go", "street: "}, |
| + {"cli.houseNumber", "domains_buy_copy.go", "house number (optional): "}, |
| + {"cli.city", "domains_buy_copy.go", "city: "}, |
| + {"cli.state", "domains_buy_copy.go", "state or province (optional): "}, |
| + {"cli.postalCode", "domains_buy_copy.go", "postal code: "}, |
| + {"cli.country", "domains_buy_copy.go", "country (two uppercase letters): "}, |
| + {"cli.inputEnded", "domains_buy_copy.go", "input ended before the answer was complete"}, |
| + {"cli.checkout", "domains_buy_copy.go", "checkout: %s\n"}, |
| + {"cli.purchaseState", "domains_buy_copy.go", "purchase: %s\n"}, |
| + {"cli.domainState", "domains_buy_copy.go", "domain: %s\n"}, |
| + {"cli.failed", "domains_buy_copy.go", "purchase failed: %s. nothing was charged"}, |
| + {"cli.background", "domains_buy_copy.go", "the domain will finish setting up in the background"}, |
| + {"cli.missingID", "domains_buy_copy.go", "purchase response is missing its ID"}, |
| + {"cli.unreadableCheck", "domains_buy_copy.go", "domains check: unreadable response: %w"}, |
| + {"cli.unreadablePurchase", "domains_buy_copy.go", "domains buy: unreadable response: %w"}, |
| + {"email.owner.unpaidSubject", "internal/console/domainbuy_copy.go", "Payment for %s needs attention"}, |
| + {"email.owner.unpaidBody", "internal/console/domainbuy_copy.go", "Your domain is registered, but the payment did not go through. We will contact you about paying for it."}, |
| + {"email.operator.subject", "internal/console/domainbuy_copy.go", "Domain purchase needs attention"}, |
| + {"email.operator.body", "internal/console/domainbuy_copy.go", "Domain: %s\nPurchase: %s\nAccount: %s\nReason: %s\n"}, |
| + {"operator.reason.registrar_balance", "internal/console/domainbuy.go", "registrar balance"}, |
| + {"operator.reason.registering", "internal/console/domainbuy.go", "registering"}, |
| + {"operator.reason.unconfirmed", "internal/console/domainbuy.go", "unconfirmed"}, |
| + {"operator.reason.unpaid", "internal/console/domainbuy.go", "unpaid"}, |
| + {"browser.ownership", "internal/console/domainbuy_copy.go", "The domain is registered in your name, so it is yours to keep or move."}, |
| + {"browser.timing", "internal/console/domainbuy_copy.go", "Your domain usually works over HTTPS one to five minutes after payment."}, |
| + {"cli.failedNoReason", "domains_buy_copy.go", "purchase failed. nothing was charged"}, |
| + {"cli.expired", "domains_buy_copy.go", "checkout was not completed. nothing was charged"}, |
| + {"cli.unpaid", "domains_buy_copy.go", "the domain is registered but the payment did not go through. we will contact you about paying"}, |
| + } |
| + for _, row := range rows { |
| + t.Run(row.key, func(t *testing.T) { |
| + body, err := os.ReadFile(row.path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if !goLiteralMatches(body, func(s string) bool { return s == row.want }) { |
| + t.Errorf("%s: missing approved string %q", row.path, row.want) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md b/docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md| new file mode 100644 |
| index 000000000..ebb017654 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md |
| @@ -0,0 +1,107 @@ |
| +| key | new | why | |
| +|---|---|---| |
| +| `browser.title` | Buy a domain | Clear action label. | |
| +| `browser.name` | Domain | Clear field label. | |
| +| `browser.check` | Check availability | Clear button label. | |
| +| `browser.quote` | Price for one year | Says what the price covers. | |
| +| `browser.paymentDetails` | You will review the final payment details at checkout. | Clarifies when payment details appear. | |
| +| `browser.background` | Your purchase will continue in the background. Reload this page to check its progress. | Keeps the customer informed without implying the purchase stopped. | |
| +| `browser.contact` | Your contact details | Avoids the unexplained term “registrant”; the form collects the customer’s details. | |
| +| `browser.pay` | Continue to checkout | Describes the button’s action. | |
| +| `browser.back` | Back to domains | Clear link label. | |
| +| `browser.contactError` | Enter your name, email address, postal address, country code and phone number. Use digits for the phone number and calling code, and two uppercase letters for the country. | Uses familiar terms and clarifies the required formats. | |
| +| `browser.nameError` | Enter a domain name that can be registered. | Plain explanation. | |
| +| `browser.unavailable` | buying domains is unavailable right now | Already follows the neutral lower-case style. | |
| +| `browser.rate` | Too many requests. Wait a minute and try again. | Clear instruction. | |
| +| `browser.refused` | Refused | Neutral short title. | |
| +| `browser.csrf` | This request was blocked. | Plain explanation that does not expose account or name information. | |
| +| `browser.notOffered` | This domain ending is not offered. | Clear refusal. | |
| +| `browser.premium` | Premium domains are not offered. | Clear refusal. | |
| +| `browser.taken` | This domain is not available. | Neutral wording; this draft has no current caller. | |
| +| `browser.progress` | Your domain purchase | Clear progress heading. | |
| +| `browser.pollError` | We could not check progress. We will try again shortly. | Plain, reassuring retry message. | |
| +| `browser.awaiting_payment` | Waiting for payment approval. | Clear progress update. | |
| +| `browser.authorised` | Payment approved. Preparing your domain. | Distinguishes approval from taking payment. | |
| +| `browser.zone_ready` | Domain settings are ready. | Clear progress update. | |
| +| `browser.registering` | Registering your domain. | Clear progress update. | |
| +| `browser.registered` | Your domain is registered. Taking payment now. | Makes clear registration has succeeded and payment is being taken afterward. | |
| +| `browser.captured` | Payment taken. Connecting your domain to your app. | Avoids payment jargon and says what happens next. | |
| +| `browser.done` | Your domain is connected. Waiting for HTTPS to be ready. | Makes clear connection is complete but the domain is not yet live. | |
| +| `browser.live` | Your domain is live. | Clear completion state. | |
| +| `browser.failed` | We could not complete the purchase. | Plain failure message. | |
| +| `browser.expired` | Checkout expired before you completed it. Nothing was charged. Start a new purchase to try again. | Clarifies that the checkout expired, nothing was charged and a new purchase is needed. | |
| +| `browser.unpaid` | Your domain is registered and still yours, but we could not take payment. Auto-renew is off while payment is outstanding. Review your billing details. | Explains ownership, payment status and auto-renew accurately. | |
| +| `browser.FirstName` | First name | Clear field label. | |
| +| `browser.LastName` | Last name | Clear field label. | |
| +| `browser.Company` | Company (optional) | Clear field label. | |
| +| `browser.Email` | Email | Clear field label. | |
| +| `browser.PhoneCountryCode` | Phone country code | Clear field label. | |
| +| `browser.Phone` | Phone number | Clear field label. | |
| +| `browser.Street` | Street | Clear field label. | |
| +| `browser.HouseNumber` | House number (optional) | Clear field label. | |
| +| `browser.City` | City | Clear field label. | |
| +| `browser.State` | State or region (optional) | Clear field label. | |
| +| `browser.PostalCode` | Postal code | Clear field label. | |
| +| `browser.Country` | Country (two uppercase letters) | Clear field label and format. | |
| +| `browser.dailyCap` | You have reached today's domain purchase limit. Try again tomorrow. | Clear refusal and next step. | |
| +| `browser.sharedRefused` | Refused | Neutral short title. | |
| +| `door.hostUnavailable` | hostname unavailable | Already neutral and lower case. | |
| +| `door.customDomain` | custom domains need a paid plan. on this plan the app keeps its platform address | Already follows the shared lower-case door style and explains the refusal. | |
| +| `door.planCheckFailed` | could not check this account's plan. try again | Lower-case shared refusal with a simple next step. | |
| +| `cli.help` |   check <name> [flags]<br>                  check availability and the price for one year<br>  buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]<br>                  buy a domain and wait for it to serve the app<br><br> | Uses lower-case CLI wording and preserves indentation and line breaks. | |
| +| `cli.checkUsage` | usage: carlos domains check <name> [--account <a>] [--account-id <id>] [--console <origin>]<br> | Already lower case; preserves command syntax and final line break. | |
| +| `cli.buyUsage` | usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]<br> | Already lower case; preserves command syntax and final line break. | |
| +| `cli.appFlag` | app the domain will serve | Already clear and lower case. | |
| +| `cli.accountFlag` | account (sqid or name) | Already clear and lower case. | |
| +| `cli.accountIDFlag` | account sqid, matched as a sqid only | Already clear and lower case. | |
| +| `cli.consoleFlag` | console to use (default: the only logged-in one) | Already clear and lower case. | |
| +| `cli.contactFileFlag` | JSON file containing your contact details | Avoids an unexplained term and makes clear whose details to supply. | |
| +| `cli.yesFlag` | confirm the purchase without prompting | Already clear and lower case. | |
| +| `cli.noWaitFlag` | print the checkout link and return without waiting | The output is a checkout link; this does not imply a payment link or that the purchase is cancelled. | |
| +| `cli.quote` | %s: %s, %s %s for one year<br> | Already concise and preserves placeholder order. | |
| +| `cli.available` | available | Already clear and lower case. | |
| +| `cli.unavailable` | unavailable | Already clear and lower case. | |
| +| `cli.confirm` | buy this domain? [y/N]  | Lower-case prompt; preserves choice and trailing space. | |
| +| `cli.confirmNonTTY` | use --yes to confirm the purchase when stdin is not a terminal | Already clear and lower case. | |
| +| `cli.cancelled` | purchase cancelled | Lower-case CLI style. | |
| +| `cli.contactNonTTY` | %w; supply contact details with --contact-file contact.json | Already lower case and preserves the wrapped error. | |
| +| `cli.contactFile` | read --contact-file: %w | Already clear and lower case. | |
| +| `cli.contactJSON` | --contact-file must contain one contact JSON object | Already clear and lower case. | |
| +| `cli.contactSize` | --contact-file is too large (maximum 16 KiB) | Already clear and lower case. | |
| +| `cli.contactPrompt` | enter your contact details | Lower-case CLI style and plain wording. | |
| +| `cli.firstName` | first name:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.lastName` | last name:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.company` | company (optional):  | Lower-case prompt; preserves trailing space. | |
| +| `cli.email` | email:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.phoneCountryCode` | phone country code (digits only):  | Lower-case prompt; preserves trailing space. | |
| +| `cli.phone` | phone number (digits only):  | Lower-case prompt; preserves trailing space. | |
| +| `cli.street` | street:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.houseNumber` | house number (optional):  | Lower-case prompt; preserves trailing space. | |
| +| `cli.city` | city:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.state` | state or province (optional):  | Lower-case prompt; preserves trailing space. | |
| +| `cli.postalCode` | postal code:  | Lower-case prompt; preserves trailing space. | |
| +| `cli.country` | country (two uppercase letters):  | Lower-case prompt; preserves format and trailing space. | |
| +| `cli.inputEnded` | input ended before the answer was complete | Already clear and lower case. | |
| +| `cli.checkout` | checkout: %s<br> | Lower-case CLI style; preserves placeholder and line break. | |
| +| `cli.purchaseState` | purchase: %s<br> | Lower-case CLI style; preserves raw state value. | |
| +| `cli.domainState` | domain: %s<br> | Lower-case CLI style; preserves raw state value. | |
| +| `cli.failed` | %s: %s | The raw state and reason do not explain whether payment was taken, whether a domain is registered, or whether checkout expired. | |
| +| `cli.background` | the domain will finish setting up in the background | Lower-case CLI style; states that setup continues. | |
| +| `cli.missingID` | purchase response is missing its ID | Already clear and lower case. | |
| +| `cli.unreadableCheck` | domains check: unreadable response: %w | Already clear and lower case. | |
| +| `cli.unreadablePurchase` | domains buy: unreadable response: %w | Already clear and lower case. | |
| +| `email.owner.unpaidSubject` | Payment for %s needs attention | Clear subject; preserves placeholder. | |
| +| `email.owner.unpaidBody` | We registered %s for you, but could not take payment. The domain is still yours. Auto-renew is off while payment is outstanding.<br><br>Review your billing details:<br>%s<br> | Uses plain payment language and confirms ownership; preserves the billing URL and line breaks. | |
| +| `email.operator.subject` | Domain purchase needs attention | Clear, concise operator subject. | |
| +| `email.operator.body` | Domain: %s<br>Purchase: %s<br>Account: %s<br>Reason: %s<br> | Keeps the identifying details and their order. | |
| +| `operator.reason.registrar_balance` | registrar balance | Fixed raw reason value. | |
| +| `operator.reason.registering` | registering | Fixed raw reason value. | |
| +| `operator.reason.unconfirmed` | unconfirmed | Fixed raw reason value. | |
| +| `operator.reason.unpaid` | unpaid | Fixed raw reason value. | |
| + |
| +## Flags |
| + |
| +- The browser form has no string explaining that the customer is the registrant and owns the domain, or that it usually takes one to five minutes after checkout to become available over HTTPS. Add a customer sentence and place it near the contact form or progress view. |
| +- The owner email and unpaid progress text link to the account billing page, which is not a payment link and may not settle this purchase. The product needs to define how customers resolve an unpaid purchase before copy can give a recovery instruction. |
| +- `cli.failed` needs state-specific wording or a structured result so it can explain `failed`, `expired` and `unpaid` accurately, including an empty reason. Keep `taken` neutral and do not reveal private ownership or purchase information. |
| +- `door.planCheckFailed` is shared. Changing its capitalization affects other callers, so apply the lower-case wording only if the shared refusal style is intended across those callers. |
| \ No newline at end of file |
diff --git a/domains_buy_cli.go b/domains_buy_cli.go| index ecc181361..df6a862f1 100644 |
| --- a/domains_buy_cli.go |
| +++ b/domains_buy_cli.go |
| @@ -231,8 +231,13 @@ func waitDomainPurchase(ctx context.Context, s *apiSession, acct apiAcct, p doma |
| seen[p.State] = true |
| } |
| switch p.State { |
| - case "failed", "expired", "unpaid": |
| - return fmt.Errorf(domainsBuyCopy["failed"], p.State, p.Reason) |
| + case "failed": |
| + if p.Reason == "" { |
| + return errors.New(domainsBuyCopy["failedNoReason"]) |
| + } |
| + return fmt.Errorf(domainsBuyCopy["failed"], p.Reason) |
| + case "expired", "unpaid": |
| + return errors.New(domainsBuyCopy[p.State]) |
| case "done": |
| if doneAt.IsZero() { |
| doneAt = o.now() |
diff --git a/domains_buy_cli_test.go b/domains_buy_cli_test.go| index c02a80995..dc781d1a1 100644 |
| --- a/domains_buy_cli_test.go |
| +++ b/domains_buy_cli_test.go |
| @@ -119,16 +119,22 @@ func runBuyTestCommand(t *testing.T, base string, args ...string) (string, error |
| } |
| func TestDomainsBuyFailedExitsNonZeroWithReason(t *testing.T) { |
| - for _, state := range []string{"failed", "expired", "unpaid"} { |
| - t.Run(state, func(t *testing.T) { |
| + for _, tc := range []struct{ name, state, reason, want string }{ |
| + {"failed", "failed", "payment not completed", "purchase failed: payment not completed. nothing was charged"}, |
| + {"empty reason", "failed", "", "purchase failed. nothing was charged"}, |
| + {"taken", "failed", "taken", "purchase failed: taken. nothing was charged"}, |
| + {"expired", "expired", "payment not completed", "checkout was not completed. nothing was charged"}, |
| + {"unpaid", "unpaid", "", "the domain is registered but the payment did not go through. we will contact you about paying"}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| ts := buyTestServer(t, func(w http.ResponseWriter, r *http.Request) { |
| fmt.Fprint(w, `{"id":"p1","state":"awaiting_payment"}`) |
| }, func(w http.ResponseWriter, r *http.Request) { |
| - json.NewEncoder(w).Encode(map[string]string{"id": "p1", "state": state, "reason": "payment not completed"}) |
| + json.NewEncoder(w).Encode(map[string]string{"id": "p1", "state": tc.state, "reason": tc.reason}) |
| }) |
| out, err := runBuyTestCommand(t, ts.URL) |
| - if err == nil || !strings.Contains(out, state) || !strings.Contains(out, "payment not completed") { |
| - t.Fatalf("err=%v output=%s", err, out) |
| + if err == nil || !strings.Contains(out, tc.want) || strings.Contains(out, "%!") { |
| + t.Fatalf("err=%v output=%s, want %q", err, out, tc.want) |
| } |
| }) |
| } |
diff --git a/domains_buy_copy.go b/domains_buy_copy.go| index 042640ab6..bfe00c1e5 100644 |
| --- a/domains_buy_copy.go |
| +++ b/domains_buy_copy.go |
| @@ -1,12 +1,9 @@ |
| package main |
| -// Plan 1 drafts, replaced by the Luna pass (Task 11). |
| -const domainsBuyHelp = ` check <name> [flags] |
| - check availability and the price for one year |
| - buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags] |
| - buy a domain and wait for it to serve the app |
| - |
| -` |
| +// Approved by delegation (Luna), 2026-11-02: |
| +// docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md, plus controller rulings |
| +// on four flags. Apply later edits through a copy pass. |
| +const domainsBuyHelp = " check <name> [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app\n\n" |
| const domainsCheckUsage = "usage: carlos domains check <name> [--account <a>] [--account-id <id>] [--console <origin>]\n" |
| const domainsBuyUsage = "usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n" |
| @@ -16,39 +13,42 @@ var domainsBuyCopy = map[string]string{ |
| "accountFlag": "account (sqid or name)", |
| "accountIDFlag": "account sqid, matched as a sqid only", |
| "consoleFlag": "console to use (default: the only logged-in one)", |
| - "contactFileFlag": "JSON file containing the registrant's contact details", |
| + "contactFileFlag": "JSON file containing your contact details", |
| "yesFlag": "confirm the purchase without prompting", |
| - "noWaitFlag": "print the payment link without waiting for completion", |
| + "noWaitFlag": "print the checkout link and return without waiting", |
| "quote": "%s: %s, %s %s for one year\n", |
| "available": "available", |
| "unavailable": "unavailable", |
| - "confirm": "Buy this domain? [y/N] ", |
| + "confirm": "buy this domain? [y/N] ", |
| "confirmNonTTY": "use --yes to confirm the purchase when stdin is not a terminal", |
| - "cancelled": "Purchase cancelled.", |
| + "cancelled": "purchase cancelled", |
| "contactNonTTY": "%w; supply contact details with --contact-file contact.json", |
| "contactFile": "read --contact-file: %w", |
| "contactJSON": "--contact-file must contain one contact JSON object", |
| "contactSize": "--contact-file is too large (maximum 16 KiB)", |
| - "contactPrompt": "Enter the registrant's contact details.", |
| - "firstName": "First name: ", |
| - "lastName": "Last name: ", |
| - "company": "Company (optional): ", |
| - "email": "Email: ", |
| - "phoneCountryCode": "Phone country code (digits only): ", |
| - "phone": "Phone national number (digits only): ", |
| - "street": "Street: ", |
| - "houseNumber": "House number (optional): ", |
| - "city": "City: ", |
| - "state": "State or province (optional): ", |
| - "postalCode": "Postal code: ", |
| - "country": "Country (two uppercase letters): ", |
| + "contactPrompt": "enter your contact details", |
| + "firstName": "first name: ", |
| + "lastName": "last name: ", |
| + "company": "company (optional): ", |
| + "email": "email: ", |
| + "phoneCountryCode": "phone country code (digits only): ", |
| + "phone": "phone number (digits only): ", |
| + "street": "street: ", |
| + "houseNumber": "house number (optional): ", |
| + "city": "city: ", |
| + "state": "state or province (optional): ", |
| + "postalCode": "postal code: ", |
| + "country": "country (two uppercase letters): ", |
| "inputEnded": "input ended before the answer was complete", |
| - "checkout": "Checkout: %s\n", |
| - "purchaseState": "Purchase: %s\n", |
| - "domainState": "Domain: %s\n", |
| - "failed": "%s: %s", |
| - "background": "The domain will finish setting up in the background.", |
| + "checkout": "checkout: %s\n", |
| + "purchaseState": "purchase: %s\n", |
| + "domainState": "domain: %s\n", |
| + "failed": "purchase failed: %s. nothing was charged", |
| + "background": "the domain will finish setting up in the background", |
| "missingID": "purchase response is missing its ID", |
| "unreadableCheck": "domains check: unreadable response: %w", |
| "unreadablePurchase": "domains buy: unreadable response: %w", |
| + "failedNoReason": "purchase failed. nothing was charged", |
| + "expired": "checkout was not completed. nothing was charged", |
| + "unpaid": "the domain is registered but the payment did not go through. we will contact you about paying", |
| } |
diff --git a/internal/console/apidomainbuy_test.go b/internal/console/apidomainbuy_test.go| index 47e307af1..64f55c66c 100644 |
| --- a/internal/console/apidomainbuy_test.go |
| +++ b/internal/console/apidomainbuy_test.go |
| @@ -177,6 +177,14 @@ func TestBrowserBuyRedirectsToCheckout(t *testing.T) { |
| if status != 200 || !strings.Contains(body, "$15") || strings.Contains(body, "$15 usd") || !strings.Contains(body, "PhoneCountryCode") { |
| t.Fatalf("quote status=%d, has price=%v, duplicate currency=%v, has phone=%v", status, strings.Contains(body, "$15"), strings.Contains(body, "$15 usd"), strings.Contains(body, "PhoneCountryCode")) |
| } |
| + for _, want := range []string{ |
| + "The domain is registered in your name, so it is yours to keep or move.", |
| + "Your domain usually works over HTTPS one to five minutes after payment.", |
| + } { |
| + if !strings.Contains(body, "<p>"+want+"</p>") { |
| + t.Errorf("missing visible copy %q", want) |
| + } |
| + } |
| values := url.Values{"csrf": {csrf}, "name": {"shop.com"}} |
| for _, field := range buyContactFields(purchaseContact()) { |
| values.Set(field.Name, field.Value) |
| @@ -193,6 +201,14 @@ func TestBrowserBuyRedirectsToCheckout(t *testing.T) { |
| if status != 200 || !strings.Contains(body, "fetch(") { |
| t.Fatalf("purchase page %d %s", status, body) |
| } |
| + for _, want := range []string{ |
| + "The domain is registered in your name, so it is yours to keep or move.", |
| + "Your domain usually works over HTTPS one to five minutes after payment.", |
| + } { |
| + if !strings.Contains(body, "<p>"+want+"</p>") { |
| + t.Errorf("missing visible copy %q", want) |
| + } |
| + } |
| } |
| func TestBrowserBuyCSRF(t *testing.T) { |
| f := newPurchaseFixture(t) |
diff --git a/internal/console/domainbuy.go b/internal/console/domainbuy.go| index 99ea0e312..15a813199 100644 |
| --- a/internal/console/domainbuy.go |
| +++ b/internal/console/domainbuy.go |
| @@ -7,7 +7,6 @@ import ( |
| "fmt" |
| "log" |
| "net/http" |
| - "net/url" |
| "os" |
| "time" |
| @@ -660,7 +659,7 @@ func (s *Server) purchaseOwnerNotice(ctx context.Context, acct *Account, p *Doma |
| return |
| } |
| subject := fmt.Sprintf(domainPurchaseCopy.UnpaidSubject, p.Domain) |
| - body := fmt.Sprintf(domainPurchaseCopy.UnpaidBody, p.Domain, s.cfg.Origin+"/a/"+url.PathEscape(acct.Sqid)+"/billing") |
| + body := domainPurchaseCopy.UnpaidBody |
| for _, member := range members { |
| if member.Role != RoleOwner { |
| continue |
diff --git a/internal/console/domainbuy_copy.go b/internal/console/domainbuy_copy.go| index da1241a43..ae42c112c 100644 |
| --- a/internal/console/domainbuy_copy.go |
| +++ b/internal/console/domainbuy_copy.go |
| @@ -10,25 +10,55 @@ import ( |
| "github.com/carlosframework/platform/internal/registrar" |
| ) |
| -// Plan 1 drafts, replaced by the Luna pass (Task 11). |
| +// Approved by delegation (Luna), 2026-11-02: |
| +// docs/superpowers/specs/LUNA-COPY-RESULT-DOMAINS-1.md, plus controller rulings |
| +// on four flags. Apply later edits through a copy pass. |
| var domainBuyCopy = map[string]string{ |
| - "title": "Buy a domain", "name": "Domain", "check": "Check availability", |
| - "quote": "Price for one year", "paymentDetails": "Final payment details appear at checkout.", |
| - "background": "Your purchase will continue in the background. Reload this page to check progress.", |
| - "contact": "Registrant contact details", "pay": "Continue to checkout", "back": "Back to domains", |
| - "contactError": "Enter your name, email, address, country code and phone number. Use digits for the phone and calling code, and two uppercase letters for the country.", |
| - "nameError": "Enter a registrable domain name.", "unavailable": "buying domains is unavailable right now", |
| - "rate": "Too many requests. Wait a minute and try again.", "refused": "Refused", "csrf": "Cross-site request blocked.", |
| - "notOffered": "This domain ending is not offered.", "premium": "Premium domains are not offered.", "taken": "This domain is not available.", |
| - "progress": "Your domain purchase", "pollError": "Could not check progress. Retrying shortly.", |
| - "awaiting_payment": "Waiting for payment approval.", "authorised": "Payment approved. Preparing your domain.", |
| - "zone_ready": "Domain settings are ready.", "registering": "Registering your domain.", "registered": "Domain registered. Collecting payment.", |
| - "captured": "Payment collected. Connecting your app.", "done": "Domain connected. Waiting for HTTPS to be ready.", |
| - "live": "Your domain is live.", "failed": "The purchase could not be completed.", "expired": "The checkout expired. Start a new purchase to try again.", |
| - "unpaid": "Your domain is registered, but payment needs attention. Check your billing details.", |
| - "FirstName": "First name", "LastName": "Last name", "Company": "Company (optional)", "Email": "Email", |
| - "PhoneCountryCode": "Phone calling code", "Phone": "National phone number", "Street": "Street", "HouseNumber": "House number (optional)", |
| - "City": "City", "State": "State or region (optional)", "PostalCode": "Postal code", "Country": "Country (two uppercase letters)", |
| + "title": "Buy a domain", |
| + "name": "Domain", |
| + "check": "Check availability", |
| + "quote": "Price for one year", |
| + "paymentDetails": "You will review the final payment details at checkout.", |
| + "background": "Your purchase will continue in the background. Reload this page to check its progress.", |
| + "contact": "Your contact details", |
| + "pay": "Continue to checkout", |
| + "back": "Back to domains", |
| + "contactError": "Enter your name, email address, postal address, country code and phone number. Use digits for the phone number and calling code, and two uppercase letters for the country.", |
| + "nameError": "Enter a domain name that can be registered.", |
| + "unavailable": "buying domains is unavailable right now", |
| + "rate": "Too many requests. Wait a minute and try again.", |
| + "refused": "Refused", |
| + "csrf": "This request was blocked.", |
| + "notOffered": "This domain ending is not offered.", |
| + "premium": "Premium domains are not offered.", |
| + "taken": "This domain is not available.", |
| + "progress": "Your domain purchase", |
| + "pollError": "We could not check progress. We will try again shortly.", |
| + "awaiting_payment": "Waiting for payment approval.", |
| + "authorised": "Payment approved. Preparing your domain.", |
| + "zone_ready": "Domain settings are ready.", |
| + "registering": "Registering your domain.", |
| + "registered": "Your domain is registered. Taking payment now.", |
| + "captured": "Payment taken. Connecting your domain to your app.", |
| + "done": "Your domain is connected. Waiting for HTTPS to be ready.", |
| + "live": "Your domain is live.", |
| + "failed": "We could not complete the purchase.", |
| + "expired": "Checkout expired before you completed it. Nothing was charged. Start a new purchase to try again.", |
| + "unpaid": "Your domain is registered, but the payment did not go through. We will contact you about paying for it.", |
| + "FirstName": "First name", |
| + "LastName": "Last name", |
| + "Company": "Company (optional)", |
| + "Email": "Email", |
| + "PhoneCountryCode": "Phone country code", |
| + "Phone": "Phone number", |
| + "Street": "Street", |
| + "HouseNumber": "House number (optional)", |
| + "City": "City", |
| + "State": "State or region (optional)", |
| + "PostalCode": "Postal code", |
| + "Country": "Country (two uppercase letters)", |
| + "ownership": "The domain is registered in your name, so it is yours to keep or move.", |
| + "timing": "Your domain usually works over HTTPS one to five minutes after payment.", |
| } |
| func domainBuyErrorRefusal(err error) *doorRefusal { |
| @@ -54,7 +84,7 @@ var domainPurchaseCopy = struct { |
| }{ |
| DailyCap: "You have reached today's domain purchase limit. Try again tomorrow.", |
| UnpaidSubject: "Payment for %s needs attention", |
| - UnpaidBody: "We registered %s for you, but could not collect the payment. Your domain is still yours. Auto-renew is off while payment is outstanding.\n\nReview your billing details:\n%s\n", |
| + UnpaidBody: "Your domain is registered, but the payment did not go through. We will contact you about paying for it.", |
| OperatorSubject: "Domain purchase needs attention", |
| OperatorBody: "Domain: %s\nPurchase: %s\nAccount: %s\nReason: %s\n", |
| } |
diff --git a/internal/console/domainbuy_test.go b/internal/console/domainbuy_test.go| index bae7931dc..f2437c606 100644 |
| --- a/internal/console/domainbuy_test.go |
| +++ b/internal/console/domainbuy_test.go |
| @@ -573,8 +573,6 @@ func TestPurchaseUnpaidNotifiesOwnersAndOperator(t *testing.T) { |
| f := newPurchaseFixture(t) |
| previousCopy, previousPage := domainPurchaseCopy, pageDomainPurchase |
| t.Cleanup(func() { domainPurchaseCopy = previousCopy; pageDomainPurchase = previousPage }) |
| - domainPurchaseCopy.UnpaidSubject = "%s" |
| - domainPurchaseCopy.UnpaidBody = "%s %s" |
| domainPurchaseCopy.OperatorSubject = "purchase" |
| domainPurchaseCopy.OperatorBody = "%s %s %s %s" |
| var alerts []string |
| @@ -602,6 +600,10 @@ func TestPurchaseUnpaidNotifiesOwnersAndOperator(t *testing.T) { |
| if len(mail.sentCopy()) != 1 { |
| t.Fatalf("owner emails: %v", mail.sentCopy()) |
| } |
| + want := "Your domain is registered, but the payment did not go through. We will contact you about paying for it." |
| + if got := strings.SplitN(mail.sentCopy()[0], "|", 2)[1]; got != want { |
| + t.Fatalf("owner email body = %q, want %q", got, want) |
| + } |
| } |
| func TestPurchaseRetryRefusalDoesNotDisproveEarlierRegistration(t *testing.T) { |
diff --git a/internal/console/templates/domain_buy.html b/internal/console/templates/domain_buy.html| index f66605e16..9ac0cb60c 100644 |
| --- a/internal/console/templates/domain_buy.html |
| +++ b/internal/console/templates/domain_buy.html |
| @@ -3,6 +3,8 @@ |
| {{with .DomainBuy}} |
| {{if .Purchase}} |
| <h2>{{$.DomainBuyCopy.progress}}: {{.Purchase.Domain}}</h2> |
| +<p>{{$.DomainBuyCopy.ownership}}</p> |
| +<p>{{$.DomainBuyCopy.timing}}</p> |
| <p id="purchase-progress" role="status">{{index $.DomainBuyCopy (printf "%s" .Purchase.State)}}</p> |
| <script> |
| (function () { |
| @@ -28,6 +30,8 @@ |
| <p>{{$.DomainBuyCopy.quote}}: {{.Price}}</p> |
| <p class="small">{{$.DomainBuyCopy.paymentDetails}}</p> |
| <h2>{{$.DomainBuyCopy.contact}}</h2> |
| +<p>{{$.DomainBuyCopy.ownership}}</p> |
| +<p>{{$.DomainBuyCopy.timing}}</p> |
| <form method="post" action="{{.Base}}/buy"> |
| <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| <input type="hidden" name="name" value="{{.Quote.Domain}}"> |