summaryrefslogtreecommitdiff
path: root/cmd/stripe-preflight
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-06 15:58:57 +1200
committerChia <Chia@93.nz>2026-08-06 15:58:57 +1200
commit3f702084d20b3c3a3ea916f3110e99b22bda60b3 (patch)
tree517f76c51025ce1ee085ea4898c60f799e5c37ea /cmd/stripe-preflight
parent41e322c53d7b4b796eb377d0df9c29ecd10ba431 (diff)
feat: complete commercial developer workflowspublish-commercial-control-plane
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.
Diffstat (limited to '')
-rw-r--r--cmd/stripe-preflight/main.go34
1 files changed, 34 insertions, 0 deletions
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)
+ }
+}