summaryrefslogtreecommitdiff
path: root/engines/billing/app/controllers
diff options
context:
space:
mode:
authorclaucece <soficeli0@gmail.com>2015-09-22 23:50:04 -0500
committerclaucece <soficeli0@gmail.com>2015-10-05 22:39:31 -0500
commit5a4f0fa64d36df1d60bdd693580e10ce55949b6a (patch)
treeda89540518cb5224e9b273d834156fff3ffcfc4e /engines/billing/app/controllers
parentc10bbfa44442c86fda82c16524341d5f21b63664 (diff)
changed routes and links
Diffstat (limited to 'engines/billing/app/controllers')
-rw-r--r--engines/billing/app/controllers/subscription_controller.rb7
-rw-r--r--engines/billing/app/controllers/subscriptions_controller.rb40
2 files changed, 17 insertions, 30 deletions
diff --git a/engines/billing/app/controllers/subscription_controller.rb b/engines/billing/app/controllers/subscription_controller.rb
new file mode 100644
index 0000000..5328c48
--- /dev/null
+++ b/engines/billing/app/controllers/subscription_controller.rb
@@ -0,0 +1,7 @@
+class SubscriptionsController < BillingBaseController
+
+before_filter :require_admin
+before_filter :require_login
+before_filter :confirm_cancel_subscription, :only => [:destroy]
+before_filter :confirm_no_pending_active_pastdue_subscription, :only => [:new, :create]
+before_filter :confirm_self, :only => [:new, :create]
diff --git a/engines/billing/app/controllers/subscriptions_controller.rb b/engines/billing/app/controllers/subscriptions_controller.rb
index 0a9b412..dda328a 100644
--- a/engines/billing/app/controllers/subscriptions_controller.rb
+++ b/engines/billing/app/controllers/subscriptions_controller.rb
@@ -1,16 +1,20 @@
class SubscriptionsController < BillingBaseController
before_filter :require_login
before_filter :confirm_cancel_subscription, :only => [:destroy]
- before_filter :confirm_self_or_admin, :only => [:index]
- before_filter :confirm_no_pending_active_pastdue_subscription, :only => [:new, :create]
- # for now, admins cannot create or destroy subscriptions for others:
- before_filter :confirm_self, :only => [:new, :create]
+
+ def index
+ @subscriptions = Braintree::Plan.all
+ end
+
+ def show
+ @subscription = Braintree::Plan.all.find params[:subscription_id]
+ end
def new
if current_user.braintree_customer_id
@client_token = Braintree::ClientToken.generate(customer_id: current_user.braintree_customer_id)
else
- @client_token = Braintree::ClientToken.generate
+ @client_token = Braintree::ClientToken.generate
end
@subscriptions = Braintree::Plan.all
end
@@ -41,7 +45,7 @@ class SubscriptionsController < BillingBaseController
def confirm
@result = Braintree::Subscription.sale(
payment_method_token: params[:payment_method_nonce],
- plans_id: params[:plan_id],
+ plan_id: params[:plan_id],
)
end
@@ -94,29 +98,5 @@ private
@result = Braintree::Subscription.cancel params[:id]
end
- def index
- customer = Customer.find_by_user_id(@user.id)
- @subscriptions = customer.subscriptions(nil, false)
- end
-
-
- def confirm_cancel_subscription
- access_denied unless view_context.allow_cancel_subscription(@subscription)
- end
-
- def confirm_no_pending_active_pastdue_subscription
- #@customer = Customer.find_by_user_id(@user.id)
- #if subscription = @customer.subscriptions # will return pending, active or pastdue subscription, if it exists
- #redirect_to user_subscription_path(@user, subscription.id), :notice => 'You already have a subscription'
- #end
- end
-
- def confirm_self
- @user == current_user
- end
-
- def confirm_self_or_admin
- access_denied unless confirm_self or admin?
- end
end