@@ -24,6 +24,7 @@ import ( |
| 24 | 24 | "github.com/tenseleyFlow/shithub/internal/auth/secretbox" |
| 25 | 25 | "github.com/tenseleyFlow/shithub/internal/auth/session" |
| 26 | 26 | "github.com/tenseleyFlow/shithub/internal/auth/throttle" |
| 27 | + "github.com/tenseleyFlow/shithub/internal/billing/stripebilling" |
| 27 | 28 | "github.com/tenseleyFlow/shithub/internal/infra/config" |
| 28 | 29 | "github.com/tenseleyFlow/shithub/internal/infra/storage" |
| 29 | 30 | "github.com/tenseleyFlow/shithub/internal/ratelimit" |
@@ -162,6 +163,20 @@ func buildAuthHandlers( |
| 162 | 163 | logger.Warn("auth: no totp_key_b64 configured; 2FA enrollment routes disabled", |
| 163 | 164 | "hint", "set SHITHUB_TOTP_KEY=$(openssl rand -base64 32) to enable 2FA") |
| 164 | 165 | } |
| 166 | + var stripeRemote stripebilling.Remote |
| 167 | + if cfg.Billing.Enabled { |
| 168 | + remote, err := stripebilling.New(stripebilling.Config{ |
| 169 | + SecretKey: cfg.Billing.Stripe.SecretKey, |
| 170 | + WebhookSecret: cfg.Billing.Stripe.WebhookSecret, |
| 171 | + TeamPriceID: cfg.Billing.Stripe.TeamPriceID, |
| 172 | + ProPriceID: cfg.Billing.Stripe.ProPriceID, |
| 173 | + AutomaticTax: cfg.Billing.Stripe.AutomaticTax, |
| 174 | + }) |
| 175 | + if err != nil { |
| 176 | + return nil, err |
| 177 | + } |
| 178 | + stripeRemote = remote |
| 179 | + } |
| 165 | 180 | return authh.New(authh.Deps{ |
| 166 | 181 | Logger: logger, |
| 167 | 182 | Render: rr, |
@@ -187,6 +202,13 @@ func buildAuthHandlers( |
| 187 | 202 | Audit: audit.NewRecorder(), |
| 188 | 203 | ObjectStore: objectStore, |
| 189 | 204 | OrgBillingEnabled: cfg.Billing.Enabled, |
| 205 | + BillingEnabled: cfg.Billing.Enabled, |
| 206 | + BillingGracePeriod: cfg.Billing.GracePeriod, |
| 207 | + Stripe: stripeRemote, |
| 208 | + StripeSuccessURL: cfg.Billing.Stripe.SuccessURL, |
| 209 | + StripeCancelURL: cfg.Billing.Stripe.CancelURL, |
| 210 | + StripePortalReturnURL: cfg.Billing.Stripe.PortalReturnURL, |
| 211 | + BaseURL: cfg.Auth.BaseURL, |
| 190 | 212 | }) |
| 191 | 213 | } |
| 192 | 214 | |