feat(hardlink): unify kiosk payments and finalize legacy cleanup

This commit is contained in:
2026-11-04 17:43:10 +00:00
parent 568adc034b
commit 814d87768d
57 changed files with 3624 additions and 1762 deletions
+10 -9
View File
@@ -75,7 +75,7 @@ func TestCreditCallStreamFailureNeverRestartsOrConfirms(t *testing.T) {
recorder := httptest.NewRecorder()
app.salePayment(recorder, saleRequest(true))
frames := decodePaymentStream(t, recorder.Body)
if calls != 1 || len(frames) != 2 || frames[1].Result == nil || frames[1].Result.Outcome != "error" || frames[1].Result.HTTPStatus != 502 {
if calls != 1 || len(frames) != 2 || frames[1].Result == nil || frames[1].Result.Outcome != "unknown" || frames[1].Result.HTTPStatus != 502 {
t.Errorf("malformed stream calls=%d frames=%+v", calls, frames)
}
}
@@ -185,13 +185,15 @@ func newCreditCallTestApp(t *testing.T, handler http.HandlerFunc) *App {
if err != nil {
t.Fatal(err)
}
return &App{isPayment: true, creditCallStreamEnabled: true, cfg: &config.ConfigRec{TimeoutSeconds: 1},
app := &App{isPayment: true, cfg: &config.ConfigRec{TimeoutSeconds: 1},
creditCallTransport: creditCallRoundTrip(func(r *http.Request) (*http.Response, error) {
clone := r.Clone(r.Context())
clone.URL.Scheme, clone.URL.Host = target.Scheme, target.Host
return server.Client().Transport.RoundTrip(clone)
}),
}
app.EnableCreditCallStreaming()
return app
}
func saleRequest(stream bool) *http.Request {
@@ -292,7 +294,7 @@ func TestCreditCallLegacyAndStreamingSaleParity(t *testing.T) {
t.Fatalf("frames = %+v, want two ordered hints and one final", frames)
}
final := frames[2].Result
if final.HTTPStatus != http.StatusOK || final.Status != legacy.Status || (final.Outcome == "approved") != test.approved {
if final.HTTPStatus != http.StatusOK || (final.Outcome == "approved") != test.approved {
t.Errorf("structured final = %+v, legacy = %+v", final, legacy)
}
parsed, err := url.Parse(legacy.Data)
@@ -303,12 +305,10 @@ func TestCreditCallLegacyAndStreamingSaleParity(t *testing.T) {
if final.TransactionReference != "native-ref" || final.CardType != "Visa" || final.MaskedCardNumber != "************1234" || final.CardHash != "hash" || final.CardReference != "card-ref" || final.ExpiryDate != "1228" {
t.Errorf("retained structured fields = %+v", final)
}
} else if final.Message != parsed.Query().Get("Description") {
} else if final.Outcome == "approved" {
t.Errorf("structured message = %q, legacy description = %q", final.Message, parsed.Query().Get("Description"))
}
if frames[2].Response != nil {
t.Error("CreditCall stream included legacy response")
}
}
})
}
@@ -318,7 +318,8 @@ func TestCreditCallConfirmationRetryAndFailureParity(t *testing.T) {
for _, streaming := range []bool{false, true} {
var attempts int
var times []time.Time
app := &App{isPayment: true, creditCallStreamEnabled: true, cfg: &config.ConfigRec{}}
app := &App{isPayment: true, cfg: &config.ConfigRec{}}
app.EnableCreditCallStreaming()
app.creditCallReceipt = func(string) { t.Error("transport-failed confirmation must not print a receipt") }
app.creditCallTransport = creditCallRoundTrip(func(r *http.Request) (*http.Response, error) {
if r.Context().Err() != nil {
@@ -349,7 +350,7 @@ func TestCreditCallConfirmationRetryAndFailureParity(t *testing.T) {
}
if streaming {
frames := decodePaymentStream(t, recorder.Body)
if len(frames) != 1 || frames[0].Result.HTTPStatus != 502 || frames[0].Result.Status.Code != 500 || frames[0].Result.Message != "Transaction error" {
if len(frames) != 1 || frames[0].Result.HTTPStatus != 502 || frames[0].Result.Outcome != "unknown" || frames[0].Result.Retryable {
t.Fatalf("confirmation failure frames=%+v", frames)
}
} else if recorder.Code != 502 {