carlos / platform Public

console: buy step 3 again shows the quote's refusal, not the contact's

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev d5fcfa105bc299f8f8f0240221fe443f2cf768b4 parent 99643e5
2 files changed, +19 −1
  • internal/console/accountdomainbuy.go +1 −1
  • internal/console/accountdomainbuy_test.go +18 −0
diff --git a/internal/console/accountdomainbuy.go b/internal/console/accountdomainbuy.go
index 33bb2b8a7..970632777 100644
--- a/internal/console/accountdomainbuy.go
+++ b/internal/console/accountdomainbuy.go
@@ -418,7 +418,7 @@ func (s *Server) buyPayAgain(w http.ResponseWriter, r *http.Request, addr, raw s
} else {
var qref *doorRefusal
if q, qref = s.buyStepQuote(ctx, acct, r.FormValue("name"), country); qref != nil {
- s.renderDoorRefusal(w, r, ref)
+ s.renderDoorRefusal(w, r, qref)
return
}
}
diff --git a/internal/console/accountdomainbuy_test.go b/internal/console/accountdomainbuy_test.go
index b70daa5da..3900d8802 100644
--- a/internal/console/accountdomainbuy_test.go
+++ b/internal/console/accountdomainbuy_test.go
@@ -3,7 +3,9 @@ package console
import (
"context"
"encoding/json"
+ "html"
"net/http"
+ "net/http/httptest"
"net/url"
"strings"
"testing"
@@ -570,3 +572,19 @@ func (f *purchaseFixture) browserQuote(t *testing.T, c *http.Client, values url.
status, _, body = get(t, c, f.ts.URL+loc)
return status, body
}
+
+// TestBuyPayAgainShowsQuoteRefusal: when step 3 comes back with a contact
+// to correct but the name can no longer be quoted, the page shows the
+// quote's refusal, not the contact error it was asked to show.
+func TestBuyPayAgainShowsQuoteRefusal(t *testing.T) {
+ f := newPurchaseFixture(t)
+ contactRef := &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
+ r := httptest.NewRequest(http.MethodPost, "/a/"+f.acct.Sqid+"/domains/buy", strings.NewReader(url.Values{"name": {"shop.zzz"}}.Encode()))
+ r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+ w := httptest.NewRecorder()
+ f.srv.buyPayAgain(w, r, pointOwner(f), "", f.acct, nil, contactRef, "kass", "", "new", &registrar.Contact{})
+ body := w.Body.String()
+ if !strings.Contains(body, html.EscapeString(domainBuyCopy["notOffered"])) || strings.Contains(body, html.EscapeString(domainBuyCopy["contactError"])) {
+ t.Fatalf("status %d, want the quote's refusal %q:\n%s", w.Code, domainBuyCopy["notOffered"], body)
+ }
+}