2019-09-11 05:55:35 -04:00
|
|
|
# frozen_string_literal: true
|
2019-09-11 05:27:24 -04:00
|
|
|
|
2019-12-02 02:58:14 -05:00
|
|
|
# name: discourse-subscriptions
|
|
|
|
# about: Integrates Stripe into Discourse to allow visitors to subscribe
|
2020-03-21 05:35:05 -04:00
|
|
|
# version: 2.8.1
|
2019-12-02 02:58:14 -05:00
|
|
|
# url: https://github.com/rimian/discourse-subscriptions
|
2019-09-11 05:11:02 -04:00
|
|
|
# authors: Rimian Perkins
|
2017-01-30 21:28:41 -05:00
|
|
|
|
2019-12-03 19:53:05 -05:00
|
|
|
enabled_site_setting :discourse_subscriptions_enabled
|
2017-01-31 19:35:21 -05:00
|
|
|
|
2020-03-19 19:30:32 -04:00
|
|
|
gem 'stripe', '5.17.0'
|
2019-09-11 05:18:30 -04:00
|
|
|
|
2019-12-02 19:51:18 -05:00
|
|
|
register_asset "stylesheets/common/main.scss"
|
|
|
|
register_asset "stylesheets/common/layout.scss"
|
2019-12-05 21:52:03 -05:00
|
|
|
register_asset "stylesheets/common/subscribe.scss"
|
2019-12-02 19:51:18 -05:00
|
|
|
register_asset "stylesheets/mobile/main.scss"
|
2019-10-24 22:23:32 -04:00
|
|
|
register_svg_icon "credit-card" if respond_to?(:register_svg_icon)
|
2019-09-11 07:14:48 -04:00
|
|
|
|
2019-09-11 05:18:30 -04:00
|
|
|
register_html_builder('server:before-head-close') do
|
|
|
|
"<script src='https://js.stripe.com/v3/'></script>"
|
|
|
|
end
|
|
|
|
|
|
|
|
extend_content_security_policy(
|
|
|
|
script_src: ['https://js.stripe.com/v3/']
|
|
|
|
)
|
|
|
|
|
2019-12-03 17:29:13 -05:00
|
|
|
add_admin_route 'discourse_subscriptions.admin_navigation', 'discourse-subscriptions.products'
|
2019-09-13 22:56:28 -04:00
|
|
|
|
|
|
|
Discourse::Application.routes.append do
|
2019-12-02 02:58:14 -05:00
|
|
|
get '/admin/plugins/discourse-subscriptions' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/products' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/products/:product_id' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/products/:product_id/plans' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/products/:product_id/plans/:plan_id' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/subscriptions' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/plans' => 'admin/plugins#index'
|
|
|
|
get '/admin/plugins/discourse-subscriptions/plans/:plan_id' => 'admin/plugins#index'
|
2019-10-24 23:00:59 -04:00
|
|
|
get 'u/:username/billing' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
|
2019-12-15 18:42:55 -05:00
|
|
|
get 'u/:username/billing/:id' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
|
2019-09-13 22:56:28 -04:00
|
|
|
end
|
|
|
|
|
2019-09-11 03:13:12 -04:00
|
|
|
after_initialize do
|
2019-12-04 18:29:26 -05:00
|
|
|
::Stripe.api_version = "2019-12-03"
|
2019-12-02 02:58:14 -05:00
|
|
|
|
|
|
|
::Stripe.set_app_info(
|
|
|
|
'Discourse Subscriptions',
|
2020-03-21 05:35:05 -04:00
|
|
|
version: '2.8.1',
|
2019-12-02 02:58:14 -05:00
|
|
|
url: 'https://github.com/rimian/discourse-subscriptions'
|
|
|
|
)
|
2019-09-11 07:14:48 -04:00
|
|
|
|
2019-09-12 23:52:41 -04:00
|
|
|
[
|
2019-12-03 17:44:20 -05:00
|
|
|
"../lib/discourse_subscriptions/engine",
|
2019-09-12 23:52:41 -04:00
|
|
|
"../config/routes",
|
2019-11-28 17:01:56 -05:00
|
|
|
"../app/controllers/concerns/group",
|
2019-09-24 06:44:51 -04:00
|
|
|
"../app/controllers/concerns/stripe",
|
2019-09-13 22:56:28 -04:00
|
|
|
"../app/controllers/admin_controller",
|
2019-09-24 02:04:42 -04:00
|
|
|
"../app/controllers/admin/plans_controller",
|
2019-10-14 22:18:25 -04:00
|
|
|
"../app/controllers/admin/products_controller",
|
2019-09-23 03:53:05 -04:00
|
|
|
"../app/controllers/admin/subscriptions_controller",
|
2019-12-17 00:31:58 -05:00
|
|
|
"../app/controllers/user/payments_controller",
|
2019-10-31 22:43:09 -04:00
|
|
|
"../app/controllers/user/subscriptions_controller",
|
2019-10-10 21:26:01 -04:00
|
|
|
"../app/controllers/customers_controller",
|
2020-01-09 18:24:09 -05:00
|
|
|
"../app/controllers/hooks_controller",
|
2019-10-27 23:05:58 -04:00
|
|
|
"../app/controllers/invoices_controller",
|
2019-10-09 22:52:55 -04:00
|
|
|
"../app/controllers/plans_controller",
|
2019-12-12 18:41:14 -05:00
|
|
|
"../app/controllers/payments_controller",
|
2019-10-24 17:18:16 -04:00
|
|
|
"../app/controllers/products_controller",
|
2019-10-13 18:52:43 -04:00
|
|
|
"../app/controllers/subscriptions_controller",
|
2019-10-25 20:31:19 -04:00
|
|
|
"../app/models/customer",
|
2019-09-13 22:56:28 -04:00
|
|
|
"../app/serializers/payment_serializer",
|
2019-09-12 23:52:41 -04:00
|
|
|
].each { |path| require File.expand_path(path, __FILE__) }
|
|
|
|
|
2019-09-11 04:32:09 -04:00
|
|
|
Discourse::Application.routes.append do
|
2019-12-03 19:23:45 -05:00
|
|
|
mount ::DiscourseSubscriptions::Engine, at: 's'
|
2019-09-11 04:32:09 -04:00
|
|
|
end
|
2017-02-16 21:15:32 -05:00
|
|
|
end
|