DEV: continue to use subscribe_controller instead of introducting a new controller
This commit is contained in:
parent
bf7079928e
commit
ce988c9512
|
@ -1,9 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module StripeDiscourseSubscriptions
|
|
||||||
class PricingtableController < ::ApplicationController
|
|
||||||
def index
|
|
||||||
head 200
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -11,20 +11,7 @@ module DiscourseSubscriptions
|
||||||
requires_login except: %i[index contributors show]
|
requires_login except: %i[index contributors show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
begin
|
head 200
|
||||||
product_ids = Product.all.pluck(:external_id)
|
|
||||||
products = []
|
|
||||||
|
|
||||||
if product_ids.present? && is_stripe_configured?
|
|
||||||
response = ::Stripe::Product.list({ ids: product_ids, active: true })
|
|
||||||
|
|
||||||
products = response[:data].map { |p| serialize_product(p) }
|
|
||||||
end
|
|
||||||
|
|
||||||
render_json_dump products
|
|
||||||
rescue ::Stripe::InvalidRequestError => e
|
|
||||||
render_json_error e.message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def contributors
|
def contributors
|
||||||
|
|
|
@ -58,12 +58,14 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentUser && this.showContributors) {
|
if (this.currentUser && this.showContributors) {
|
||||||
return ajax("/s/contributors", { method: "get" }).then((result) => {
|
return ajax("/subscriptions/contributors", { method: "get" }).then(
|
||||||
|
(result) => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
contributors: result,
|
contributors: result,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,14 @@ const AdminProduct = EmberObject.extend({
|
||||||
|
|
||||||
AdminProduct.reopenClass({
|
AdminProduct.reopenClass({
|
||||||
findAll() {
|
findAll() {
|
||||||
return ajax("/s/admin/products", { method: "get" }).then((result) => {
|
return ajax("/subscriptions/admin/products", { method: "get" }).then(
|
||||||
|
(result) => {
|
||||||
if (result === null) {
|
if (result === null) {
|
||||||
return { unconfigured: true };
|
return { unconfigured: true };
|
||||||
}
|
}
|
||||||
return result.map((product) => AdminProduct.create(product));
|
return result.map((product) => AdminProduct.create(product));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
find(id) {
|
find(id) {
|
||||||
|
|
13
plugin.rb
13
plugin.rb
|
@ -68,17 +68,8 @@ require_relative "app/controllers/concerns/group"
|
||||||
after_initialize do
|
after_initialize do
|
||||||
::Stripe.api_version = "2024-04-10"
|
::Stripe.api_version = "2024-04-10"
|
||||||
|
|
||||||
module ::StripeDiscourseSubscriptions
|
|
||||||
class Engine < ::Rails::Engine
|
|
||||||
engine_name "stripe-discourse-subscriptions"
|
|
||||||
isolate_namespace StripeDiscourseSubscriptions
|
|
||||||
end
|
|
||||||
end
|
|
||||||
StripeDiscourseSubscriptions::Engine.routes.draw { get "/" => "pricingtable#index" }
|
|
||||||
require_relative "app/controllers/discourse_subscriptions/pricingtable_controller.rb"
|
|
||||||
|
|
||||||
Discourse::Application.routes.append do
|
Discourse::Application.routes.append do
|
||||||
mount ::StripeDiscourseSubscriptions::Engine, at: "subscriptions"
|
mount ::DiscourseSubscriptions::Engine, at: "subscriptions"
|
||||||
end
|
end
|
||||||
|
|
||||||
::Stripe.set_app_info(
|
::Stripe.set_app_info(
|
||||||
|
@ -87,8 +78,6 @@ after_initialize do
|
||||||
url: "https://github.com/discourse/discourse-subscriptions",
|
url: "https://github.com/discourse/discourse-subscriptions",
|
||||||
)
|
)
|
||||||
|
|
||||||
Discourse::Application.routes.append { mount ::DiscourseSubscriptions::Engine, at: "s" }
|
|
||||||
|
|
||||||
add_to_serializer(:site, :show_campaign_banner) do
|
add_to_serializer(:site, :show_campaign_banner) do
|
||||||
begin
|
begin
|
||||||
enabled = SiteSetting.discourse_subscriptions_enabled
|
enabled = SiteSetting.discourse_subscriptions_enabled
|
||||||
|
|
Loading…
Reference in New Issue