tenseleyflow/shithub / 25b797f

Browse files

web/orgs: wire ProPriceID + expose BillingPriceIDs to webhook handler

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
25b797f2705d0484167210ab171bf33920fc215c
Parents
ab57979
Tree
b9230df

2 changed files

StatusFile+-
M internal/web/handlers/orgs/orgs.go 13 0
M internal/web/orgs_wiring.go 3 0
internal/web/handlers/orgs/orgs.gomodified
@@ -68,6 +68,19 @@ type Deps struct {
6868
 	StripeSuccessURL      string
6969
 	StripeCancelURL       string
7070
 	StripePortalReturnURL string
71
+	// PRO04: price IDs surface to the webhook handler for cross-kind
72
+	// misroute guarding. Wiring populates these from the same config
73
+	// that constructs the Stripe client; either may be empty when the
74
+	// operator has enabled only one tier.
75
+	StripeTeamPriceID string
76
+	StripeProPriceID  string
77
+}
78
+
79
+// BillingPriceIDs returns the configured (team, pro) Stripe price
80
+// IDs. The webhook handler uses these to refuse cross-kind
81
+// misroutes (Pro price on an org subject or Team on a user).
82
+func (d Deps) BillingPriceIDs() (team, pro string) {
83
+	return d.StripeTeamPriceID, d.StripeProPriceID
7184
 }
7285
 
7386
 // Handlers groups the org surface handlers.
internal/web/orgs_wiring.gomodified
@@ -41,6 +41,7 @@ func buildOrgHandlers(
4141
 			SecretKey:     cfg.Billing.Stripe.SecretKey,
4242
 			WebhookSecret: cfg.Billing.Stripe.WebhookSecret,
4343
 			TeamPriceID:   cfg.Billing.Stripe.TeamPriceID,
44
+			ProPriceID:    cfg.Billing.Stripe.ProPriceID,
4445
 			AutomaticTax:  cfg.Billing.Stripe.AutomaticTax,
4546
 		})
4647
 		if err != nil {
@@ -76,6 +77,8 @@ func buildOrgHandlers(
7677
 		StripeSuccessURL:      cfg.Billing.Stripe.SuccessURL,
7778
 		StripeCancelURL:       cfg.Billing.Stripe.CancelURL,
7879
 		StripePortalReturnURL: cfg.Billing.Stripe.PortalReturnURL,
80
+		StripeTeamPriceID:     cfg.Billing.Stripe.TeamPriceID,
81
+		StripeProPriceID:      cfg.Billing.Stripe.ProPriceID,
7982
 	})
8083
 }
8184