paymill_on_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/paymill_on_rails/application.js +13 -0
- data/app/assets/javascripts/paymill_on_rails/plans.js +2 -0
- data/app/assets/javascripts/paymill_on_rails/subscriptions.js +2 -0
- data/app/assets/stylesheets/paymill_on_rails/application.css +13 -0
- data/app/assets/stylesheets/paymill_on_rails/plans.css +4 -0
- data/app/assets/stylesheets/paymill_on_rails/subscriptions.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/paymill_on_rails/application_controller.rb +4 -0
- data/app/controllers/paymill_on_rails/plans_controller.rb +63 -0
- data/app/controllers/paymill_on_rails/subscriptions_controller.rb +70 -0
- data/app/helpers/paymill_on_rails/application_helper.rb +4 -0
- data/app/helpers/paymill_on_rails/plans_helper.rb +4 -0
- data/app/helpers/paymill_on_rails/subscriptions_helper.rb +4 -0
- data/app/models/paymill_on_rails/plan.rb +9 -0
- data/app/models/paymill_on_rails/subscription.rb +25 -0
- data/app/views/layouts/paymill_on_rails/application.html.erb +115 -0
- data/app/views/paymill_on_rails/plans/_form.html.erb +29 -0
- data/app/views/paymill_on_rails/plans/edit.html.erb +6 -0
- data/app/views/paymill_on_rails/plans/index.html.erb +41 -0
- data/app/views/paymill_on_rails/plans/new.html.erb +5 -0
- data/app/views/paymill_on_rails/plans/show.html.erb +28 -0
- data/app/views/paymill_on_rails/subscriptions/_form.html.erb +17 -0
- data/app/views/paymill_on_rails/subscriptions/edit.html.erb +6 -0
- data/app/views/paymill_on_rails/subscriptions/index.html.erb +25 -0
- data/app/views/paymill_on_rails/subscriptions/new.html.erb +52 -0
- data/app/views/paymill_on_rails/subscriptions/show.html.erb +6 -0
- data/config/initializers/paymill.rb +5 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20131111122533_create_paymill_on_rails_plans.rb +12 -0
- data/db/migrate/20131111132308_create_paymill_on_rails_subscriptions.rb +13 -0
- data/lib/paymill_on_rails.rb +4 -0
- data/lib/paymill_on_rails/engine.rb +7 -0
- data/lib/paymill_on_rails/version.rb +3 -0
- data/lib/tasks/paymill_on_rails.rake +20 -0
- data/test/controllers/paymill_on_rails/plans_controller_test.rb +51 -0
- data/test/controllers/paymill_on_rails/subscriptions_controller_test.rb +51 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/migrate/20131111135531_create_paymill_on_rails_plans.paymill_on_rails.rb +9 -0
- data/test/dummy/db/migrate/20131111135532_create_paymill_on_rails_subscriptions.paymill_on_rails.rb +9 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/paymill_on_rails/plans.yml +11 -0
- data/test/fixtures/paymill_on_rails/subscriptions.yml +11 -0
- data/test/helpers/paymill_on_rails/plans_helper_test.rb +6 -0
- data/test/helpers/paymill_on_rails/subscriptions_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/paymill_on_rails/plan_test.rb +9 -0
- data/test/models/paymill_on_rails/subscription_test.rb +9 -0
- data/test/paymill_on_rails_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +211 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
<%= form_for @plan, :html => { :class => 'form-horizontal' } do |f| %>
|
4
|
+
<div class="control-group">
|
5
|
+
<%= f.label :paymill_id, :class => 'control-label' %>
|
6
|
+
<div class="controls">
|
7
|
+
<%= f.text_field :paymill_id, :class => 'text_field' %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="control-group">
|
11
|
+
<%= f.label :name, :class => 'control-label' %>
|
12
|
+
<div class="controls">
|
13
|
+
<%= f.text_field :name, :class => 'text_field' %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="control-group">
|
17
|
+
<%= f.label :price, :class => 'control-label' %>
|
18
|
+
<div class="controls">
|
19
|
+
<%= f.text_field :price, :class => 'text_field' %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="form-actions">
|
24
|
+
<%= f.submit nil, :class => 'btn btn-primary' %>
|
25
|
+
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
|
26
|
+
plans_path, :class => 'btn' %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
<div class="jumbotron">
|
3
|
+
<h1>Awesome Plans</h1> <br> <br>
|
4
|
+
<div class="row">
|
5
|
+
<% @plans.each do |plan| %>
|
6
|
+
<div class="span2">
|
7
|
+
<div class="lead">
|
8
|
+
<div class="name"><%= plan.name %></div>
|
9
|
+
<div class="price">
|
10
|
+
<%= number_to_currency plan.price, unit: "€" %>
|
11
|
+
</div>
|
12
|
+
<div class="per_week">per week</div>
|
13
|
+
<div class="signup">
|
14
|
+
<%= link_to "Sign up", new_subscription_path(:plan_id => plan.id), :class => 'btn btn-primary' %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<div class="hero-unit">
|
23
|
+
<h3>In order to perform test payments, simply use the following credit card numbers:</h3>
|
24
|
+
<p class="lead">
|
25
|
+
Please be sure to always enter a future date for the credit card date, or an error will be displayed when using the credit card numbers in live mode.
|
26
|
+
</p>
|
27
|
+
<table class="table table-striped">
|
28
|
+
<tbody>
|
29
|
+
<tr>
|
30
|
+
<td>Visa:</td>
|
31
|
+
<td>4111111111111111</td>
|
32
|
+
</tr>
|
33
|
+
<tr>
|
34
|
+
<td>Mastercard:</td>
|
35
|
+
<td>5500000000000004</td>
|
36
|
+
</tr>
|
37
|
+
</tbody>
|
38
|
+
</table>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
<%- model_class = Plan -%>
|
3
|
+
<div class="page-header">
|
4
|
+
<h1><%=t '.title', :default => model_class.model_name.human %></h1>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<dl class="dl-horizontal">
|
8
|
+
<dt><strong><%= model_class.human_attribute_name(:paymill_id) %>:</strong></dt>
|
9
|
+
<dd><%= @plan.paymill_id %></dd>
|
10
|
+
<dt><strong><%= model_class.human_attribute_name(:name) %>:</strong></dt>
|
11
|
+
<dd><%= @plan.name %></dd>
|
12
|
+
<dt><strong><%= model_class.human_attribute_name(:price) %>:</strong></dt>
|
13
|
+
<dd><%= @plan.price %></dd>
|
14
|
+
</dl>
|
15
|
+
|
16
|
+
<div class="form-actions">
|
17
|
+
<%= link_to t('.back', :default => t("helpers.links.back")),
|
18
|
+
plans_path, :class => 'btn' %>
|
19
|
+
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
20
|
+
edit_plan_path(@plan), :class => 'btn' %>
|
21
|
+
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
22
|
+
plan_path(@plan),
|
23
|
+
:method => 'delete',
|
24
|
+
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
25
|
+
:class => 'btn btn-danger' %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= form_for(@subscription) do |f| %>
|
2
|
+
<% if @subscription.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@subscription.errors.count, "error") %> prohibited this subscription from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @subscription.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="actions">
|
15
|
+
<%= f.submit %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h1>Listing subscriptions</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<th></th>
|
7
|
+
<th></th>
|
8
|
+
<th></th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
|
12
|
+
<tbody>
|
13
|
+
<% @subscriptions.each do |subscription| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link_to 'Show', subscription %></td>
|
16
|
+
<td><%= link_to 'Edit', edit_subscription_path(subscription) %></td>
|
17
|
+
<td><%= link_to 'Destroy', subscription, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<%= link_to 'New Subscription', new_subscription_path %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<h1>Signing up for "<%= @subscription.plan.name %>"</h1>
|
2
|
+
<p>It's only <strong><%= number_to_currency @subscription.plan.price, unit: "€" %></strong> per month!</p>
|
3
|
+
|
4
|
+
<%= form_for @subscription do |f| %>
|
5
|
+
<% if @subscription.errors.any? %>
|
6
|
+
<div class="error_messages">
|
7
|
+
<h2><%= pluralize(@subscription.errors.count, "error") %> prohibited this subscription from being saved:</h2>
|
8
|
+
<ul>
|
9
|
+
<% @subscription.errors.full_messages.each do |msg| %>
|
10
|
+
<li><%= msg %></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= f.hidden_field :plan_id %>
|
17
|
+
|
18
|
+
<%= f.hidden_field :paymill_card_token %>
|
19
|
+
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :name %>
|
22
|
+
<%= f.text_field :name %>
|
23
|
+
</div>
|
24
|
+
<div class="field">
|
25
|
+
<%= f.label :email %>
|
26
|
+
<%= f.text_field :email %>
|
27
|
+
</div>
|
28
|
+
<% if @subscription.paymill_card_token.present? %>
|
29
|
+
Credit card has been provided.
|
30
|
+
<% else %>
|
31
|
+
<div class="field">
|
32
|
+
<%= label_tag :card_number, "Credit Card Number" %>
|
33
|
+
<%= text_field_tag :card_number, nil, name: nil %>
|
34
|
+
</div>
|
35
|
+
<div class="field">
|
36
|
+
<%= label_tag :card_code, "Security Code on Card (CVV)" %>
|
37
|
+
<%= text_field_tag :card_code, nil, name: nil %>
|
38
|
+
</div>
|
39
|
+
<div class="field">
|
40
|
+
<%= label_tag :card_month, "Card Expiration" %>
|
41
|
+
<%= select_month nil, {add_month_numbers: true}, {name: nil, id: "card_month"} %>
|
42
|
+
<%= select_year nil, {start_year: Date.today.year, end_year: Date.today.year+15}, {name: nil, id: "card_year"} %>
|
43
|
+
</div>
|
44
|
+
<% end %>
|
45
|
+
<div id="paymill_error">
|
46
|
+
<noscript>JavaScript is not enabled and is required for this form. First enable it in your web browser settings.</noscript>
|
47
|
+
</div>
|
48
|
+
<div class="actions">
|
49
|
+
<%= f.submit "Subscribe" %>
|
50
|
+
</div>
|
51
|
+
<% end %>
|
52
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :paymill_on_rails do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
5
|
+
|
6
|
+
require 'paymill'
|
7
|
+
|
8
|
+
namespace :paymill_on_rails do
|
9
|
+
desc "Import all subscription plans (Offers) from paymill"
|
10
|
+
task :import_plans => :environment do
|
11
|
+
|
12
|
+
PaymillOnRails::Plan.destroy_all
|
13
|
+
|
14
|
+
offers = Paymill::Offer.all
|
15
|
+
offers.each do |offer|
|
16
|
+
PaymillOnRails::Plan.create paymill_id: offer.id, name: offer.name, price: offer.amount / 100.0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module PaymillOnRails
|
4
|
+
class PlansControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@plan = plans(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get index" do
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert_not_nil assigns(:plans)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get new" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should create plan" do
|
21
|
+
assert_difference('Plan.count') do
|
22
|
+
post :create, plan: { }
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to plan_path(assigns(:plan))
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should show plan" do
|
29
|
+
get :show, id: @plan
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should get edit" do
|
34
|
+
get :edit, id: @plan
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should update plan" do
|
39
|
+
patch :update, id: @plan, plan: { }
|
40
|
+
assert_redirected_to plan_path(assigns(:plan))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should destroy plan" do
|
44
|
+
assert_difference('Plan.count', -1) do
|
45
|
+
delete :destroy, id: @plan
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_redirected_to plans_path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module PaymillOnRails
|
4
|
+
class SubscriptionsControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@subscription = subscriptions(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get index" do
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert_not_nil assigns(:subscriptions)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get new" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should create subscription" do
|
21
|
+
assert_difference('Subscription.count') do
|
22
|
+
post :create, subscription: { }
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to subscription_path(assigns(:subscription))
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should show subscription" do
|
29
|
+
get :show, id: @subscription
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should get edit" do
|
34
|
+
get :edit, id: @subscription
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should update subscription" do
|
39
|
+
patch :update, id: @subscription, subscription: { }
|
40
|
+
assert_redirected_to subscription_path(assigns(:subscription))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should destroy subscription" do
|
44
|
+
assert_difference('Subscription.count', -1) do
|
45
|
+
delete :destroy, id: @subscription
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_redirected_to subscriptions_path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|