Justin DiRose a868e6b838
FEATURE: Cancel payments at end of subscription vs immediately
Previously, when a user canceled a subscription, the access would revoke
immediately on Discourse vs. at the end of the billing period. This
commit changes the behavior to remove membership at the end of the
billing period using Stripe's `cancel_at_period_end` attribute on the
Subscription object.

This commit now requires the setup of webhooks for subscription
processing to occur correctly.
2020-08-19 14:37:47 -05:00

32 lines
936 B
Ruby

# frozen_string_literal: true
require_dependency "subscriptions_user_constraint"
DiscourseSubscriptions::Engine.routes.draw do
# TODO: namespace this
scope 'admin' do
get '/' => 'admin#index'
end
namespace :admin do
resources :plans
resources :subscriptions, only: [:index, :destroy]
resources :products
end
namespace :user do
resources :payments, only: [:index]
resources :subscriptions, only: [:index, :destroy]
end
resources :customers, only: [:create]
resources :plans, only: [:index], constraints: SubscriptionsUserConstraint.new
resources :products, only: [:index, :show]
resources :subscriptions, only: [:create]
post '/subscriptions/finalize' => 'subscriptions#finalize'
post '/hooks' => 'hooks#create'
get '/' => 'subscriptions#index', constraints: SubscriptionsUserConstraint.new
get '/:id' => 'subscriptions#index', constraints: SubscriptionsUserConstraint.new
end