saasaparilla 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +36 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +3 -0
  6. data/Rakefile +39 -0
  7. data/app/controllers/saasaparilla/admin/plans_controller.rb +87 -0
  8. data/app/controllers/saasaparilla/admin/subscriptions_controller.rb +34 -0
  9. data/app/controllers/saasaparilla/admin/transactions_controller.rb +14 -0
  10. data/app/controllers/saasaparilla/application_controller.rb +4 -0
  11. data/app/controllers/saasaparilla/billing_history_controller.rb +9 -0
  12. data/app/controllers/saasaparilla/contact_info_controller.rb +31 -0
  13. data/app/controllers/saasaparilla/credit_card_controller.rb +41 -0
  14. data/app/controllers/saasaparilla/invoices_controller.rb +19 -0
  15. data/app/controllers/saasaparilla/payments_controller.rb +71 -0
  16. data/app/controllers/saasaparilla/plans_controller.rb +34 -0
  17. data/app/controllers/saasaparilla/subscription_controller.rb +71 -0
  18. data/app/helpers/application_helper.rb +3 -0
  19. data/app/helpers/plans_helper.rb +2 -0
  20. data/app/helpers/saasaparilla/billing_history_helper.rb +4 -0
  21. data/app/mailers/saasaparilla/notifier.rb +38 -0
  22. data/app/models/billing_activity.rb +12 -0
  23. data/app/models/contact_info.rb +107 -0
  24. data/app/models/credit_card.rb +109 -0
  25. data/app/models/invoice.rb +31 -0
  26. data/app/models/invoice_line_item.rb +3 -0
  27. data/app/models/payment.rb +39 -0
  28. data/app/models/plan.rb +36 -0
  29. data/app/models/subscription.rb +363 -0
  30. data/app/models/transaction.rb +32 -0
  31. data/app/views/layouts/saasaparilla.html.haml +9 -0
  32. data/app/views/saasaparilla/admin/plans/_form.html.haml +45 -0
  33. data/app/views/saasaparilla/admin/plans/edit.html.erb +4 -0
  34. data/app/views/saasaparilla/admin/plans/index.html.erb +31 -0
  35. data/app/views/saasaparilla/admin/plans/new.html.haml +4 -0
  36. data/app/views/saasaparilla/admin/plans/show.html.haml +20 -0
  37. data/app/views/saasaparilla/admin/subscriptions/_subscription.html.haml +7 -0
  38. data/app/views/saasaparilla/admin/subscriptions/index.html.haml +14 -0
  39. data/app/views/saasaparilla/admin/subscriptions/show.html.haml +52 -0
  40. data/app/views/saasaparilla/admin/transactions/_transaction.html.haml +6 -0
  41. data/app/views/saasaparilla/admin/transactions/index.html.haml +16 -0
  42. data/app/views/saasaparilla/billing_history/_billing_activity.html.haml +10 -0
  43. data/app/views/saasaparilla/billing_history/show.html.haml +11 -0
  44. data/app/views/saasaparilla/contact_info/edit.html.haml +8 -0
  45. data/app/views/saasaparilla/credit_card/edit.html.haml +18 -0
  46. data/app/views/saasaparilla/invoices/show.html.haml +17 -0
  47. data/app/views/saasaparilla/notifier/billing_failed.html.haml +5 -0
  48. data/app/views/saasaparilla/notifier/billing_successful.html.haml +5 -0
  49. data/app/views/saasaparilla/notifier/invoice_created.html.haml +24 -0
  50. data/app/views/saasaparilla/notifier/pending_cancellation_notice.html.haml +6 -0
  51. data/app/views/saasaparilla/notifier/subscription_canceled.html.haml +4 -0
  52. data/app/views/saasaparilla/notifier/subscription_created.html.haml +5 -0
  53. data/app/views/saasaparilla/payments/edit.html.haml +10 -0
  54. data/app/views/saasaparilla/payments/new.html.haml +10 -0
  55. data/app/views/saasaparilla/payments/show.html.haml +8 -0
  56. data/app/views/saasaparilla/plans/edit.html.haml +34 -0
  57. data/app/views/saasaparilla/subscription/_contact_info_form.html.haml +19 -0
  58. data/app/views/saasaparilla/subscription/_credit_card_form.html.haml +10 -0
  59. data/app/views/saasaparilla/subscription/new.html.haml +24 -0
  60. data/app/views/saasaparilla/subscription/show.html.haml +73 -0
  61. data/autotest/discover.rb +2 -0
  62. data/config/routes.rb +27 -0
  63. data/lib/country_select/MIT-LICENSE +20 -0
  64. data/lib/country_select/README +15 -0
  65. data/lib/country_select/init.rb +1 -0
  66. data/lib/country_select/install.rb +2 -0
  67. data/lib/country_select/lib/country_select.rb +88 -0
  68. data/lib/country_select/uninstall.rb +1 -0
  69. data/lib/extensions/action_controller/base.rb +7 -0
  70. data/lib/extensions/active_record/nested_attributes.rb +36 -0
  71. data/lib/extensions/active_record/statuses.rb +16 -0
  72. data/lib/extensions/billable.rb +12 -0
  73. data/lib/generators/saasaparilla/install/install_generator.rb +29 -0
  74. data/lib/generators/saasaparilla/install/templates/create_saasaparilla_tables.rb +106 -0
  75. data/lib/generators/saasaparilla/install/templates/saasaparilla.yml +32 -0
  76. data/lib/initializers/auth_dot_net.rb +25 -0
  77. data/lib/initializers/simple_form.rb +77 -0
  78. data/lib/initializers/time_format.rb +3 -0
  79. data/lib/saasaparilla.rb +16 -0
  80. data/lib/saasaparilla/authentication.rb +18 -0
  81. data/lib/saasaparilla/authorization.rb +26 -0
  82. data/lib/saasaparilla/engine.rb +30 -0
  83. data/lib/saasaparilla/version.rb +3 -0
  84. data/saasaparilla.gemspec +48 -0
  85. data/spec/.livereload +21 -0
  86. data/spec/dummy/Rakefile +7 -0
  87. data/spec/dummy/app/controllers/application_controller.rb +11 -0
  88. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  89. data/spec/dummy/app/model/user.rb +4 -0
  90. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  91. data/spec/dummy/config.ru +4 -0
  92. data/spec/dummy/config/application.rb +46 -0
  93. data/spec/dummy/config/boot.rb +10 -0
  94. data/spec/dummy/config/database.yml +22 -0
  95. data/spec/dummy/config/environment.rb +5 -0
  96. data/spec/dummy/config/environments/development.rb +30 -0
  97. data/spec/dummy/config/environments/production.rb +49 -0
  98. data/spec/dummy/config/environments/test.rb +39 -0
  99. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  100. data/spec/dummy/config/initializers/inflections.rb +10 -0
  101. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  102. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  103. data/spec/dummy/config/initializers/session_store.rb +8 -0
  104. data/spec/dummy/config/initializers/simple_form.rb +77 -0
  105. data/spec/dummy/config/locales/en.yml +5 -0
  106. data/spec/dummy/config/locales/simple_form.en.yml +24 -0
  107. data/spec/dummy/config/routes.rb +58 -0
  108. data/spec/dummy/config/saasaparilla.yml +32 -0
  109. data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
  110. data/spec/dummy/public/404.html +26 -0
  111. data/spec/dummy/public/422.html +26 -0
  112. data/spec/dummy/public/500.html +26 -0
  113. data/spec/dummy/public/favicon.ico +0 -0
  114. data/spec/dummy/public/index.html +0 -0
  115. data/spec/dummy/public/javascripts/application.js +2 -0
  116. data/spec/dummy/public/javascripts/jquery.js +8374 -0
  117. data/spec/dummy/public/javascripts/jquery.min.js +16 -0
  118. data/spec/dummy/public/javascripts/rails.js +159 -0
  119. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  120. data/spec/dummy/script/rails +6 -0
  121. data/spec/dummy/vendor/plugins/active_merchant_testing/MIT-LICENSE +20 -0
  122. data/spec/dummy/vendor/plugins/active_merchant_testing/README +32 -0
  123. data/spec/dummy/vendor/plugins/active_merchant_testing/Rakefile +23 -0
  124. data/spec/dummy/vendor/plugins/active_merchant_testing/init.rb +1 -0
  125. data/spec/dummy/vendor/plugins/active_merchant_testing/install.rb +1 -0
  126. data/spec/dummy/vendor/plugins/active_merchant_testing/lib/authorize_net_cim_gateway_test.rb +492 -0
  127. data/spec/dummy/vendor/plugins/active_merchant_testing/lib/authorize_net_gateway_test.rb +133 -0
  128. data/spec/dummy/vendor/plugins/active_merchant_testing/lib/paypal_express_gateway_test.rb +138 -0
  129. data/spec/dummy/vendor/plugins/active_merchant_testing/tasks/activemerchant_testing_tasks.rake +4 -0
  130. data/spec/dummy/vendor/plugins/active_merchant_testing/test/activemerchant_testing_test.rb +8 -0
  131. data/spec/dummy/vendor/plugins/active_merchant_testing/test/test_helper.rb +3 -0
  132. data/spec/dummy/vendor/plugins/active_merchant_testing/uninstall.rb +1 -0
  133. data/spec/factories/factories.rb +75 -0
  134. data/spec/integration/navigation_spec.rb +9 -0
  135. data/spec/mailers/notifier_spec.rb +167 -0
  136. data/spec/models/billing_activity_spec.rb +27 -0
  137. data/spec/models/contact_info_spec.rb +32 -0
  138. data/spec/models/credit_card_spec.rb +57 -0
  139. data/spec/models/invoice_line_item_spec.rb +7 -0
  140. data/spec/models/invoice_spec.rb +25 -0
  141. data/spec/models/payment_spec.rb +29 -0
  142. data/spec/models/plan_spec.rb +16 -0
  143. data/spec/models/subscription_spec.rb +414 -0
  144. data/spec/requests/admin_plans_spec.rb +32 -0
  145. data/spec/requests/admin_subscriptions_spec.rb +31 -0
  146. data/spec/requests/billing_history_spec.rb +26 -0
  147. data/spec/requests/contact_info_controller_spec.rb +42 -0
  148. data/spec/requests/credit_cards_spec.rb +79 -0
  149. data/spec/requests/invoices_spec.rb +23 -0
  150. data/spec/requests/payments_spec.rb +89 -0
  151. data/spec/requests/subscription_plans_spec.rb +34 -0
  152. data/spec/requests/subscriptions_spec.rb +80 -0
  153. data/spec/spec_helper.rb +68 -0
  154. data/spec/spec_helpers/spec_helpers.rb +8 -0
  155. metadata +611 -0
@@ -0,0 +1,4 @@
1
+ <div class="saasaparilla">
2
+ <h1>Editing plan</h1>
3
+ <%= render 'form' %>
4
+ </div>
@@ -0,0 +1,31 @@
1
+ <div class="saasaparilla">
2
+
3
+ <h1>Plans</h1>
4
+
5
+ <table>
6
+ <tr>
7
+ <th>Name</th>
8
+ <th>Billing period</th>
9
+ <th>Subscription</th>
10
+ <th>Extras</th>
11
+ <th></th>
12
+ <th></th>
13
+ <th></th>
14
+ </tr>
15
+
16
+ <% @plans.each do |plan| %>
17
+ <tr>
18
+ <td><%= plan.name %></td>
19
+ <td><%= plan.billing_period %></td>
20
+ <td><%= plan.subscription_id %></td>
21
+ <td><%#= plan.extras %></td>
22
+ <td><%= link_to 'Show', admin_plan_path(plan) %></td>
23
+ <td><%= link_to 'Edit', edit_admin_plan_path(plan) %></td>
24
+ <td><%= link_to 'Destroy', admin_plan_path(plan), :confirm => 'Are you sure?', :method => :delete %></td>
25
+ </tr>
26
+ <% end %>
27
+ </table>
28
+
29
+ <p><%= link_to 'New Plan', new_admin_plan_path %></p>
30
+
31
+ </div>
@@ -0,0 +1,4 @@
1
+ .saasaparilla
2
+ %h1 New plan
3
+ = render 'form'
4
+
@@ -0,0 +1,20 @@
1
+ .saasaparilla
2
+ %h2 Plan
3
+ %p
4
+ %b Name:
5
+ = @plan.name
6
+ %p
7
+ %b Billing period:
8
+ = @plan.billing_period
9
+ %p
10
+ %b Attributes:
11
+ %br
12
+ - @plan.dynamic_attributes.each do |da|
13
+ = da[0].gsub("field_", "")
14
+ = ": "
15
+ = da[1]
16
+ %br
17
+ %p
18
+ = link_to 'Edit', edit_admin_plan_path(@plan)
19
+ = " | "
20
+ = link_to 'Back', admin_plans_path
@@ -0,0 +1,7 @@
1
+ %tr
2
+ %td= subscription.email
3
+ %td= subscription.created_at.to_s(:month_day_year)
4
+ %td= subscription.last_transaction_date
5
+ %td= subscription.status
6
+ %td= subscription.plan_name
7
+ %td= link_to "Show Detail", admin_subscription_path(subscription)
@@ -0,0 +1,14 @@
1
+ .saasaparilla
2
+ %h1 Subscriptions
3
+
4
+ %table
5
+ %tr
6
+ %th Email
7
+ %th Sign up
8
+ %th Last Transaction Date
9
+ %th Status
10
+ %th Plan
11
+
12
+ = render :partial => "subscription", :collection => @subscriptions
13
+
14
+ = will_paginate @subscriptions
@@ -0,0 +1,52 @@
1
+ .saasaparilla
2
+ %h1 Subscription Detail
3
+
4
+ .info
5
+ %h2 Subscriber Contact Info
6
+ %p
7
+ = "#{@subscription.first_name} #{@subscription.last_name}"
8
+ %br
9
+ = @subscription.contact_info.email
10
+ %br
11
+ - if @subscription.contact_info.require_billing_address?
12
+ = @subscription.address
13
+ %br
14
+ = "#{@subscription.city}, #{@subscription.state} #{@subscription.zip}"
15
+ %br
16
+ - if @subscription.contact_info.require_phone_number?
17
+ = "#{@subscription.phone_number}"
18
+
19
+ .info
20
+ %h2 Subscription Details
21
+ %p
22
+ ="Status: "
23
+ = @subscription.status
24
+ %br
25
+ - if @subscription.no_charge
26
+ Complimentary (no_charge):
27
+ = @subscription.no_charge
28
+ %br
29
+ = "Balance: "
30
+ = number_to_currency(@subscription.balance)
31
+ %br
32
+ = "Last Invoiced: "
33
+ = @subscription.invoiced_on.to_s(:month_day_year) unless @subscription.invoiced_on.nil?
34
+ %br
35
+ = "Last Transaction Date: "
36
+ = @subscription.last_transaction_date
37
+ %br
38
+ = "Last Transaction Amount: "
39
+ = number_to_currency(@subscription.last_transaction_amount)
40
+ %br
41
+ %br
42
+ = link_to "See all transactions", admin_subscription_transactions_path(@subscription)
43
+
44
+ .info
45
+ %h2 Actions
46
+ %p
47
+ = link_to "Cancel Subscription", cancel_admin_subscription_path(@subscription), :confirm => "Are you sure you want to cancel this subscription?" unless @subscription.status == "canceled"
48
+ %br
49
+ - if @subscription.no_charge
50
+ = link_to "Revoke complimentary subscription", toggle_no_charge_admin_subscription_path(@subscription), :confirm => "Are you sure you want to comp this subscription?"
51
+ - else
52
+ = link_to "Make subscription complimentary", toggle_no_charge_admin_subscription_path(@subscription), :confirm => "Are you sure you want to comp this subscription?"
@@ -0,0 +1,6 @@
1
+ %tr
2
+ %td= transaction.created_at.to_s(:month_day_year)
3
+ %td= number_to_currency(transaction.amount)
4
+ %td= transaction.success
5
+ %td= transaction.action
6
+ %td= transaction.message
@@ -0,0 +1,16 @@
1
+ .saasaparilla
2
+ %h1
3
+ = "Transactions for #{@subscription.email}"
4
+
5
+ %table
6
+ %tr
7
+ %th Date
8
+ %th Amount
9
+ %th Success
10
+ %th Action
11
+ %th Message
12
+
13
+ = render :partial => "transaction", :collection => @transactions
14
+
15
+ = will_paginate @transactions
16
+
@@ -0,0 +1,10 @@
1
+ %tr
2
+ %td
3
+ = billing_activity.created_at.to_s(:month_day_year)
4
+ %td
5
+ = raw(billing_activity.message)
6
+ %td
7
+ - if billing_activity.invoice.nil?
8
+ = number_to_currency(billing_activity.amount)
9
+ - else
10
+ = "(#{number_to_currency(billing_activity.invoice.amount)})"
@@ -0,0 +1,11 @@
1
+ .saasaparilla
2
+ %h1 Billing History
3
+
4
+ %table
5
+ %tr
6
+ %th Date
7
+ %th Description
8
+ %th Amount
9
+
10
+ = render :partial => "billing_activity", :collection => @billing_activities
11
+
@@ -0,0 +1,8 @@
1
+ .saasaparilla
2
+ %h1 Update Billing Contact Info
3
+
4
+ = simple_form_for [@subscription, @contact_info] do |f|
5
+ = render :partial => "saasaparilla/subscription/contact_info_form", :locals =>{:f => f}
6
+
7
+ = f.submit "Update Contact Info"
8
+ = link_to "Cancel", :back
@@ -0,0 +1,18 @@
1
+ .saasaparilla
2
+ %h1 Update Billing Payment Info
3
+
4
+ .info
5
+ %h2 Current card
6
+ %p
7
+ = @current_card.card_number
8
+ %br
9
+ = "Exp: #{@current_card.expiration_date}"
10
+
11
+
12
+ .info
13
+ %h2 Update card
14
+ = simple_form_for [@subscription, @credit_card], :secure => true do |f|
15
+ = render :partial => 'saasaparilla/subscription/credit_card_form', :locals => {:f => f}
16
+ = f.submit "Update Card"
17
+ = link_to "Cancel", :back
18
+
@@ -0,0 +1,17 @@
1
+ .saasaparilla
2
+ %h1 Invoice
3
+
4
+ %p
5
+ Date
6
+ = @invoice.created_at.to_s(:month_day_year)
7
+
8
+ %table
9
+ %tr
10
+ %th Price
11
+ %th Billing From
12
+ %th Billing To
13
+ - for line_item in @invoice.invoice_line_items
14
+ %tr
15
+ %td= line_item.price
16
+ %td= line_item.from.to_date.to_s(:month_day_year)
17
+ %td= line_item.to.to_date.to_s(:month_day_year)
@@ -0,0 +1,5 @@
1
+ %h2 Account Billing Failed
2
+
3
+ %p
4
+ = "Our attempt to charge your credit card #{number_to_currency(@amount)} for your #{@subscription.plan.billing_period} subscription to the #{@subscription.plan.name} plan has failed. Please visit #{@url} to fix this problem."
5
+ If you need any assistance, please contact the administrator.
@@ -0,0 +1,5 @@
1
+ %h2 Your account was successfully billed
2
+
3
+ %p
4
+ = "Your credit card has been charged #{number_to_currency(@amount)} for your #{@subscription.plan.billing_period} subscription to the #{@subscription.plan.name} plan. Thank you."
5
+ If you need any assistance, please contact the administrator.
@@ -0,0 +1,24 @@
1
+ %h2 Invoice
2
+
3
+ %p
4
+ = "You will be billed in 5 days for the following:"
5
+
6
+ %table
7
+ - @invoice.invoice_line_items.each do |item|
8
+ %tr
9
+ %td
10
+ = @subscription.plan.name
11
+ %td
12
+ = "#{item.from.to_s}-#{item.to.to_s}"
13
+ %td
14
+ = "$" + item.price.to_s
15
+ %tr
16
+ %td
17
+ Total:
18
+ %td
19
+ &nbsp;
20
+ %td
21
+ = "$" + @invoice.amount.to_s
22
+
23
+ %p
24
+ No action is required at this time. If you need any assistance, please contact the administrator.
@@ -0,0 +1,6 @@
1
+ %h2 Your account will be canceled soon
2
+
3
+ %p
4
+ = "Our attempt to charge your credit card #{number_to_currency(@amount)} for your #{@subscription.plan.billing_period} subscription to the #{@subscription.plan.name} plan has failed multiple times. Please visit #{@url} to fix this problem."
5
+ If this problem is not fixed soon, your account will be canceled and deleted.
6
+ If you need any assistance, please contact the administrator.
@@ -0,0 +1,4 @@
1
+ %h2 Your subscription has been canceled
2
+
3
+ %p
4
+ Your subscription has been canceled. If you need any further assistance, please contact the administrator.
@@ -0,0 +1,5 @@
1
+ %h2 Thanks for signing up
2
+
3
+ %p
4
+ = "Your subscription to the #{@subscription.plan.name} plan has be created. You will be billed automatically on a #{@subscription.plan.billing_period} basis."
5
+ If you need any assistance, please contact the administrator.
@@ -0,0 +1,10 @@
1
+ .saasaparilla
2
+ %h1 Confirm Payment
3
+
4
+ %p
5
+ Payment Amount
6
+ = number_to_currency(@payment.amount)
7
+
8
+ = simple_form_for [:subscription, @payment] do |f|
9
+ = f.hidden_field :amount, :value => @payment.amount
10
+ = f.submit "Confirm"
@@ -0,0 +1,10 @@
1
+ .saasaparilla
2
+ %h1 Make a Payment
3
+
4
+ %strong Current Balance
5
+ = number_to_currency(@subscription.balance)
6
+
7
+ = simple_form_for [@subscription, @payment], :secure => true do |f|
8
+ = f.input :amount
9
+ = f.submit "Submit"
10
+
@@ -0,0 +1,8 @@
1
+ .saasaparilla
2
+ %p
3
+ Payment Amount:
4
+ = number_to_currency(@payment.amount)
5
+
6
+ %p
7
+ Payment Date:
8
+ = @payment.updated_at.to_s(:month_day_year)
@@ -0,0 +1,34 @@
1
+ .saasaparilla
2
+ %h1 Change you plan
3
+
4
+ - if Saasaparilla::CONFIG["include_free_account"]
5
+ .plan
6
+ %h4
7
+ Free Plan
8
+ = button_to "Downgrade", {:action => :update, :subscription => {:plan_id => nil}}, {:method => :put, :confirm => 'Are you sure you want downgrade to the free plan?'}
9
+ %p
10
+ If you downgrade to the free plan, you may reactivate your paid subscription at a later date.
11
+ %br
12
+
13
+ - @plans.each do |plan|
14
+ .plan
15
+ %h4
16
+ = "#{plan.name}: #{number_to_currency(plan.price)}"
17
+ - if @subscription.plan_id == plan.id
18
+ %br
19
+ You are currently subscribed to this plan
20
+ %br
21
+ %br
22
+ - else
23
+ - if plan.price > @subscription.plan.price
24
+ = button_to "Upgrade", {:action => :update, :subscription => {:plan_id => plan.id}}, {:method => :put, :confirm => 'Are you sure you want to upgrade your plan?'}
25
+ %p
26
+ If you choose to upgrade, you will be put on the new plan immediately. You will be charged the new rate minus a pro-rated credit for your current cycle.
27
+ %br
28
+ - else
29
+ = button_to "Downgrade", {:action => :update, :subscription => {:plan_id => plan.id}}, {:method => :put, :confirm => 'Are you sure you want to downgrade your plan?'}
30
+ %p
31
+ The downgrade will occur at the end of your current billing cycle. You will remain on your current plan until then.
32
+ %br
33
+
34
+ = link_to 'Back', subscription_path
@@ -0,0 +1,19 @@
1
+ = f.input :first_name
2
+ = f.input :last_name
3
+ = f.input :email
4
+ - if @subscription.contact_info.require_billing_address?
5
+ = f.input :address
6
+ = f.input :city
7
+ = f.input :state
8
+ = f.input :zip
9
+ = f.input :country
10
+ - if @subscription.contact_info.require_phone_number?
11
+ .input.string.required
12
+ = f.label :phone, :required => true
13
+ = "("
14
+ = f.text_field :phone_area_code, :required => true, :size => 3, :maxlength => 3, :class => "phone_3"
15
+ = ")"
16
+ = f.text_field :phone_prefix, :required => true, :size => 3, :maxlength => 3, :class => "phone_3"
17
+ = " - "
18
+ = f.text_field :phone_suffix, :required => true, :size => 4, :maxlength => 4, :class => "phone_4"
19
+ = f.error :phone_number, :id => 'phone_error'
@@ -0,0 +1,10 @@
1
+ = f.input :card_type, :collection => CreditCard::CARD_TYPES, :include_blank => false
2
+ - if f.object.new_record?
3
+ = f.input :card_number
4
+ - else
5
+ = f.input :card_number, :input_html => {:value => ""}
6
+ = f.input :expiry_month, :collection => CreditCard::MONTHS
7
+ = f.input :expiry_year, :collection => CreditCard::YEARS, :error_html => { :id => "subscription_credit_card_attributes_expiry_date_error"}
8
+ = f.input :card_verification
9
+
10
+
@@ -0,0 +1,24 @@
1
+ .saasaparilla
2
+ %h1 Create Subscription
3
+
4
+ = simple_form_for @subscription, :url => subscription_path(:secure => true) do |f|
5
+
6
+ .info
7
+ %h2 Plan
8
+ = f.association :plan, :as => 'radio', :label => false
9
+
10
+
11
+ = f.simple_fields_for :contact_info, @subscription.contact_info do |cif|
12
+ .info
13
+ %h2 Billing Contact Info
14
+ = render :partial => 'contact_info_form', :locals => {:f => cif}
15
+
16
+ = f.simple_fields_for :credit_card, @subscription.credit_card do |cf|
17
+ .info
18
+ %h2 Billing Payment Info
19
+ = render :partial => 'credit_card_form', :locals => {:f => cf}
20
+
21
+
22
+ = f.submit "Create Subscription"
23
+
24
+
@@ -0,0 +1,73 @@
1
+ .saasaparilla
2
+ %h1 Subscription
3
+
4
+
5
+ - if @subscription.status == "canceled"
6
+ .info
7
+ %p
8
+ You do not have an active paid subscription.
9
+ = link_to "Reactivate your previous plan", reactivate_subscription_path, :confirm => "Are you sure you want to reactive your previous plan? Your credit card will be billed immediately."
10
+
11
+ - else
12
+ .info
13
+ %h2 Plan
14
+
15
+ %p
16
+ = "You are currently subscribed to the #{@subscription.plan.name} plan."
17
+ %p
18
+ = link_to "Change plan", edit_subscription_plan_path
19
+
20
+ .info
21
+ %h2 Billing Contact Info
22
+
23
+ %p
24
+ = "#{@subscription.contact_info.first_name} #{@subscription.contact_info.last_name}"
25
+ %br
26
+ = @subscription.contact_info.email
27
+ %br
28
+ - if @subscription.contact_info.require_billing_address?
29
+ = @subscription.contact_info.address
30
+ %br
31
+ = "#{@subscription.contact_info.city}, #{@subscription.contact_info.state} #{@subscription.contact_info.zip}"
32
+ %br
33
+ = @subscription.contact_info.country
34
+ %br
35
+ - if @subscription.contact_info.require_phone_number?
36
+ = "#{@subscription.contact_info.phone_number}"
37
+ %p
38
+ = link_to "Update", edit_subscription_contact_info_path(@subscription.contact_info)
39
+
40
+ .info
41
+ %h2 Billing Payment Info
42
+
43
+
44
+ %p
45
+ Card Number
46
+ %br
47
+ = @subscription.credit_card.card_number
48
+ %p
49
+ Expiration
50
+ %br
51
+ =@subscription.credit_card.expiration_date
52
+ %p
53
+ = link_to "Update", edit_subscription_credit_card_path(@subscription.credit_card)
54
+
55
+ .info
56
+ %h2 Billing History
57
+ %p
58
+ = "Balance: #{number_to_currency(@subscription.balance)}"
59
+ = link_to "Make a payment", new_subscription_payment_path if @subscription.balance > 0
60
+ %br
61
+ = "Your next billing date is #{@subscription.billing_date.to_s(:month_day_year)}"
62
+ %br
63
+ Your subscription was created on
64
+ = @subscription.created_at.to_s(:month_day_year)
65
+
66
+ %table.history-table
67
+ = render :partial => 'saasaparilla/billing_history/billing_activity', :collection => @subscription.billing_activities.recent.limit(5)
68
+
69
+
70
+ .info
71
+ %h2 Actions
72
+ %p
73
+ = link_to "Cancel Subscription", @subscription, :method => "delete", :confirm => "Are you sure you want to cancel your subscription?"