From 5ccc131e73e80bc4295a375a8bd6a37928731257 Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Fri, 4 Jul 2025 06:41:14 +0200 Subject: [PATCH] Derp --- server/server.go | 2 +- server/server_payments.go | 6 ++++- server/server_payments_dummy.go | 41 +++++++++++++++++++++++++++++++++ server/server_payments_test.go | 2 ++ stripe/types.go | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 server/server_payments_dummy.go create mode 100644 stripe/types.go diff --git a/server/server.go b/server/server.go index e1126757..36fd25f2 100644 --- a/server/server.go +++ b/server/server.go @@ -158,7 +158,7 @@ func New(conf *Config) (*Server, error) { mailer = &smtpSender{config: conf} } var stripe stripeAPI - if conf.StripeSecretKey != "" { + if hasStripe && conf.StripeSecretKey != "" { stripe = newStripeAPI() } messageCache, err := createMessageCache(conf) diff --git a/server/server_payments.go b/server/server_payments.go index 334301bb..3c4b1fc6 100644 --- a/server/server_payments.go +++ b/server/server_payments.go @@ -1,3 +1,5 @@ +//go:build !nopayments + package server import ( @@ -22,7 +24,7 @@ import ( // Payments in ntfy are done via Stripe. // -// Pretty much all payments related things are in this file. The following processes +// Pretty much all payments-related things are in this file. The following processes // handle payments: // // - Checkout: @@ -42,6 +44,8 @@ import ( // This is used to keep the local user database fields up to date. Stripe is the source of truth. // What Stripe says is mirrored and not questioned. +const hasStripe = true + var ( errNotAPaidTier = errors.New("tier does not have billing price identifier") errMultipleBillingSubscriptions = errors.New("cannot have multiple billing subscriptions") diff --git a/server/server_payments_dummy.go b/server/server_payments_dummy.go new file mode 100644 index 00000000..3915453c --- /dev/null +++ b/server/server_payments_dummy.go @@ -0,0 +1,41 @@ +//go:build nopayments + +package server + +const hasStripe = false + +func (s *Server) handleBillingTiersGet(w http.ResponseWriter, _ *http.Request, _ *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingSubscriptionCreate(w http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingSubscriptionCreateSuccess(w http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingSubscriptionUpdate(w http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingSubscriptionDelete(w http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingPortalSessionCreate(w http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingWebhook(_ http.ResponseWriter, r *http.Request, v *visitor) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingWebhookSubscriptionUpdated(r *http.Request, v *visitor, event stripe.Event) error { + return errHTTPNotFound +} + +func (s *Server) handleAccountBillingWebhookSubscriptionDeleted(r *http.Request, v *visitor, event stripe.Event) error { + return errHTTPNotFound +} diff --git a/server/server_payments_test.go b/server/server_payments_test.go index 56d4cc6a..d72d2a6b 100644 --- a/server/server_payments_test.go +++ b/server/server_payments_test.go @@ -1,3 +1,5 @@ +//go:build !nopayments + package server import ( diff --git a/stripe/types.go b/stripe/types.go new file mode 100644 index 00000000..0e0d17df --- /dev/null +++ b/stripe/types.go @@ -0,0 +1 @@ +package stripe