@@ -24,6 +24,7 @@ import ( |
| 24 | "github.com/tenseleyFlow/shithub/internal/auth/secretbox" | 24 | "github.com/tenseleyFlow/shithub/internal/auth/secretbox" |
| 25 | "github.com/tenseleyFlow/shithub/internal/auth/session" | 25 | "github.com/tenseleyFlow/shithub/internal/auth/session" |
| 26 | "github.com/tenseleyFlow/shithub/internal/auth/throttle" | 26 | "github.com/tenseleyFlow/shithub/internal/auth/throttle" |
| | 27 | + "github.com/tenseleyFlow/shithub/internal/billing/stripebilling" |
| 27 | "github.com/tenseleyFlow/shithub/internal/infra/config" | 28 | "github.com/tenseleyFlow/shithub/internal/infra/config" |
| 28 | "github.com/tenseleyFlow/shithub/internal/infra/storage" | 29 | "github.com/tenseleyFlow/shithub/internal/infra/storage" |
| 29 | "github.com/tenseleyFlow/shithub/internal/ratelimit" | 30 | "github.com/tenseleyFlow/shithub/internal/ratelimit" |
@@ -162,6 +163,20 @@ func buildAuthHandlers( |
| 162 | logger.Warn("auth: no totp_key_b64 configured; 2FA enrollment routes disabled", | 163 | logger.Warn("auth: no totp_key_b64 configured; 2FA enrollment routes disabled", |
| 163 | "hint", "set SHITHUB_TOTP_KEY=$(openssl rand -base64 32) to enable 2FA") | 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 | return authh.New(authh.Deps{ | 180 | return authh.New(authh.Deps{ |
| 166 | Logger: logger, | 181 | Logger: logger, |
| 167 | Render: rr, | 182 | Render: rr, |
@@ -187,6 +202,13 @@ func buildAuthHandlers( |
| 187 | Audit: audit.NewRecorder(), | 202 | Audit: audit.NewRecorder(), |
| 188 | ObjectStore: objectStore, | 203 | ObjectStore: objectStore, |
| 189 | OrgBillingEnabled: cfg.Billing.Enabled, | 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 | |