jackpot 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/.gitignore +16 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc.example +1 -0
  4. data/.travis.yml +12 -0
  5. data/Gemfile +9 -0
  6. data/Gemfile.lock +181 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +134 -0
  9. data/Rakefile +25 -0
  10. data/app/assets/images/jackpot/.gitkeep +0 -0
  11. data/app/assets/javascripts/jackpot/application.js +5 -0
  12. data/app/assets/javascripts/jackpot/bootstrap.js +32 -0
  13. data/app/assets/javascripts/jackpot/customers.js +2 -0
  14. data/app/assets/javascripts/jackpot/login.js +1 -0
  15. data/app/assets/javascripts/jackpot/payments.js +2 -0
  16. data/app/assets/javascripts/jackpot/subscriptions.js +2 -0
  17. data/app/assets/stylesheets/jackpot/application.css +9 -0
  18. data/app/assets/stylesheets/jackpot/customers.css +4 -0
  19. data/app/assets/stylesheets/jackpot/jackpot.css +10 -0
  20. data/app/controllers/jackpot/application_controller.rb +4 -0
  21. data/app/controllers/jackpot/customers_controller.rb +100 -0
  22. data/app/controllers/jackpot/payments_controller.rb +20 -0
  23. data/app/controllers/jackpot/subscriptions_controller.rb +86 -0
  24. data/app/helpers/jackpot/application_helper.rb +27 -0
  25. data/app/helpers/jackpot/customers_helper.rb +7 -0
  26. data/app/helpers/jackpot/subscriptions_helper.rb +4 -0
  27. data/app/models/jackpot/card.rb +29 -0
  28. data/app/models/jackpot/customer.rb +48 -0
  29. data/app/models/jackpot/gateway.rb +28 -0
  30. data/app/models/jackpot/payment.rb +33 -0
  31. data/app/models/jackpot/subscription.rb +13 -0
  32. data/app/models/jackpot/user.rb +25 -0
  33. data/app/views/jackpot/customers/_credit_card_form.html.erb +42 -0
  34. data/app/views/jackpot/customers/_form.html.erb +17 -0
  35. data/app/views/jackpot/customers/edit.html.erb +13 -0
  36. data/app/views/jackpot/customers/index.html.erb +30 -0
  37. data/app/views/jackpot/customers/new.html.erb +8 -0
  38. data/app/views/jackpot/customers/show.html.erb +32 -0
  39. data/app/views/jackpot/payments/create.html.erb +1 -0
  40. data/app/views/jackpot/payments/index.html.erb +25 -0
  41. data/app/views/jackpot/shared/_flash_messages.html.erb +6 -0
  42. data/app/views/jackpot/shared/_navigation.html.erb +5 -0
  43. data/app/views/jackpot/subscriptions/_form.html.erb +13 -0
  44. data/app/views/jackpot/subscriptions/edit.html.erb +6 -0
  45. data/app/views/jackpot/subscriptions/index.html.erb +29 -0
  46. data/app/views/jackpot/subscriptions/new.html.erb +4 -0
  47. data/app/views/jackpot/subscriptions/show.html.erb +23 -0
  48. data/app/views/layouts/devise.html.erb +22 -0
  49. data/app/views/layouts/jackpot/application.html.erb +39 -0
  50. data/config/initializers/jackpot_devise.rb +226 -0
  51. data/config/locales/devise.en.yml +57 -0
  52. data/config/routes.rb +17 -0
  53. data/db/migrate/20111221002616_create_jackpot_payments.rb +11 -0
  54. data/db/migrate/20111230014003_add_customer_information_to_jackpot_payments.rb +5 -0
  55. data/db/migrate/20120102223341_create_jackpot_subscriptions.rb +10 -0
  56. data/db/migrate/20120103211153_create_jackpot_customers.rb +11 -0
  57. data/db/migrate/20120104164830_add_credit_card_number_to_customer.rb +5 -0
  58. data/db/migrate/20120130173242_add_credit_card_information_to_customers.rb +7 -0
  59. data/db/migrate/20120208191815_add_billing_period_to_jackpot_subscriptions.rb +5 -0
  60. data/db/migrate/20120208191934_add_good_until_date_to_jackpot_customers.rb +6 -0
  61. data/db/migrate/20120209203542_add_subscription_and_customer_to_jackpot_payments.rb +8 -0
  62. data/db/migrate/20120209212043_rename_column_token_in_jackpot_payments.rb +5 -0
  63. data/db/migrate/20120210144038_devise_create_jackpot_users.rb +49 -0
  64. data/jackpot.gemspec +33 -0
  65. data/lib/jackpot.rb +23 -0
  66. data/lib/jackpot/configuration.rb +33 -0
  67. data/lib/jackpot/cron.rb +22 -0
  68. data/lib/jackpot/engine.rb +14 -0
  69. data/lib/jackpot/errors.rb +18 -0
  70. data/lib/jackpot/factory.rb +26 -0
  71. data/lib/jackpot/version.rb +3 -0
  72. data/lib/tasks/jackpot_tasks.rake +38 -0
  73. data/script/rails +6 -0
  74. data/spec/controllers/jackpot/customers_controller_spec.rb +170 -0
  75. data/spec/controllers/jackpot/payments_controller_spec.rb +47 -0
  76. data/spec/controllers/jackpot/subscriptions_controller_spec.rb +153 -0
  77. data/spec/dummy/.gitignore +1 -0
  78. data/spec/dummy/Rakefile +7 -0
  79. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  80. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  81. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  82. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  83. data/spec/dummy/app/mailers/.gitkeep +0 -0
  84. data/spec/dummy/app/models/.gitkeep +0 -0
  85. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  86. data/spec/dummy/config.ru +4 -0
  87. data/spec/dummy/config/application.rb +51 -0
  88. data/spec/dummy/config/boot.rb +10 -0
  89. data/spec/dummy/config/database.yml +17 -0
  90. data/spec/dummy/config/environment.rb +5 -0
  91. data/spec/dummy/config/environments/development.rb +32 -0
  92. data/spec/dummy/config/environments/production.rb +60 -0
  93. data/spec/dummy/config/environments/test.rb +41 -0
  94. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  95. data/spec/dummy/config/initializers/inflections.rb +10 -0
  96. data/spec/dummy/config/initializers/jackpot.rb +13 -0
  97. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  98. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  99. data/spec/dummy/config/initializers/session_store.rb +8 -0
  100. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  101. data/spec/dummy/config/locales/en.yml +5 -0
  102. data/spec/dummy/config/routes.rb +3 -0
  103. data/spec/dummy/db/schema.rb +68 -0
  104. data/spec/dummy/lib/assets/.gitkeep +0 -0
  105. data/spec/dummy/public/404.html +26 -0
  106. data/spec/dummy/public/422.html +26 -0
  107. data/spec/dummy/public/500.html +26 -0
  108. data/spec/dummy/public/favicon.ico +0 -0
  109. data/spec/dummy/public/index.html +5 -0
  110. data/spec/dummy/public/payment.html +36 -0
  111. data/spec/dummy/script/rails +6 -0
  112. data/spec/fixtures/vcr/Create_Customers_To_bill_monthly_my_customers_As_a_user_I_want_to_record_their_billing_information_/assigning_credit_card_information_to_customer.yml +34 -0
  113. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/.yml +34 -0
  114. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_actual_card_number.yml +34 -0
  115. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_NEVER_persist_in_the_database_the_verification_value.yml +34 -0
  116. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_in_the_database_the_ONLY_last_four_digits.yml +34 -0
  117. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_persist_the_card_information.yml +34 -0
  118. data/spec/fixtures/vcr/Jackpot_Customer/_update_credit_card_number/when_card_is_valid/when_persisting/should_store_this_card_at_the_gateway.yml +34 -0
  119. data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/creates_a_new_payment.yml +96 -0
  120. data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/does_not_persist_credit_card_token_information.yml +96 -0
  121. data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_the_payment_transaction_id_for_future_reference.yml +96 -0
  122. data/spec/fixtures/vcr/Jackpot_Payment/_create/with_valid_token_information/records_this_payment_information.yml +96 -0
  123. data/spec/fixtures/vcr/Jackpot_Payment/_customer_name/returns_its_customer_email.yml +96 -0
  124. data/spec/fixtures/vcr/jackpot/customer/updatecard.yml +34 -0
  125. data/spec/fixtures/vcr/jackpot/customer_expiration_date.yml +34 -0
  126. data/spec/fixtures/vcr/jackpot/receiving_payments.yml +96 -0
  127. data/spec/helpers/jackpot/customers_helper_spec.rb +16 -0
  128. data/spec/helpers/jackpot/subscriptions_helper_spec.rb +4 -0
  129. data/spec/lib/cron_spec.rb +39 -0
  130. data/spec/lib/factory_spec.rb +40 -0
  131. data/spec/models/jackpot/card_spec.rb +23 -0
  132. data/spec/models/jackpot/customer_spec.rb +140 -0
  133. data/spec/models/jackpot/gateway_spec.rb +22 -0
  134. data/spec/models/jackpot/payment_spec.rb +74 -0
  135. data/spec/models/jackpot/subscription_spec.rb +19 -0
  136. data/spec/requests/jackpot/jackpot_assign_subscription_to_customer_spec.rb +39 -0
  137. data/spec/requests/jackpot/jackpot_create_customer_spec.rb +73 -0
  138. data/spec/requests/jackpot/jackpot_create_subscriptions_spec.rb +27 -0
  139. data/spec/requests/jackpot/jackpot_receive_payments_spec.rb +34 -0
  140. data/spec/spec_helper.rb +41 -0
  141. data/spec/support/active_merchant.rb +1 -0
  142. data/spec/support/capybara.rb +6 -0
  143. data/spec/support/devise.rb +21 -0
  144. data/spec/support/factories/jackpot_customers.rb +36 -0
  145. data/spec/support/factories/jackpot_payments.rb +7 -0
  146. data/spec/support/factories/jackpot_subscriptions.rb +9 -0
  147. data/spec/support/factories/jackpot_users.rb +9 -0
  148. data/spec/support/helpers.rb +16 -0
  149. data/spec/support/routes.rb +3 -0
  150. data/spec/support/vcr.rb +10 -0
  151. data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings-white.png +0 -0
  152. data/vendor/assets/images/twitter/bootstrap/glyphicons-halflings.png +0 -0
  153. data/vendor/assets/javascripts/twitter/bootstrap.js +12 -0
  154. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alert.js +91 -0
  155. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-button.js +98 -0
  156. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-carousel.js +154 -0
  157. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-collapse.js +136 -0
  158. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js +92 -0
  159. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js +209 -0
  160. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-popover.js +95 -0
  161. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-scrollspy.js +125 -0
  162. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tab.js +130 -0
  163. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-tooltip.js +270 -0
  164. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-transition.js +51 -0
  165. data/vendor/assets/javascripts/twitter/bootstrap/bootstrap-typeahead.js +271 -0
  166. data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap-responsive.css +567 -0
  167. data/vendor/assets/stylesheets/twitter/bootstrap/bootstrap.css.erb +3366 -0
  168. metadata +351 -0
@@ -0,0 +1,16 @@
1
+ doc/
2
+ .yardoc
3
+ .bundle/
4
+ pkg/
5
+ *.sqlite3
6
+ *.log
7
+ .rvmrc
8
+ .rbenv-version
9
+ *.gem
10
+ *.gems
11
+ tmp
12
+ *.sw*
13
+ spec/dummy/log
14
+ spec/dummy/db/*.sqlite3
15
+ spec/dummy/db/migrate
16
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@jackpot --create
@@ -0,0 +1,12 @@
1
+ script: "bundle exec rake -f spec/dummy/Rakefile db:drop jackpot:install:migrations db:create db:migrate db:test:clone; bundle exec rspec spec"
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 1.9.2
6
+ branches:
7
+ only:
8
+ - master
9
+
10
+ notifications:
11
+ irc: "irc.freenode.org#jackpot"
12
+
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ # jquery-rails is used by the dummy application
6
+ gem "jquery-rails"
7
+
8
+ # database
9
+ gem 'mysql2', :platform => :ruby
@@ -0,0 +1,181 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jackpot (0.0.3)
5
+ activemerchant (~> 1.20.1)
6
+ devise (~> 2.0)
7
+ formtastic-bootstrap (~> 1.1)
8
+ rails (~> 3.1)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ actionmailer (3.1.3)
14
+ actionpack (= 3.1.3)
15
+ mail (~> 2.3.0)
16
+ actionpack (3.1.3)
17
+ activemodel (= 3.1.3)
18
+ activesupport (= 3.1.3)
19
+ builder (~> 3.0.0)
20
+ erubis (~> 2.7.0)
21
+ i18n (~> 0.6)
22
+ rack (~> 1.3.5)
23
+ rack-cache (~> 1.1)
24
+ rack-mount (~> 0.8.2)
25
+ rack-test (~> 0.6.1)
26
+ sprockets (~> 2.0.3)
27
+ active_utils (1.0.3)
28
+ activesupport (>= 2.3.11)
29
+ i18n
30
+ activemerchant (1.20.3)
31
+ active_utils (>= 1.0.2)
32
+ activesupport (>= 2.3.11)
33
+ braintree (>= 2.0.0)
34
+ builder (>= 2.0.0)
35
+ i18n
36
+ money (<= 3.7.1)
37
+ activemodel (3.1.3)
38
+ activesupport (= 3.1.3)
39
+ builder (~> 3.0.0)
40
+ i18n (~> 0.6)
41
+ activerecord (3.1.3)
42
+ activemodel (= 3.1.3)
43
+ activesupport (= 3.1.3)
44
+ arel (~> 2.2.1)
45
+ tzinfo (~> 0.3.29)
46
+ activeresource (3.1.3)
47
+ activemodel (= 3.1.3)
48
+ activesupport (= 3.1.3)
49
+ activesupport (3.1.3)
50
+ multi_json (~> 1.0)
51
+ arel (2.2.1)
52
+ bcrypt-ruby (3.0.1)
53
+ braintree (2.13.4)
54
+ builder (>= 2.0.0)
55
+ builder (3.0.0)
56
+ capybara (1.1.2)
57
+ mime-types (>= 1.16)
58
+ nokogiri (>= 1.3.3)
59
+ rack (>= 1.0.0)
60
+ rack-test (>= 0.5.4)
61
+ selenium-webdriver (~> 2.0)
62
+ xpath (~> 0.1.4)
63
+ childprocess (0.3.1)
64
+ ffi (~> 1.0.6)
65
+ database_cleaner (0.7.1)
66
+ devise (2.0.2)
67
+ bcrypt-ruby (~> 3.0)
68
+ orm_adapter (~> 0.0.3)
69
+ railties (~> 3.1)
70
+ warden (~> 1.1)
71
+ diff-lcs (1.1.3)
72
+ erubis (2.7.0)
73
+ factory_girl (2.5.2)
74
+ activesupport (>= 2.3.9)
75
+ factory_girl_rails (1.6.0)
76
+ factory_girl (~> 2.5.0)
77
+ railties (>= 3.0.0)
78
+ fakeweb (1.3.0)
79
+ ffi (1.0.11)
80
+ formtastic (2.0.2)
81
+ rails (~> 3.0)
82
+ formtastic-bootstrap (1.2.0)
83
+ formtastic
84
+ rails (~> 3.1.0)
85
+ hike (1.2.1)
86
+ i18n (0.6.0)
87
+ jquery-rails (1.0.19)
88
+ railties (~> 3.0)
89
+ thor (~> 0.14)
90
+ json (1.6.5)
91
+ mail (2.3.0)
92
+ i18n (>= 0.4.0)
93
+ mime-types (~> 1.16)
94
+ treetop (~> 1.4.8)
95
+ mime-types (1.17.2)
96
+ money (3.7.1)
97
+ i18n (~> 0.4)
98
+ multi_json (1.0.4)
99
+ mysql2 (0.3.11)
100
+ nokogiri (1.5.0)
101
+ orm_adapter (0.0.6)
102
+ polyglot (0.3.3)
103
+ rack (1.3.6)
104
+ rack-cache (1.1)
105
+ rack (>= 0.4)
106
+ rack-mount (0.8.3)
107
+ rack (>= 1.0.0)
108
+ rack-ssl (1.3.2)
109
+ rack
110
+ rack-test (0.6.1)
111
+ rack (>= 1.0)
112
+ rails (3.1.3)
113
+ actionmailer (= 3.1.3)
114
+ actionpack (= 3.1.3)
115
+ activerecord (= 3.1.3)
116
+ activeresource (= 3.1.3)
117
+ activesupport (= 3.1.3)
118
+ bundler (~> 1.0)
119
+ railties (= 3.1.3)
120
+ railties (3.1.3)
121
+ actionpack (= 3.1.3)
122
+ activesupport (= 3.1.3)
123
+ rack-ssl (~> 1.3.2)
124
+ rake (>= 0.8.7)
125
+ rdoc (~> 3.4)
126
+ thor (~> 0.14.6)
127
+ rake (0.9.2.2)
128
+ rdoc (3.12)
129
+ json (~> 1.4)
130
+ rspec (2.8.0)
131
+ rspec-core (~> 2.8.0)
132
+ rspec-expectations (~> 2.8.0)
133
+ rspec-mocks (~> 2.8.0)
134
+ rspec-core (2.8.0)
135
+ rspec-expectations (2.8.0)
136
+ diff-lcs (~> 1.1.2)
137
+ rspec-mocks (2.8.0)
138
+ rspec-rails (2.8.1)
139
+ actionpack (>= 3.0)
140
+ activesupport (>= 3.0)
141
+ railties (>= 3.0)
142
+ rspec (~> 2.8.0)
143
+ rubyzip (0.9.6.1)
144
+ selenium-webdriver (2.19.0)
145
+ childprocess (>= 0.2.5)
146
+ ffi (~> 1.0.9)
147
+ multi_json (~> 1.0.4)
148
+ rubyzip
149
+ shoulda-matchers (1.0.0)
150
+ sprockets (2.0.3)
151
+ hike (~> 1.2)
152
+ rack (~> 1.0)
153
+ tilt (~> 1.1, != 1.3.0)
154
+ thor (0.14.6)
155
+ tilt (1.3.3)
156
+ timecop (0.3.5)
157
+ treetop (1.4.10)
158
+ polyglot
159
+ polyglot (>= 0.3.1)
160
+ tzinfo (0.3.31)
161
+ vcr (2.0.0.rc1)
162
+ warden (1.1.0)
163
+ rack (>= 1.0)
164
+ xpath (0.1.4)
165
+ nokogiri (~> 1.3)
166
+
167
+ PLATFORMS
168
+ ruby
169
+
170
+ DEPENDENCIES
171
+ capybara (~> 1.1)
172
+ database_cleaner (~> 0.7)
173
+ factory_girl_rails (~> 1.6.0)
174
+ fakeweb
175
+ jackpot!
176
+ jquery-rails
177
+ mysql2
178
+ rspec-rails (~> 2.8)
179
+ shoulda-matchers (~> 1.0.0)
180
+ timecop (~> 0.3)
181
+ vcr (~> 2.0.0.rc1)
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
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,134 @@
1
+ Jackpot
2
+ ==========
3
+
4
+ # WORK IN PROGRESS
5
+
6
+ [![Build Status](https://secure.travis-ci.org/pellegrino/jackpot.png)](http://travis-ci.org/pellegrino/jackpot)
7
+
8
+ _WORK IN PROGRESS_
9
+
10
+ Jackpot is the easiest way to get paid using ruby. It abstracts all the nasty details about billing that every Saas app have to deal with. It uses [Active Merchant](https://github.com/Shopify/active_merchant) internally, so Jackpot will suport the gateways (that support credit card storage) provided by Active Merchant, making it easier to extend to your own needs.
11
+ It is built using Rails Engines so it is easy to mount Jackpot in our rails 3.1 or 3.2 app and start using it to do your billing.
12
+
13
+ It started out as my may 2011 session @ [Mendicant University](http://mendicantuniversity.org) project and now its going through a major overhaul to get ready to hit its primetime.
14
+
15
+ ## Installation
16
+
17
+ 1. Add jackpot to your Gemfile as you normally would do with any bundler powered gem. You might also have to add jquery-rails as it is used extensively at jackpot.
18
+
19
+ gem 'jackpot'
20
+ gem 'jquery-rails'
21
+
22
+ 1. Create an initializer to configure your gateway information. Heres an example of how to do it
23
+
24
+ Jackpot.configure do |c|
25
+ if Rails.env.production? or Rails.env.staging?
26
+ c.gateway_type :braintree
27
+ c.gateway_login ENV['JACKPOT_LOGIN']
28
+ c.gateway_password ENV['JACKPOT_PASSWORD']
29
+ c.gateway_mode :test
30
+ else
31
+ c.gateway_type :braintree
32
+ c.gateway_login 'login'
33
+ c.gateway_password 'demo'
34
+ c.gateway_mode :test
35
+ end
36
+ end
37
+
38
+ 1. You should copy jackpot migrations to your project by issuing the following command
39
+
40
+ bundle exec rake jackpot:install:migrations
41
+
42
+ 1. Mount jackpot engine at your config/routes
43
+
44
+ mount Jackpot::Engine => "/billing"
45
+
46
+ After these steps, everything should be working. Don't forget to run your migrations so your database its updated
47
+
48
+ ## How it works
49
+
50
+ ### Recurring Payments
51
+
52
+ Even though some gateways will provide you a recurring payment option, normally it isn't a fire and forget process as you'ld normally imagine. Also, its needed to have information about when this payments actually did happen so you can send invoices accordingly. That being said, in Jackpot we opt to use Gateways that support credit card storage, instead of relying on Gateway Recurring payments.
53
+
54
+ The main goal of this project is to provide billing to rails apps via a rails-engine.
55
+
56
+ ### List of supported gateways
57
+
58
+ Currently, only a small set of gateways is supported, however, it should be fairly simple to integrate any Active Merchant powered gateway that supports card storage
59
+
60
+ * Braintree
61
+ * Bogus (for testing)
62
+
63
+ ### Cron job for Nightly billing
64
+
65
+ You might also want to setup a cron job for running your billing periodically task. There is a jackpot:cron rake task provided. Edit your cron or similar to run that rake task as much as you want to.
66
+
67
+ This task will bill automatically every customer that is currently overdue using his/hers saved credit card token information.
68
+
69
+
70
+ ### Authentication
71
+
72
+ Jackpot uses devise internally to protect its controllers.
73
+
74
+ You need to setup default url options for each environment you use. Heres an example for development environment.
75
+
76
+ # in config/environments/development.rb
77
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
78
+ ## Docs
79
+
80
+ This project uses YARD and the current can always be found at [http://rubydoc.info/github/pellegrino/jackpot](http://rubydoc.info/github/pellegrino/jackpot)
81
+
82
+ ## Contributing to jackpot
83
+
84
+ ### How to run jackpot locally
85
+ This application uses bundler and rvm for dependencies management, so its
86
+ recommended to create a gemset to test it.
87
+
88
+ Run the following commands at the directory where you've checked out
89
+ jackpot.
90
+
91
+ rvm use 1.9.3@jackpot --create
92
+ gem install bundler
93
+ bundle install
94
+
95
+ ### Migrations and RSpec
96
+
97
+ Since this project is basically a Rails Engine, some additional steps are required to run the spec suite locally. Its a pretty straightfoward process, don't worry much about it.
98
+
99
+ Before running the specs for the first time, or after adding a new migration, make sure to run the following command
100
+
101
+ bundle exec rake -f spec/dummy/Rakefile db:drop jackpot:install:migrations db:create db:migrate db:test:prepare
102
+
103
+ That will create and initialize the database for you. The dataase.yml file used is the one located at spec/dummy/config/database.yml. If you changed something that did require a migration to be created, make sure you've copied that one to spec/dummy/db/migrate folder.
104
+
105
+ bundle exec rake -f spec/dummy/Rakefile jackpot:install:migrations
106
+
107
+ The command above will copy every migration you created at Jackpot to the dummy app folder. Also, make sure to run the database initializer command above or your changes won't be reflected.
108
+
109
+
110
+ ### Rails development Server
111
+
112
+ If you ran the migrations correctly, you can start the dummy app as you normally would start a regular Rails 3.x app.
113
+
114
+ bundle exec rails server
115
+
116
+
117
+ ### General advice
118
+
119
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
120
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
121
+ * Fork the project
122
+ * Start a feature/bugfix branch
123
+ * Commit and push until you are happy with your contribution
124
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
125
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
126
+
127
+ ### Get in contact!
128
+
129
+ There is a #jackpot channel @ freenode for this project. Feel free to stop by to ask questions and interact with other users. My IRC username is _pellegrino_ and i'm happy to help.
130
+
131
+ ## Copyright
132
+
133
+ Copyright (c) 2011-2012 Vitor Pellegrino. See LICENSE.txt forfurther details.
134
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+ load 'lib/tasks/jackpot_tasks.rake'
10
+ load 'rails/tasks/engine.rake'
11
+ require 'rspec/core/rake_task'
12
+
13
+ RSpec::Core::RakeTask.new(:spec)
14
+ task :default => :spec
15
+
16
+ Bundler::GemHelper.install_tasks
17
+
18
+
19
+ namespace :jackpot do
20
+ desc "Run billing cron job"
21
+ task :cron => :environment do
22
+ cron = Jackpot::Cron.new(Jackpot::Customer, Rails.logger)
23
+ cron.run
24
+ end
25
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ //= require jquery
2
+ //= require jquery-ui
3
+ //= require jquery_ujs
4
+ //= require twitter/bootstrap
5
+ //= require jackpot/bootstrap
@@ -0,0 +1,32 @@
1
+ $(function() {
2
+ return $("body > .topbar").scrollSpy();
3
+ });
4
+ $(function() {
5
+ return $(".tabs").tabs();
6
+ });
7
+ $(function() {
8
+ return $("a[rel=twipsy]").twipsy({
9
+ live: true
10
+ });
11
+ });
12
+ $(function() {
13
+ return $("a[rel=popover]").popover({
14
+ offset: 10
15
+ });
16
+ });
17
+ $(function() {
18
+ return $(".topbar-wrapper").dropdown();
19
+ });
20
+ $(function() {
21
+ return $(".alert-message").alert();
22
+ });
23
+ $(function() {
24
+ var domModal;
25
+ domModal = $(".modal").modal({
26
+ backdrop: true,
27
+ closeOnEscape: true
28
+ });
29
+ return $(".open-modal").click(function() {
30
+ return domModal.toggle();
31
+ });
32
+ });