Files
commerce/api/checkout/dumb_processor_test.go
d82ec00d3e checkout: Stripe hosts no checkout page; hosted checkout is a Square Payment Link (#47)
POST /v1/checkout/sessions created Stripe Checkout Sessions and Stripe Coupons when
routed to Stripe. Stripe is a processor of PaymentIntents only here (the intent flow
in api/billing); the page, the coupon and the line items belong to commerce. Nothing
reaches the hosted path: it is registered only in the standalone /v1 bundle, which
the co-resident embed skips, and no caller in pay, admin, cloud or the console posts
to it with this body. The Stripe branch, its coupon call and the Stripe processor in
the hosted registry are deleted; a providerHint of stripe is refused with 400.

Testing: go test ./api/checkout ./checkout; TestHostedCheckoutNeverCallsStripeBillingObjects
fails if api.stripe.com, Checkout Sessions, Coupons or the Stripe provider return to the package.
Risk: low; the path is unreachable in the embedded deployment and has no caller.
How to revert: git revert this commit.

Co-authored-by: Hanzo Dev <[email protected]>
2026-11-13 13:17:29 -08:00

30 lines
830 B
Go

package checkout
import (
"os"
"path/filepath"
"strings"
"testing"
)
// Stripe is a processor of PaymentIntents (api/billing), never a host of checkout
// pages, coupons or catalogs. This fails if a hosted-checkout path to Stripe's
// Checkout Sessions, Coupons, Prices or Products comes back into this package.
func TestHostedCheckoutNeverCallsStripeBillingObjects(t *testing.T) {
files, _ := filepath.Glob("*.go")
for _, f := range files {
if strings.HasSuffix(f, "_test.go") {
continue
}
b, err := os.ReadFile(f)
if err != nil {
t.Fatal(err)
}
for _, bad := range []string{"api.stripe.com", "checkout/sessions\",", "stripeprovider", "/v1/coupons"} {
if strings.Contains(string(b), bad) {
t.Errorf("%s reaches Stripe-hosted objects (%q); Stripe takes PaymentIntents only", f, bad)
}
}
}
}