domains: check takes the contact country; card door gated
Co-Authored-By: Astra (gpt-6-astra) via Codex <noreply@openai.com>
14 files changed,
+285
−21
apimode.go+4 −3approved_domains_buy_copy_test.go+3 −0domains_buy_cli.go+6 −2domains_buy_cli_test.go+60 −2domains_buy_copy.go+1 −1internal/console/apidomainbuy.go+14 −7internal/console/appdomainbuy.go+4 −1internal/console/billingcard.go+1 −1internal/console/billingcard_test.go+13 −0internal/console/domainbuy_copy.go+2 −2internal/console/domainbuy_fix_test.go+1 −1internal/console/domainbuy_round2_test.go+173 −0internal/console/templates/domain_buy.html+2 −0internal/provision/testdata/plan14-root-reads-domains-buy-nosub.tsv+1 −1
CI failed — run details
diff --git a/apimode.go b/apimode.go| index e9dd25463..070250a99 100644 |
| --- a/apimode.go |
| +++ b/apimode.go |
| @@ -4709,11 +4709,12 @@ func domainBuyAPIPath(acct apiAcct, tail string) string { |
| return path |
| } |
| -func (s *apiSession) postDomainCheck(ctx context.Context, acct apiAcct, name string) (domainQuoteResp, error) { |
| +func (s *apiSession) postDomainCheck(ctx context.Context, acct apiAcct, name, country string) (domainQuoteResp, error) { |
| var out domainQuoteResp |
| status, body, err := s.postJSON(ctx, domainBuyAPIPath(acct, "/check"), struct { |
| - Name string `json:"name"` |
| - }{name}) |
| + Name string `json:"name"` |
| + Country string `json:"country,omitempty"` |
| + }{name, country}) |
| if err != nil { |
| return out, err |
| } |
diff --git a/approved_domains_buy_copy_test.go b/approved_domains_buy_copy_test.go| index 5d0ec2998..7905454a7 100644 |
| --- a/approved_domains_buy_copy_test.go |
| +++ b/approved_domains_buy_copy_test.go |
| @@ -9,6 +9,9 @@ import ( |
| // Like approved_copy_test.go, compare decoded Go literals byte for byte. |
| func TestApprovedDomainsBuyCopy(t *testing.T) { |
| rows := []struct{ key, path, want string }{ |
| + // Approved by delegation (reviewer), 2026-11-03. |
| + {"browser.priceChanged", "internal/console/domainbuy_copy.go", "the price is different from the one you confirmed. confirm the new price to continue"}, |
| + {"cli.confirmChanged", "domains_buy_copy.go", "buy this domain at the new price? [y/N] "}, |
| // Approved by delegation (Luna), 2026-11-03, including the controller's hint. |
| {"browser.billingSetup", "internal/console/domainbuy_copy.go", "we could not set up billing for your account. try again later"}, |
| {"browser.currency", "internal/console/domainbuy_copy.go", "we could not find a price for this domain in your account currency"}, |
diff --git a/domains_buy_cli.go b/domains_buy_cli.go| index 79798dd67..1b899a0f0 100644 |
| --- a/domains_buy_cli.go |
| +++ b/domains_buy_cli.go |
| @@ -76,7 +76,7 @@ func printDomainQuote(out io.Writer, q domainQuoteResp) { |
| } |
| func domainsCheck(ctx context.Context, s *apiSession, acct apiAcct, name string, out io.Writer) error { |
| - q, err := s.postDomainCheck(ctx, acct, name) |
| + q, err := s.postDomainCheck(ctx, acct, name, "") |
| if err != nil { |
| return err |
| } |
| @@ -102,7 +102,11 @@ func domainsBuy(ctx context.Context, s *apiSession, acct apiAcct, name, app stri |
| return err |
| } |
| } |
| - q, err := s.postDomainCheck(ctx, acct, name) |
| + country := "" |
| + if contact != nil { |
| + country = contact.Country |
| + } |
| + q, err := s.postDomainCheck(ctx, acct, name, country) |
| if err != nil { |
| return err |
| } |
diff --git a/domains_buy_cli_test.go b/domains_buy_cli_test.go| index d85e0225c..bd3ea55e2 100644 |
| --- a/domains_buy_cli_test.go |
| +++ b/domains_buy_cli_test.go |
| @@ -317,7 +317,7 @@ func TestDomainsBuyDoorErrors(t *testing.T) { |
| var err error |
| switch door { |
| case "check": |
| - _, err = s.postDomainCheck(context.Background(), apiAcct{Seg: "bab"}, "shop.com") |
| + _, err = s.postDomainCheck(context.Background(), apiAcct{Seg: "bab"}, "shop.com", "") |
| case "purchase": |
| _, err = s.postDomainPurchase(context.Background(), apiAcct{Seg: "bab"}, "shop.com", "shop", nil, domainQuoteResp{Currency: "eur", Price: 1299}) |
| case "status": |
| @@ -359,7 +359,7 @@ func TestDomainsBuyAPIExactAccountAndEscapedID(t *testing.T) { |
| var err error |
| switch door { |
| case "check": |
| - _, err = s.postDomainCheck(context.Background(), a, "shop.com") |
| + _, err = s.postDomainCheck(context.Background(), a, "shop.com", "") |
| case "purchase": |
| _, err = s.postDomainPurchase(context.Background(), a, "shop.com", "shop", nil, domainQuoteResp{Currency: "eur", Price: 1299}) |
| case "status": |
| @@ -540,3 +540,61 @@ func TestDomainsBuyChangedPriceAfterContact(t *testing.T) { |
| t.Fatalf("calls=%d err=%v output=%s", calls, err, &out) |
| } |
| } |
| + |
| +func TestDomainsBuyContactFileCountryWithYes(t *testing.T) { |
| + for _, country := range []string{"IE", "GB"} { |
| + t.Run(country, func(t *testing.T) { |
| + currency := "eur" |
| + if country == "GB" { |
| + currency = "gbp" |
| + } |
| + checks, purchases := 0, 0 |
| + mux := http.NewServeMux() |
| + mux.HandleFunc("POST "+buyTestPath+"/check", func(w http.ResponseWriter, r *http.Request) { |
| + checks++ |
| + var in struct{ Name, Country string } |
| + if err := json.NewDecoder(r.Body).Decode(&in); err != nil { |
| + t.Error(err) |
| + } |
| + quoted := "usd" |
| + if in.Country == country { |
| + quoted = currency |
| + } |
| + json.NewEncoder(w).Encode(map[string]any{"domain": "shop.com", "available": true, "currency": quoted, "price": 1600}) |
| + }) |
| + mux.HandleFunc("POST "+buyTestPath+"/purchases", func(w http.ResponseWriter, r *http.Request) { |
| + purchases++ |
| + var in struct { |
| + Currency string |
| + Price int64 |
| + Contact struct{ Country string } |
| + } |
| + if err := json.NewDecoder(r.Body).Decode(&in); err != nil { |
| + t.Error(err) |
| + } |
| + if in.Currency != currency || in.Price != 1600 || in.Contact.Country != country { |
| + w.WriteHeader(http.StatusConflict) |
| + json.NewEncoder(w).Encode(map[string]any{"error": "price differs", "code": "price_changed", "domain": "shop.com", "available": true, "currency": currency, "price": 1600}) |
| + return |
| + } |
| + fmt.Fprint(w, `{"id":"p1","checkout_url":"https://checkout.example/p1","state":"awaiting_payment"}`) |
| + }) |
| + mux.HandleFunc("GET "+buyTestPath+"/purchases/p1", func(w http.ResponseWriter, r *http.Request) { |
| + fmt.Fprint(w, `{"id":"p1","state":"done","domain_state":"live"}`) |
| + }) |
| + ts := httptest.NewServer(mux) |
| + defer ts.Close() |
| + contactFile := filepath.Join(t.TempDir(), "contact.json") |
| + if err := os.WriteFile(contactFile, []byte(fmt.Sprintf(`{"first_name":"Jane","last_name":"Buyer","email":"buyer@example.test","phone_country_code":"353","phone":"871234567","street":"Main Street","city":"Dublin","postal_code":"D01 A123","country":%q}`, country)), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + out, err := runBuyTestCommand(t, ts.URL, "--contact-file", contactFile) |
| + if err != nil { |
| + t.Fatalf("first purchase --yes: %v\n%s", err, out) |
| + } |
| + if checks != 1 || purchases != 1 || !strings.Contains(out, strings.ToUpper(currency)) || !strings.Contains(out, "live") { |
| + t.Fatalf("checks=%d purchases=%d output=%s", checks, purchases, out) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/domains_buy_copy.go b/domains_buy_copy.go| index 7c8a2679a..a1b310ddd 100644 |
| --- a/domains_buy_copy.go |
| +++ b/domains_buy_copy.go |
| @@ -9,7 +9,7 @@ const domainsCheckUsage = "usage: carlos domains check <name> [--account <a>] [- |
| const domainsBuyUsage = "usage: carlos domains buy <name> --app <a> [--contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n" |
| var domainsBuyCopy = map[string]string{ |
| - // Draft for the Luna pass: round 1 price-change confirmation. |
| + // Approved by delegation (reviewer), 2026-11-03. |
| "confirmChanged": "buy this domain at the new price? [y/N] ", |
| // Draft for the Luna pass: domain registration Plan 2, slice 1. |
| "purchaseID": "purchase: %s\n", |
diff --git a/internal/console/apidomainbuy.go b/internal/console/apidomainbuy.go| index c18716230..ecbaff283 100644 |
| --- a/internal/console/apidomainbuy.go |
| +++ b/internal/console/apidomainbuy.go |
| @@ -35,12 +35,18 @@ func (s *Server) domainBuyAPIGate(w http.ResponseWriter, r *http.Request) (strin |
| return addr, acct, true |
| } |
| -func (s *Server) checkDomainBuy(ctx context.Context, acct *Account, name string) (domainreg.Quote, *doorRefusal) { |
| - c, _, err := s.store.DomainContact(acct.ID) |
| - if err != nil { |
| - return domainreg.Quote{}, domainBuyUnavailable() |
| +func (s *Server) checkDomainBuy(ctx context.Context, acct *Account, name, country string) (domainreg.Quote, *doorRefusal) { |
| + if country != "" && (len(country) != 2 || country[0] < 'A' || country[0] > 'Z' || country[1] < 'A' || country[1] > 'Z') { |
| + return domainreg.Quote{}, &doorRefusal{http.StatusUnprocessableEntity, domainBuyCopy["contactError"]} |
| + } |
| + if country == "" { |
| + c, _, err := s.store.DomainContact(acct.ID) |
| + if err != nil { |
| + return domainreg.Quote{}, domainBuyUnavailable() |
| + } |
| + country = c.Country |
| } |
| - return s.admitDomainBuy(ctx, acct, name, c.Country) |
| + return s.admitDomainBuy(ctx, acct, name, country) |
| } |
| func (s *Server) liveDomainPurchaseRefusal(ctx context.Context, name string) *doorRefusal { |
| @@ -60,14 +66,15 @@ func (s *Server) handleAPIDomainCheck(w http.ResponseWriter, r *http.Request) { |
| return |
| } |
| var in struct { |
| - Name string `json:"name"` |
| + Name string `json:"name"` |
| + Country string `json:"country"` |
| } |
| if !readJSONStrictLimit(w, r, &in, 8<<10) { |
| return |
| } |
| ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second) |
| defer cancel() |
| - q, ref := s.checkDomainBuy(ctx, acct, in.Name) |
| + q, ref := s.checkDomainBuy(ctx, acct, in.Name, in.Country) |
| if ref != nil { |
| writeDoorRefusalJSON(w, r, ref) |
| return |
diff --git a/internal/console/appdomainbuy.go b/internal/console/appdomainbuy.go| index 1e4e63ce6..1eb02dedb 100644 |
| --- a/internal/console/appdomainbuy.go |
| +++ b/internal/console/appdomainbuy.go |
| @@ -92,7 +92,7 @@ func (s *Server) handleAppDomainBuyCheck(w http.ResponseWriter, r *http.Request) |
| } |
| ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second) |
| defer cancel() |
| - q, ref := s.checkDomainBuy(ctx, acct, r.FormValue("name")) |
| + q, ref := s.checkDomainBuy(ctx, acct, r.FormValue("name"), r.FormValue("country")) |
| if ref != nil { |
| s.renderDoorRefusal(w, r, ref) |
| return |
| @@ -102,6 +102,9 @@ func (s *Server) handleAppDomainBuyCheck(w http.ResponseWriter, r *http.Request) |
| s.renderDoorRefusal(w, r, domainBuyUnavailable()) |
| return |
| } |
| + if country := r.FormValue("country"); country != "" { |
| + c.Country = country |
| + } |
| s.renderDomainBuy(w, r, addr, raw, acct, app, &domainBuyView{Quote: &q, Fields: buyContactFields(c)}) |
| } |
| func (s *Server) handleAppDomainBuy(w http.ResponseWriter, r *http.Request) { |
diff --git a/internal/console/billingcard.go b/internal/console/billingcard.go| index 4c404d306..7c8ea9bf7 100644 |
| --- a/internal/console/billingcard.go |
| +++ b/internal/console/billingcard.go |
| @@ -20,7 +20,7 @@ func (s *Server) handleBillingCard(w http.ResponseWriter, r *http.Request) { |
| return |
| } |
| back := billingPagePath(acct.Sqid) |
| - if !s.billing.ready.Load() { |
| + if !s.domainBuyReady() || s.checkCustomDomains(acct) != nil { |
| s.setFlash(w, "err", billingCopy["card.failed"]) |
| http.Redirect(w, r, back, http.StatusSeeOther) |
| return |
diff --git a/internal/console/billingcard_test.go b/internal/console/billingcard_test.go| index cf7cf9291..439044646 100644 |
| --- a/internal/console/billingcard_test.go |
| +++ b/internal/console/billingcard_test.go |
| @@ -71,6 +71,7 @@ func TestBillingAddCardWithoutCustomer(t *testing.T) { |
| func TestBillingAddCardGates(t *testing.T) { |
| o := newCheckoutFixture(t, false) |
| + enableCardBuying(t, o) |
| if err := o.st.AddMember(o.acct.ID, "kim@keymail.dev", RoleMember, time.Now()); err != nil { |
| t.Fatal(err) |
| } |
| @@ -96,6 +97,7 @@ func TestBillingAddCardGates(t *testing.T) { |
| func TestBillingAddCardNoProviderTimeSendsNothing(t *testing.T) { |
| o := newCheckoutFixture(t, true) |
| + enableCardBuying(t, o) |
| o.stepUp(t) |
| o.reset() |
| o.fake.ProbeErr = billing.ErrNoResponse |
| @@ -107,3 +109,14 @@ func TestBillingAddCardNoProviderTimeSendsNothing(t *testing.T) { |
| t.Fatal("setup sent without provider time") |
| } |
| } |
| + |
| +func enableCardBuying(t *testing.T, o *opsFixture) { |
| + t.Helper() |
| + o.srv.cfg.Registrar = registrartest.New() |
| + o.srv.cfg.ZoneHost = zonehosttest.New("ns1.example.test") |
| + o.srv.cfg.DomainCatalog = &domainreg.Catalog{DailyCap: 3} |
| + sponsored := sponsorUnlimited() |
| + if _, err := o.st.SetAccountPlan(o.acct.ID, "free", nil, 0, PlanSourceSponsored, &sponsored, "test", "operator", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
diff --git a/internal/console/domainbuy_copy.go b/internal/console/domainbuy_copy.go| index ebd2e7286..446186a02 100644 |
| --- a/internal/console/domainbuy_copy.go |
| +++ b/internal/console/domainbuy_copy.go |
| @@ -15,8 +15,8 @@ import ( |
| // 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{ |
| - // Draft for the Luna pass: round 1 confirmed-price refusal. |
| - "priceChanged": "the price changed. confirm the new price to continue", |
| + // Approved by delegation (reviewer), 2026-11-03. |
| + "priceChanged": "the price is different from the one you confirmed. confirm the new price to continue", |
| "plan": capMessage("cli.cap.custom_domain"), // Existing approved plan refusal. |
| // Approved by delegation (Luna), 2026-11-03: domain registration Plan 2, slice 1. |
| "billingSetup": "we could not set up billing for your account. try again later", |
diff --git a/internal/console/domainbuy_fix_test.go b/internal/console/domainbuy_fix_test.go| index cc5207f2f..c7001b533 100644 |
| --- a/internal/console/domainbuy_fix_test.go |
| +++ b/internal/console/domainbuy_fix_test.go |
| @@ -232,7 +232,7 @@ func TestCheckLimiterPerAccountAndDeployment(t *testing.T) { |
| t.Fatal(err) |
| } |
| for j := 0; j < 20; j++ { |
| - _, ref := f.srv.checkDomainBuy(context.Background(), acct, "shop.com") |
| + _, ref := f.srv.checkDomainBuy(context.Background(), acct, "shop.com", "") |
| if i < 5 && ref != nil { |
| t.Fatalf("deployment %d/%d: %+v", i, j, ref) |
| } |
diff --git a/internal/console/domainbuy_round2_test.go b/internal/console/domainbuy_round2_test.go| new file mode 100644 |
| index 000000000..4cb21af52 |
| --- /dev/null |
| +++ b/internal/console/domainbuy_round2_test.go |
| @@ -0,0 +1,173 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "net/http" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/billing" |
| +) |
| + |
| +func TestPurchaseCheckCountry(t *testing.T) { |
| + for _, browser := range []bool{false, true} { |
| + for _, tc := range []struct { |
| + name, country, saved, fixed, currency string |
| + price int64 |
| + }{ |
| + {"first IE", "IE", "", "", "eur", 1600}, |
| + {"first GB", "GB", "", "", "gbp", 1700}, |
| + {"overrides saved", "GB", "IE", "", "gbp", 1700}, |
| + {"fixed currency wins", "IE", "GB", "usd", "usd", 1500}, |
| + {"saved fallback", "", "IE", "", "eur", 1600}, |
| + {"default fallback", "", "", "", "usd", 1500}, |
| + } { |
| + t.Run(fmt.Sprintf("browser=%t/%s", browser, tc.name), func(t *testing.T) { |
| + f := newPurchaseFixture(t) |
| + firstPurchaseAccount(t, f) |
| + if tc.saved != "" { |
| + c := purchaseContact() |
| + c.Country = tc.saved |
| + if err := f.st.SetDomainContact(f.acct.ID, c, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if tc.fixed != "" { |
| + if err := f.st.SetBillingCustomer(f.acct.ID, "cus_fixed", time.Now(), tc.fixed); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + if browser { |
| + c := newBrowser(t) |
| + f.setUser("owner" + f.acct.Sqid + "@example.com") |
| + signUp(t, f.consoleFixture, c, "country-browser") |
| + status, _, body := postForm(t, c, f.ts.URL+"/a/"+f.acct.Sqid+"/apps/kass/domains/check", url.Values{"csrf": {sessionToken(t, f.consoleFixture, c)}, "name": {"shop.com"}, "country": {tc.country}}) |
| + if status != 200 || !strings.Contains(body, `name="currency" value="`+tc.currency+`"`) || !strings.Contains(body, fmt.Sprintf(`name="price" value="%d"`, tc.price)) { |
| + t.Fatalf("check: %d %s", status, body) |
| + } |
| + if tc.country != "" && !strings.Contains(body, `name="Country" value="`+tc.country+`"`) { |
| + t.Fatal("confirmation contact lost requested country") |
| + } |
| + } else { |
| + status, body := buyRequest(t, f, "POST", buyAPIPath(f)+"/check", buyToken(t, f), fmt.Sprintf(`{"name":"shop.com","country":%q}`, tc.country)) |
| + var q struct { |
| + Currency string |
| + Price int64 |
| + } |
| + if err := json.Unmarshal([]byte(body), &q); err != nil { |
| + t.Fatal(err) |
| + } |
| + if status != 200 || q.Currency != tc.currency || q.Price != tc.price { |
| + t.Fatalf("check: %d %s", status, body) |
| + } |
| + } |
| + if tc.fixed == "" { |
| + assertNoPurchaseEffects(t, f) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func TestPurchaseCheckCountryValidation(t *testing.T) { |
| + for _, country := range []string{"ie", "I", "IRL", "I1", " IE", "ÉI"} { |
| + t.Run(country, func(t *testing.T) { |
| + f := newPurchaseFixture(t) |
| + firstPurchaseAccount(t, f) |
| + status, body := buyRequest(t, f, "POST", buyAPIPath(f)+"/check", buyToken(t, f), fmt.Sprintf(`{"name":"shop.com","country":%q}`, country)) |
| + if status != 422 || !strings.Contains(body, domainBuyCopy["contactError"]) { |
| + t.Fatalf("API: %d %s", status, body) |
| + } |
| + c := newBrowser(t) |
| + f.setUser("owner" + f.acct.Sqid + "@example.com") |
| + signUp(t, f.consoleFixture, c, "invalid-country") |
| + status, _, body = postForm(t, c, f.ts.URL+"/a/"+f.acct.Sqid+"/apps/kass/domains/check", url.Values{"csrf": {sessionToken(t, f.consoleFixture, c)}, "name": {"shop.com"}, "country": {country}}) |
| + if status != 422 || !strings.Contains(body, domainBuyCopy["contactError"]) { |
| + t.Fatalf("browser: %d %s", status, body) |
| + } |
| + assertNoPurchaseEffects(t, f) |
| + if len(f.reg.Calls) != 0 { |
| + t.Fatalf("invalid country reached registrar: %v", f.reg.Calls) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestPurchaseCheckCountryChargedEUR(t *testing.T) { |
| + f := newPurchaseFixture(t) |
| + firstPurchaseAccount(t, f) |
| + tok := buyToken(t, f) |
| + status, body := buyRequest(t, f, "POST", buyAPIPath(f)+"/check", tok, `{"name":"shop.com","country":"IE"}`) |
| + var q struct { |
| + Currency string |
| + Price int64 |
| + } |
| + if err := json.Unmarshal([]byte(body), &q); err != nil { |
| + t.Fatal(err) |
| + } |
| + if status != 200 || q.Currency != "eur" || q.Price != 1600 { |
| + t.Fatalf("check: %d %s", status, body) |
| + } |
| + request, _ := json.Marshal(map[string]any{"name": "shop.com", "app": "kass", "contact": purchaseContact(), "currency": q.Currency, "price": q.Price}) |
| + status, body = buyRequest(t, f, "POST", buyAPIPath(f)+"/purchases", tok, string(request)) |
| + if status != 200 { |
| + t.Fatalf("first purchase: %d %s", status, body) |
| + } |
| + var out struct{ ID string } |
| + if err := json.Unmarshal([]byte(body), &out); err != nil { |
| + t.Fatal(err) |
| + } |
| + p := f.read(t, out.ID) |
| + f.authorise(t, p) |
| + p = f.until(t, p.ID, PurchaseCaptured) |
| + payment, err := f.fake.PaymentCheckout(context.Background(), p.CheckoutSession) |
| + if err != nil || payment.IntentStatus != "succeeded" || p.Currency != "eur" || p.Amount != 1600 || f.sent(billing.PreparedCapture) != 1 { |
| + t.Fatalf("capture: %+v %+v %v", p, payment, err) |
| + } |
| + var prepared struct { |
| + Request billing.PaymentCheckoutRequest |
| + } |
| + if err := json.Unmarshal(p.CheckoutPrepared.Body, &prepared); err != nil { |
| + t.Fatal(err) |
| + } |
| + if prepared.Request.Currency != "eur" || prepared.Request.Amount != 1600 { |
| + t.Fatalf("charged: %+v", prepared.Request) |
| + } |
| +} |
| + |
| +func TestBillingAddCardUnavailableAction(t *testing.T) { |
| + for _, reason := range []string{"not configured", "plan disallows", "exempt"} { |
| + t.Run(reason, func(t *testing.T) { |
| + o := newCheckoutFixture(t, false) |
| + if reason != "not configured" { |
| + f := newPurchaseFixture(t) |
| + o.srv.cfg.Registrar, o.srv.cfg.ZoneHost, o.srv.cfg.DomainCatalog = f.reg, f.zone, f.srv.cfg.DomainCatalog |
| + } |
| + if reason == "exempt" { |
| + o.st.planExemptID = o.acct.ID |
| + } |
| + o.stepUp(t) |
| + o.reset() |
| + in, err := o.srv.billingPageInputFor(o.acct, RoleOwner, time.Now()) |
| + if err != nil || in.CanBuyDomains { |
| + t.Fatalf("fixture: %+v %v", in, err) |
| + } |
| + r := o.request(t, http.MethodPost, o.billingBase()+"/card", nil) |
| + key := "card.failed" |
| + if reason == "exempt" { |
| + key = errBillingExempt.Key |
| + } |
| + o.wantRefused(t, r, billingCopy[key]) |
| + if b, err := o.st.BillingAccount(o.acct.ID); err != nil || b != nil { |
| + t.Fatalf("gate wrote billing: %+v %v", b, err) |
| + } |
| + if len(o.fake.Sent) != 0 { |
| + t.Fatal("gate sent provider writes") |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/console/templates/domain_buy.html b/internal/console/templates/domain_buy.html| index 0831c6295..0a96b85bb 100644 |
| --- a/internal/console/templates/domain_buy.html |
| +++ b/internal/console/templates/domain_buy.html |
| @@ -52,6 +52,8 @@ |
| <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| <label for="buy-name">{{$.DomainBuyCopy.name}}</label> |
| <input id="buy-name" name="name" required> |
| + <label for="buy-country">{{$.DomainBuyCopy.Country}}</label> |
| + <input id="buy-country" name="country" maxlength="2" pattern="[A-Z]{2}"> |
| <button type="submit">{{$.DomainBuyCopy.check}}</button> |
| </form> |
| {{end}} |
diff --git a/internal/provision/testdata/plan14-root-reads-domains-buy-nosub.tsv b/internal/provision/testdata/plan14-root-reads-domains-buy-nosub.tsv| index 08dea4404..0dddd7750 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-domains-buy-nosub.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-domains-buy-nosub.tsv |
| @@ -1,4 +1,4 @@ |
| # Census overlay domains-buy-nosub, written by census-propose (#369). census-ruling-domains-buy-nosub, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-domains-buy-nosub.md. |
| # 0 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -@coverage . 0b36c7aecfa58a4d48d41a08d38167f0ac8417f966432828463faeb85b4b804f |
| +@coverage . ecf8cb88c9cc640b8b95fe71ed448c962ba29b86ca483910ee7f5448bfd5af26 |
| @coverage internal/registrar 438f7149d09aa6a151338c68bfe428f704a09628f56e942b8fd4de8cebadd932 |