1
0
binwiederhier 8 сар өмнө
parent
commit
5ccc131e73

+ 1 - 1
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)

+ 5 - 1
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")

+ 41 - 0
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
+}

+ 2 - 0
server/server_payments_test.go

@@ -1,3 +1,5 @@
+//go:build !nopayments
+
 package server
 
 import (

+ 1 - 0
stripe/types.go

@@ -0,0 +1 @@
+package stripe