From 3f702084d20b3c3a3ea916f3110e99b22bda60b3 Mon Sep 17 00:00:00 2001 From: Chia Date: Thu, 6 Aug 2026 15:58:57 +1200 Subject: feat: complete commercial developer workflows Add tenant-safe usage observability, prepaid billing controls, API key lifecycle management, Embeddings metering, configurable billing alerts, and resilient provider health propagation. Harden Stripe failure handling, migrations, readiness, and the authenticated control-plane UI with end-to-end verification evidence. --- cmd/stripe-preflight/main.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 cmd/stripe-preflight/main.go (limited to 'cmd/stripe-preflight/main.go') diff --git a/cmd/stripe-preflight/main.go b/cmd/stripe-preflight/main.go new file mode 100644 index 0000000..3a0f2d8 --- /dev/null +++ b/cmd/stripe-preflight/main.go @@ -0,0 +1,34 @@ +package main + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "os" + "time" + + "aigw/internal/billing" +) + +func main() { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + result, err := billing.CheckStripePermissions(ctx, os.Getenv("AIGW_STRIPE_API_KEY")) + if encodeErr := json.NewEncoder(os.Stdout).Encode(result); encodeErr != nil { + fmt.Fprintln(os.Stderr, "encode Stripe preflight result") + os.Exit(1) + } + if err != nil { + if errors.Is(err, billing.ErrLiveStripeKey) { + fmt.Fprintln(os.Stderr, "Stripe preflight requires an rk_test_ or sk_test_ key; live keys are refused") + } else { + fmt.Fprintln(os.Stderr, "Stripe preflight failed") + } + os.Exit(1) + } + if !result.Ready { + fmt.Fprintln(os.Stderr, "Stripe restricted key is missing one or more required read permissions") + os.Exit(1) + } +} -- cgit v1.2.3