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