summaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/billing/app/controllers/subscriptions_controller.rb9
-rw-r--r--engines/billing/app/views/subscriptions/index.html.erb36
-rw-r--r--engines/billing/app/views/subscriptions/show.html.erb26
3 files changed, 56 insertions, 15 deletions
diff --git a/engines/billing/app/controllers/subscriptions_controller.rb b/engines/billing/app/controllers/subscriptions_controller.rb
index dda328a..65db21b 100644
--- a/engines/billing/app/controllers/subscriptions_controller.rb
+++ b/engines/billing/app/controllers/subscriptions_controller.rb
@@ -7,7 +7,12 @@ class SubscriptionsController < BillingBaseController
end
def show
- @subscription = Braintree::Plan.all.find params[:subscription_id]
+ @subscriptions = Braintree::Plan.all
+ @subscriptions = Braintree::Plan.all.find params[:subscription_id]
+ end
+
+ def search
+ @subscription = Braintree::Subscription.search params[:status]
end
def new
@@ -95,7 +100,7 @@ private
end
def destroy
- @result = Braintree::Subscription.cancel params[:id]
+ @subscriptions = Braintree::Subscription.cancel params[:id]
end
diff --git a/engines/billing/app/views/subscriptions/index.html.erb b/engines/billing/app/views/subscriptions/index.html.erb
index b47fae6..2037de3 100644
--- a/engines/billing/app/views/subscriptions/index.html.erb
+++ b/engines/billing/app/views/subscriptions/index.html.erb
@@ -1,19 +1,29 @@
<h2 class="mbs">Subscriptions</h2>
<br>
<br>
-<p>Choose subcription:</p>
-<br>
-<ul class="nav nav-tabs nav-stacked">
- <% @subscriptions.each do |subscription| %>
- <li>
- <div class="btn-group">
- <button class="btn"> <%= subscription.name %>
- <%= subscription.price %> </button>
- </div>
- <div>
- <%=link_to "Checkout", :show_subscription, class: "button" %>
- </div>
- </li>
+<div id="last"> Lastest Subscriptions:
+ <% if params[:search] == "active" %>
+ <%= render :partial => "subscriptions/subscription_details" %>
+ <%# Add destroy, route %>
+ <%=link_to "Unsubscribe", :show_subscription, class: "button" %>
+ </div>
+ <br>
+ <% else %>
+ <p> No subscriptions </p>
+ <p>Choose subcription:</p>
+ <br>
+ <ul class="nav nav-tabs nav-stacked">
+ <% @subscriptions.each do |subscription| %>
+ <li>
+ <div class="btn-group">
+ <button class="btn"> <%= subscription.name %>
+ <%= subscription.price %> </button>
+ </div>
+ <div>
+ <%=link_to "Subscribe", :show_subscription, class: "button" %>
+ </div> <br>
+ </li>
+ <% end %>
<% end %>
</ul>
diff --git a/engines/billing/app/views/subscriptions/show.html.erb b/engines/billing/app/views/subscriptions/show.html.erb
new file mode 100644
index 0000000..f3c730d
--- /dev/null
+++ b/engines/billing/app/views/subscriptions/show.html.erb
@@ -0,0 +1,26 @@
+<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
+<h2 class="mbs">New Subscription
+</h2>
+<br/>
+<%= simple_form_for :subscription, :url => :subscriptions, :id => "checkout-form-#{subscription.id}" do |f| %>
+ <input name="plan_id" type="hidden" value="<%= subscription.id %>"></input>
+ <% if current_user and !current_user.has_payment_info? %>
+ <%= render 'customer_form'%>
+ <% end %>
+ <br/>
+ <p> Please enter payment details: </p>
+ <div id="payment-form-<%= subscription.id %>"></div>
+ <div class="form-actions">
+ <%= f.submit t(:choose), :class => 'btn btn-primary' %>
+ </div>
+ <script charset="utf-8" type="text/javascript">
+ var clientToken = "<%= @client_token %>";
+ braintree.setup(clientToken, "dropin", {
+ container: "payment-form-#{subscription.id}",
+ coinbase: { container: "coinbase-container-id" }
+ });
+ </script>
+ <% end %>
+<div id="payment-form"></div>
+<div id="coinbase-container-id"></div>
+