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.
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/Gemfile +36 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/controllers/saasaparilla/admin/plans_controller.rb +87 -0
- data/app/controllers/saasaparilla/admin/subscriptions_controller.rb +34 -0
- data/app/controllers/saasaparilla/admin/transactions_controller.rb +14 -0
- data/app/controllers/saasaparilla/application_controller.rb +4 -0
- data/app/controllers/saasaparilla/billing_history_controller.rb +9 -0
- data/app/controllers/saasaparilla/contact_info_controller.rb +31 -0
- data/app/controllers/saasaparilla/credit_card_controller.rb +41 -0
- data/app/controllers/saasaparilla/invoices_controller.rb +19 -0
- data/app/controllers/saasaparilla/payments_controller.rb +71 -0
- data/app/controllers/saasaparilla/plans_controller.rb +34 -0
- data/app/controllers/saasaparilla/subscription_controller.rb +71 -0
- data/app/helpers/application_helper.rb +3 -0
- data/app/helpers/plans_helper.rb +2 -0
- data/app/helpers/saasaparilla/billing_history_helper.rb +4 -0
- data/app/mailers/saasaparilla/notifier.rb +38 -0
- data/app/models/billing_activity.rb +12 -0
- data/app/models/contact_info.rb +107 -0
- data/app/models/credit_card.rb +109 -0
- data/app/models/invoice.rb +31 -0
- data/app/models/invoice_line_item.rb +3 -0
- data/app/models/payment.rb +39 -0
- data/app/models/plan.rb +36 -0
- data/app/models/subscription.rb +363 -0
- data/app/models/transaction.rb +32 -0
- data/app/views/layouts/saasaparilla.html.haml +9 -0
- data/app/views/saasaparilla/admin/plans/_form.html.haml +45 -0
- data/app/views/saasaparilla/admin/plans/edit.html.erb +4 -0
- data/app/views/saasaparilla/admin/plans/index.html.erb +31 -0
- data/app/views/saasaparilla/admin/plans/new.html.haml +4 -0
- data/app/views/saasaparilla/admin/plans/show.html.haml +20 -0
- data/app/views/saasaparilla/admin/subscriptions/_subscription.html.haml +7 -0
- data/app/views/saasaparilla/admin/subscriptions/index.html.haml +14 -0
- data/app/views/saasaparilla/admin/subscriptions/show.html.haml +52 -0
- data/app/views/saasaparilla/admin/transactions/_transaction.html.haml +6 -0
- data/app/views/saasaparilla/admin/transactions/index.html.haml +16 -0
- data/app/views/saasaparilla/billing_history/_billing_activity.html.haml +10 -0
- data/app/views/saasaparilla/billing_history/show.html.haml +11 -0
- data/app/views/saasaparilla/contact_info/edit.html.haml +8 -0
- data/app/views/saasaparilla/credit_card/edit.html.haml +18 -0
- data/app/views/saasaparilla/invoices/show.html.haml +17 -0
- data/app/views/saasaparilla/notifier/billing_failed.html.haml +5 -0
- data/app/views/saasaparilla/notifier/billing_successful.html.haml +5 -0
- data/app/views/saasaparilla/notifier/invoice_created.html.haml +24 -0
- data/app/views/saasaparilla/notifier/pending_cancellation_notice.html.haml +6 -0
- data/app/views/saasaparilla/notifier/subscription_canceled.html.haml +4 -0
- data/app/views/saasaparilla/notifier/subscription_created.html.haml +5 -0
- data/app/views/saasaparilla/payments/edit.html.haml +10 -0
- data/app/views/saasaparilla/payments/new.html.haml +10 -0
- data/app/views/saasaparilla/payments/show.html.haml +8 -0
- data/app/views/saasaparilla/plans/edit.html.haml +34 -0
- data/app/views/saasaparilla/subscription/_contact_info_form.html.haml +19 -0
- data/app/views/saasaparilla/subscription/_credit_card_form.html.haml +10 -0
- data/app/views/saasaparilla/subscription/new.html.haml +24 -0
- data/app/views/saasaparilla/subscription/show.html.haml +73 -0
- data/autotest/discover.rb +2 -0
- data/config/routes.rb +27 -0
- data/lib/country_select/MIT-LICENSE +20 -0
- data/lib/country_select/README +15 -0
- data/lib/country_select/init.rb +1 -0
- data/lib/country_select/install.rb +2 -0
- data/lib/country_select/lib/country_select.rb +88 -0
- data/lib/country_select/uninstall.rb +1 -0
- data/lib/extensions/action_controller/base.rb +7 -0
- data/lib/extensions/active_record/nested_attributes.rb +36 -0
- data/lib/extensions/active_record/statuses.rb +16 -0
- data/lib/extensions/billable.rb +12 -0
- data/lib/generators/saasaparilla/install/install_generator.rb +29 -0
- data/lib/generators/saasaparilla/install/templates/create_saasaparilla_tables.rb +106 -0
- data/lib/generators/saasaparilla/install/templates/saasaparilla.yml +32 -0
- data/lib/initializers/auth_dot_net.rb +25 -0
- data/lib/initializers/simple_form.rb +77 -0
- data/lib/initializers/time_format.rb +3 -0
- data/lib/saasaparilla.rb +16 -0
- data/lib/saasaparilla/authentication.rb +18 -0
- data/lib/saasaparilla/authorization.rb +26 -0
- data/lib/saasaparilla/engine.rb +30 -0
- data/lib/saasaparilla/version.rb +3 -0
- data/saasaparilla.gemspec +48 -0
- data/spec/.livereload +21 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/model/user.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +46 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/simple_form.rb +77 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/simple_form.en.yml +24 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config/saasaparilla.yml +32 -0
- data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/jquery.js +8374 -0
- data/spec/dummy/public/javascripts/jquery.min.js +16 -0
- data/spec/dummy/public/javascripts/rails.js +159 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/MIT-LICENSE +20 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/README +32 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/Rakefile +23 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/init.rb +1 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/install.rb +1 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/lib/authorize_net_cim_gateway_test.rb +492 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/lib/authorize_net_gateway_test.rb +133 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/lib/paypal_express_gateway_test.rb +138 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/tasks/activemerchant_testing_tasks.rake +4 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/test/activemerchant_testing_test.rb +8 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/test/test_helper.rb +3 -0
- data/spec/dummy/vendor/plugins/active_merchant_testing/uninstall.rb +1 -0
- data/spec/factories/factories.rb +75 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/mailers/notifier_spec.rb +167 -0
- data/spec/models/billing_activity_spec.rb +27 -0
- data/spec/models/contact_info_spec.rb +32 -0
- data/spec/models/credit_card_spec.rb +57 -0
- data/spec/models/invoice_line_item_spec.rb +7 -0
- data/spec/models/invoice_spec.rb +25 -0
- data/spec/models/payment_spec.rb +29 -0
- data/spec/models/plan_spec.rb +16 -0
- data/spec/models/subscription_spec.rb +414 -0
- data/spec/requests/admin_plans_spec.rb +32 -0
- data/spec/requests/admin_subscriptions_spec.rb +31 -0
- data/spec/requests/billing_history_spec.rb +26 -0
- data/spec/requests/contact_info_controller_spec.rb +42 -0
- data/spec/requests/credit_cards_spec.rb +79 -0
- data/spec/requests/invoices_spec.rb +23 -0
- data/spec/requests/payments_spec.rb +89 -0
- data/spec/requests/subscription_plans_spec.rb +34 -0
- data/spec/requests/subscriptions_spec.rb +80 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/spec_helpers/spec_helpers.rb +8 -0
- metadata +611 -0
data/config/routes.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
|
|
3
|
+
scope '/admin', :name_prefix => 'admin' do
|
|
4
|
+
resources :plans, :controller => "saasaparilla/admin/plans"
|
|
5
|
+
resources :subscriptions, :controller => "saasaparilla/admin/subscriptions" do
|
|
6
|
+
get 'cancel', :on => :member
|
|
7
|
+
get 'toggle_no_charge', :on => :member
|
|
8
|
+
resources :transactions, :controller => "saasaparilla/admin/transactions", :only => [:index]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
resource :subscription, :controller => "saasaparilla/subscription" do
|
|
13
|
+
get 'reactivate', :on => :member
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
scope '/subscription', :name_prefix => 'subscription' do
|
|
17
|
+
resources :payments, :controller => "saasaparilla/payments"
|
|
18
|
+
resource :credit_card, :controller => "saasaparilla/credit_card"
|
|
19
|
+
resource :plan, :controller => "saasaparilla/plans", :only => [:edit, :update]
|
|
20
|
+
resource :contact_info, :controller => "saasaparilla/contact_info"
|
|
21
|
+
resource :billing_history, :controller => "saasaparilla/billing_history"
|
|
22
|
+
resources :invoices, :controller => "saasaparilla/invoices"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 Michael Koziarski
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
CountrySelect
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
Provides a simple helper to get an HTML select list of countries. The list of countries comes from the ISO 3166 standard. While it is a relatively neutral source of country names, it will still offend some users.
|
|
5
|
+
|
|
6
|
+
Users are strongly advised to evaluate the suitability of this list given their user base.
|
|
7
|
+
|
|
8
|
+
Example
|
|
9
|
+
=======
|
|
10
|
+
|
|
11
|
+
country_select("user", "country_name")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Copyright (c) 2008 Michael Koziarski, released under the MIT license
|
|
15
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'country_select'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# CountrySelect
|
|
2
|
+
module ActionView
|
|
3
|
+
module Helpers
|
|
4
|
+
module FormOptionsHelper
|
|
5
|
+
# Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
|
|
6
|
+
def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
|
|
7
|
+
InstanceTag.new(object, method, self, options.delete(:object)).to_country_select_tag(priority_countries, options, html_options)
|
|
8
|
+
end
|
|
9
|
+
# Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to
|
|
10
|
+
# have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so
|
|
11
|
+
# that they will be listed above the rest of the (long) list.
|
|
12
|
+
#
|
|
13
|
+
# NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag.
|
|
14
|
+
def country_options_for_select(selected = nil, priority_countries = nil)
|
|
15
|
+
country_options = ""
|
|
16
|
+
|
|
17
|
+
if priority_countries
|
|
18
|
+
country_options += options_for_select(priority_countries, selected)
|
|
19
|
+
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
|
20
|
+
# prevents selected from being included twice in the HTML which causes
|
|
21
|
+
# some browsers to select the second selected option (not priority)
|
|
22
|
+
# which makes it harder to select an alternative priority country
|
|
23
|
+
selected=nil if priority_countries.include?(selected)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
return country_options + options_for_select(COUNTRIES, selected)
|
|
27
|
+
end
|
|
28
|
+
# All the countries included in the country_options output.
|
|
29
|
+
COUNTRIES = ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
|
|
30
|
+
"Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
|
|
31
|
+
"Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
|
|
32
|
+
"Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil",
|
|
33
|
+
"British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia",
|
|
34
|
+
"Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
|
|
35
|
+
"Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
|
|
36
|
+
"Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba",
|
|
37
|
+
"Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt",
|
|
38
|
+
"El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)",
|
|
39
|
+
"Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia",
|
|
40
|
+
"French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea",
|
|
41
|
+
"Guinea-Bissau", "Guyana", "Haiti", "Heard and McDonald Islands", "Holy See (Vatican City State)",
|
|
42
|
+
"Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq",
|
|
43
|
+
"Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya",
|
|
44
|
+
"Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan",
|
|
45
|
+
"Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya",
|
|
46
|
+
"Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, The Former Yugoslav Republic Of",
|
|
47
|
+
"Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique",
|
|
48
|
+
"Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of",
|
|
49
|
+
"Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru",
|
|
50
|
+
"Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger",
|
|
51
|
+
"Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau",
|
|
52
|
+
"Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
|
|
53
|
+
"Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation",
|
|
54
|
+
"Rwanda", "Saint Barthelemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia",
|
|
55
|
+
"Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino",
|
|
56
|
+
"Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore",
|
|
57
|
+
"Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa",
|
|
58
|
+
"South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "Sudan", "Suriname",
|
|
59
|
+
"Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic",
|
|
60
|
+
"Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste",
|
|
61
|
+
"Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
|
|
62
|
+
"Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
|
|
63
|
+
"United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela",
|
|
64
|
+
"Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.", "Wallis and Futuna", "Western Sahara",
|
|
65
|
+
"Yemen", "Zambia", "Zimbabwe"] unless const_defined?("COUNTRIES")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
class InstanceTag
|
|
69
|
+
def to_country_select_tag(priority_countries, options, html_options)
|
|
70
|
+
html_options = html_options.stringify_keys
|
|
71
|
+
add_default_name_and_id(html_options)
|
|
72
|
+
value = value(object)
|
|
73
|
+
content_tag("select",
|
|
74
|
+
add_options(
|
|
75
|
+
country_options_for_select(value, priority_countries),
|
|
76
|
+
options, value
|
|
77
|
+
), html_options
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class FormBuilder
|
|
83
|
+
def country_select(method, priority_countries = nil, options = {}, html_options = {})
|
|
84
|
+
@template.country_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Uninstall hook code here
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class ActiveRecord::Base
|
|
2
|
+
module ClassMethods
|
|
3
|
+
def accepts_nested_attributes_for(*attr_names)
|
|
4
|
+
options = { :allow_destroy => false, :update_only => false }
|
|
5
|
+
options.update(attr_names.extract_options!)
|
|
6
|
+
options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only)
|
|
7
|
+
options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank
|
|
8
|
+
|
|
9
|
+
attr_names.each do |association_name|
|
|
10
|
+
if reflection = reflect_on_association(association_name)
|
|
11
|
+
#Removed autosave association
|
|
12
|
+
#reflection.options[:autosave] = true
|
|
13
|
+
add_autosave_association_callbacks(reflection)
|
|
14
|
+
nested_attributes_options[association_name.to_sym] = options
|
|
15
|
+
type = (reflection.collection? ? :collection : :one_to_one)
|
|
16
|
+
|
|
17
|
+
# def pirate_attributes=(attributes)
|
|
18
|
+
# assign_nested_attributes_for_one_to_one_association(:pirate, attributes)
|
|
19
|
+
# end
|
|
20
|
+
class_eval <<-eoruby, __FILE__, __LINE__ + 1
|
|
21
|
+
if method_defined?(:#{association_name}_attributes=)
|
|
22
|
+
remove_method(:#{association_name}_attributes=)
|
|
23
|
+
end
|
|
24
|
+
def #{association_name}_attributes=(attributes)
|
|
25
|
+
assign_nested_attributes_for_#{type}_association(:#{association_name}, attributes)
|
|
26
|
+
end
|
|
27
|
+
eoruby
|
|
28
|
+
else
|
|
29
|
+
raise ArgumentError, "No association found for name `#{association_name}'. Has it been defined yet?"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
ActiveRecord::Base.extend ActiveRecord::Base::ClassMethods
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class ActiveRecord::Base
|
|
2
|
+
def self.has_statuses(*status_names)
|
|
3
|
+
validates :status, :presence => true, :inclusion => { :in => status_names }
|
|
4
|
+
# Status Finders
|
|
5
|
+
status_names.each do |status_name|
|
|
6
|
+
scope "all_#{status_name}", where(:status => status_name)
|
|
7
|
+
end
|
|
8
|
+
# Status Accessors
|
|
9
|
+
status_names.each do |status_name|
|
|
10
|
+
define_method "#{status_name}?" do
|
|
11
|
+
status == status_name
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Saasaparilla
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
4
|
+
include Rails::Generators::Migration
|
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
6
|
+
desc "add the migrations"
|
|
7
|
+
|
|
8
|
+
def self.next_migration_number(path)
|
|
9
|
+
unless @prev_migration_nr
|
|
10
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
|
11
|
+
else
|
|
12
|
+
@prev_migration_nr += 1
|
|
13
|
+
end
|
|
14
|
+
@prev_migration_nr.to_s
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def copy_migrations
|
|
18
|
+
|
|
19
|
+
migration_template "create_saasaparilla_tables.rb", "db/migrate/create_saasaparilla_tables.rb"
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def copy_config
|
|
24
|
+
copy_file 'saasaparilla.yml', 'config/saasaparilla.yml'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
class CreateSaasaparillaTables < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :subscriptions do |t|
|
|
4
|
+
t.integer :billable_id
|
|
5
|
+
t.string :billable_type
|
|
6
|
+
t.float :balance
|
|
7
|
+
t.string :status
|
|
8
|
+
t.integer :customer_cim_id
|
|
9
|
+
t.integer :customer_payment_profile_id
|
|
10
|
+
t.date :billing_date
|
|
11
|
+
t.date :invoiced_on
|
|
12
|
+
t.date :overdue_on
|
|
13
|
+
t.boolean :no_charge, :default => false
|
|
14
|
+
t.integer :plan_id
|
|
15
|
+
t.integer :downgrade_to_plan_id
|
|
16
|
+
t.timestamps
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
create_table :credit_cards do |t|
|
|
20
|
+
t.string :expiration_date
|
|
21
|
+
t.string :card_number
|
|
22
|
+
t.integer :subscription_id
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
create_table :plans do |t|
|
|
27
|
+
t.string :name
|
|
28
|
+
t.string :billing_period
|
|
29
|
+
t.integer :subscription_id
|
|
30
|
+
t.float :price
|
|
31
|
+
t.text :dynamic_attributes
|
|
32
|
+
t.timestamps
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
create_table :contact_infos do |t|
|
|
36
|
+
t.string :first_name
|
|
37
|
+
t.string :last_name
|
|
38
|
+
t.string :email
|
|
39
|
+
t.string :company
|
|
40
|
+
t.string :address
|
|
41
|
+
t.string :city
|
|
42
|
+
t.string :state
|
|
43
|
+
t.string :zip
|
|
44
|
+
t.string :country
|
|
45
|
+
t.string :phone_number
|
|
46
|
+
|
|
47
|
+
t.integer :subscription_id
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
create_table :billing_activities do |t|
|
|
51
|
+
t.float :amount
|
|
52
|
+
t.string :message
|
|
53
|
+
t.integer :subscription_id
|
|
54
|
+
t.timestamps
|
|
55
|
+
end
|
|
56
|
+
create_table :payments do |t|
|
|
57
|
+
t.float :amount
|
|
58
|
+
t.integer :subscription_id
|
|
59
|
+
t.string :status
|
|
60
|
+
t.timestamps
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
create_table :invoices do |t|
|
|
64
|
+
t.float :total
|
|
65
|
+
t.integer :invoice_number
|
|
66
|
+
t.integer :billing_activity_id
|
|
67
|
+
t.timestamps
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
create_table :invoice_line_items do |t|
|
|
71
|
+
t.string :description
|
|
72
|
+
t.date :from
|
|
73
|
+
t.date :to
|
|
74
|
+
t.float :price
|
|
75
|
+
t.integer :invoice_id
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
create_table :transactions do |t|
|
|
79
|
+
t.string :action
|
|
80
|
+
t.float :amount
|
|
81
|
+
t.boolean :success
|
|
82
|
+
t.string :authorization
|
|
83
|
+
t.string :message
|
|
84
|
+
t.text :params
|
|
85
|
+
t.integer :billing_activity_id
|
|
86
|
+
t.integer :subscription_id
|
|
87
|
+
t.timestamps
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.down
|
|
94
|
+
|
|
95
|
+
drop_table :subscriptions
|
|
96
|
+
drop_table :credit_cards
|
|
97
|
+
drop_table :transactions
|
|
98
|
+
drop_table :contact_infos
|
|
99
|
+
drop_table :plans
|
|
100
|
+
drop_table :payments
|
|
101
|
+
drop_table :invoices
|
|
102
|
+
drop_table :invoice_line_items
|
|
103
|
+
drop_table :billing_activities
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
development:
|
|
2
|
+
grace_period: 10
|
|
3
|
+
from_email: test@dev.com
|
|
4
|
+
trial_period: 0
|
|
5
|
+
auth_dot_net_login: login
|
|
6
|
+
auth_dot_net_password: pass
|
|
7
|
+
include_free_account: false
|
|
8
|
+
authorization: cancan
|
|
9
|
+
require_billing_address: true
|
|
10
|
+
require_phone_number: true
|
|
11
|
+
|
|
12
|
+
test:
|
|
13
|
+
grace_period: 10
|
|
14
|
+
from_email: test@dev.com
|
|
15
|
+
trial_period: 0
|
|
16
|
+
auth_dot_net_login: login
|
|
17
|
+
auth_dot_net_password: pass
|
|
18
|
+
include_free_account: false
|
|
19
|
+
authorization: none
|
|
20
|
+
require_billing_address: true
|
|
21
|
+
require_phone_number: true
|
|
22
|
+
|
|
23
|
+
production:
|
|
24
|
+
grace_period: 10
|
|
25
|
+
from_email: test@dev.com
|
|
26
|
+
trial_period: 0
|
|
27
|
+
auth_dot_net_login: login
|
|
28
|
+
auth_dot_net_password: pass
|
|
29
|
+
include_free_account: false
|
|
30
|
+
authorization: cancan
|
|
31
|
+
require_billing_address: true
|
|
32
|
+
require_phone_number: true
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
if defined? Saasaparilla::CONFIG
|
|
2
|
+
|
|
3
|
+
if Rails.env == "production"
|
|
4
|
+
::GATEWAYCIM = ActiveMerchant::Billing::AuthorizeNetCimGateway.new(
|
|
5
|
+
:login => Saasaparilla::CONFIG["auth_dot_net_login"],
|
|
6
|
+
:password => Saasaparilla::CONFIG["auth_dot_net_password"]
|
|
7
|
+
)
|
|
8
|
+
elsif Rails.env == "test"
|
|
9
|
+
ActiveMerchant::Billing::Base.mode = :test
|
|
10
|
+
::GATEWAYCIM = AuthorizeNetCimGatewayTest.new
|
|
11
|
+
::GATEWAY = AuthorizeNetGatewayTest.new
|
|
12
|
+
::EXPRESSGATEWAY = ActiveMerchant::Billing::BogusGateway.new
|
|
13
|
+
else
|
|
14
|
+
|
|
15
|
+
ActiveMerchant::Billing::Base.mode = :test
|
|
16
|
+
::GATEWAYCIM = ActiveMerchant::Billing::AuthorizeNetCimGateway.new(
|
|
17
|
+
:login => Saasaparilla::CONFIG["auth_dot_net_login"],
|
|
18
|
+
:password => Saasaparilla::CONFIG["auth_dot_net_password"],
|
|
19
|
+
:test => true
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
ActiveMerchant::Billing::Base.gateway_mode = :test
|
|
23
|
+
ActiveMerchant::Billing::Base.integration_mode = :test
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
|
2
|
+
SimpleForm.setup do |config|
|
|
3
|
+
# Components used by the form builder to generate a complete input. You can remove
|
|
4
|
+
# any of them, change the order, or even add your own components to the stack.
|
|
5
|
+
# config.components = [ :placeholder, :label_input, :hint, :error ]
|
|
6
|
+
|
|
7
|
+
# Default tag used on hints.
|
|
8
|
+
# config.hint_tag = :span
|
|
9
|
+
|
|
10
|
+
# CSS class to add to all hint tags.
|
|
11
|
+
# config.hint_class = :hint
|
|
12
|
+
|
|
13
|
+
# Default tag used on errors.
|
|
14
|
+
# config.error_class = :error
|
|
15
|
+
|
|
16
|
+
# Default tag used on errors.
|
|
17
|
+
# config.error_tag = :span
|
|
18
|
+
|
|
19
|
+
# Method used to tidy up errors.
|
|
20
|
+
# config.error_method = :first
|
|
21
|
+
|
|
22
|
+
# Default tag used for error notification helper.
|
|
23
|
+
# config.error_notification_tag = :p
|
|
24
|
+
|
|
25
|
+
# CSS class to add for error notification helper.
|
|
26
|
+
# config.error_notification_class = :error_notification
|
|
27
|
+
|
|
28
|
+
# ID to add for error notification helper.
|
|
29
|
+
# config.error_notification_id = nil
|
|
30
|
+
|
|
31
|
+
# You can wrap all inputs in a pre-defined tag.
|
|
32
|
+
# config.wrapper_tag = :div
|
|
33
|
+
|
|
34
|
+
# CSS class to add to all wrapper tags.
|
|
35
|
+
# config.wrapper_class = :input
|
|
36
|
+
|
|
37
|
+
# CSS class to add to the wrapper if the field has errors.
|
|
38
|
+
# config.wrapper_error_class = :field_with_errors
|
|
39
|
+
|
|
40
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
|
41
|
+
# config.collection_wrapper_tag = nil
|
|
42
|
+
|
|
43
|
+
# You can wrap each item in a collection of radio/check boxes with a tag, defaulting to none.
|
|
44
|
+
# config.item_wrapper_tag = nil
|
|
45
|
+
|
|
46
|
+
# Series of attemps to detect a default label method for collection.
|
|
47
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
|
48
|
+
|
|
49
|
+
# Series of attemps to detect a default value method for collection.
|
|
50
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
|
51
|
+
|
|
52
|
+
# How the label text should be generated altogether with the required text.
|
|
53
|
+
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
|
54
|
+
|
|
55
|
+
# Whether attributes are required by default (or not). Default is true.
|
|
56
|
+
# config.required_by_default = true
|
|
57
|
+
|
|
58
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
|
59
|
+
# to match as key, and the input type that will be used when the field name
|
|
60
|
+
# matches the regexp as value.
|
|
61
|
+
# config.input_mappings = { /count/ => :integer }
|
|
62
|
+
|
|
63
|
+
# Collection of methods to detect if a file type was given.
|
|
64
|
+
# config.file_methods = [ :file?, :public_filename ]
|
|
65
|
+
|
|
66
|
+
# Default priority for time_zone inputs.
|
|
67
|
+
# config.time_zone_priority = nil
|
|
68
|
+
|
|
69
|
+
# Default priority for country inputs.
|
|
70
|
+
config.country_priority = ["United States"]
|
|
71
|
+
|
|
72
|
+
# Default size for text inputs.
|
|
73
|
+
# config.default_input_size = 50
|
|
74
|
+
|
|
75
|
+
# When false, do not use translations for labels, hints or placeholders.
|
|
76
|
+
# config.translate = true
|
|
77
|
+
end
|