Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix the hard coded store api url in billing (#65135)

Nemanja Glumac215a3c6c49b3
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.edn
index b305e20df38..bb8248ef931 100644
--- a/.clj-kondo/config/modules/config.edn
+++ b/.clj-kondo/config/modules/config.edn
@@ -1621,7 +1621,9 @@
{:team "UX West"
:api #{metabase-enterprise.billing.api.routes}
:uses #{api
- premium-features util}}
+ premium-features
+ store-api
+ util}}
enterprise/bookmarks
{:team "UX West"
diff --git a/enterprise/backend/src/metabase_enterprise/billing/api.clj b/enterprise/backend/src/metabase_enterprise/billing/api.clj
index f596cb4d49e..4829e698354 100644
--- a/enterprise/backend/src/metabase_enterprise/billing/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/billing/api.clj
@@ -8,6 +8,7 @@
[metabase.api.common :as api]
[metabase.api.macros :as api.macros]
[metabase.premium-features.core :as premium-features]
+ [metabase.store-api.core :as store-api]
[metabase.util :as u]
[metabase.util.date-2.parse :as u.date.parse]
[metabase.util.i18n :as i18n]
@@ -18,13 +19,16 @@
(set! *warn-on-reflection* true)
-(def ^:private ^String metabase-billing-info-url "https://store-api.metabase.com/api/v2/metabase/billing_info")
+(defn- metabase-billing-info-url
+ "Returns the Store URL for fetching billing info for the current Metabase instance."
+ ^String []
+ (str (store-api/store-api-url) "/api/v2/metabase/billing_info"))
(def ^:private ^{:arglists '([token email language])} fetch-billing-status*
(memoize/ttl
^{::memoize/args-fn (fn [[token email language]] [token email language])}
(fn [token email language]
- (try (some-> metabase-billing-info-url
+ (try (some-> (metabase-billing-info-url)
(http/get {:basic-auth [email token]
:language language
:content-type :json})