paymill_on_rails 0.0.1

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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/javascripts/paymill_on_rails/application.js +13 -0
  6. data/app/assets/javascripts/paymill_on_rails/plans.js +2 -0
  7. data/app/assets/javascripts/paymill_on_rails/subscriptions.js +2 -0
  8. data/app/assets/stylesheets/paymill_on_rails/application.css +13 -0
  9. data/app/assets/stylesheets/paymill_on_rails/plans.css +4 -0
  10. data/app/assets/stylesheets/paymill_on_rails/subscriptions.css +4 -0
  11. data/app/assets/stylesheets/scaffold.css +56 -0
  12. data/app/controllers/paymill_on_rails/application_controller.rb +4 -0
  13. data/app/controllers/paymill_on_rails/plans_controller.rb +63 -0
  14. data/app/controllers/paymill_on_rails/subscriptions_controller.rb +70 -0
  15. data/app/helpers/paymill_on_rails/application_helper.rb +4 -0
  16. data/app/helpers/paymill_on_rails/plans_helper.rb +4 -0
  17. data/app/helpers/paymill_on_rails/subscriptions_helper.rb +4 -0
  18. data/app/models/paymill_on_rails/plan.rb +9 -0
  19. data/app/models/paymill_on_rails/subscription.rb +25 -0
  20. data/app/views/layouts/paymill_on_rails/application.html.erb +115 -0
  21. data/app/views/paymill_on_rails/plans/_form.html.erb +29 -0
  22. data/app/views/paymill_on_rails/plans/edit.html.erb +6 -0
  23. data/app/views/paymill_on_rails/plans/index.html.erb +41 -0
  24. data/app/views/paymill_on_rails/plans/new.html.erb +5 -0
  25. data/app/views/paymill_on_rails/plans/show.html.erb +28 -0
  26. data/app/views/paymill_on_rails/subscriptions/_form.html.erb +17 -0
  27. data/app/views/paymill_on_rails/subscriptions/edit.html.erb +6 -0
  28. data/app/views/paymill_on_rails/subscriptions/index.html.erb +25 -0
  29. data/app/views/paymill_on_rails/subscriptions/new.html.erb +52 -0
  30. data/app/views/paymill_on_rails/subscriptions/show.html.erb +6 -0
  31. data/config/initializers/paymill.rb +5 -0
  32. data/config/routes.rb +7 -0
  33. data/db/migrate/20131111122533_create_paymill_on_rails_plans.rb +12 -0
  34. data/db/migrate/20131111132308_create_paymill_on_rails_subscriptions.rb +13 -0
  35. data/lib/paymill_on_rails.rb +4 -0
  36. data/lib/paymill_on_rails/engine.rb +7 -0
  37. data/lib/paymill_on_rails/version.rb +3 -0
  38. data/lib/tasks/paymill_on_rails.rake +20 -0
  39. data/test/controllers/paymill_on_rails/plans_controller_test.rb +51 -0
  40. data/test/controllers/paymill_on_rails/subscriptions_controller_test.rb +51 -0
  41. data/test/dummy/README.rdoc +28 -0
  42. data/test/dummy/Rakefile +6 -0
  43. data/test/dummy/app/assets/javascripts/application.js +13 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  45. data/test/dummy/app/controllers/application_controller.rb +5 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  48. data/test/dummy/bin/bundle +3 -0
  49. data/test/dummy/bin/rails +4 -0
  50. data/test/dummy/bin/rake +4 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/config/application.rb +23 -0
  53. data/test/dummy/config/boot.rb +5 -0
  54. data/test/dummy/config/database.yml +25 -0
  55. data/test/dummy/config/environment.rb +5 -0
  56. data/test/dummy/config/environments/development.rb +29 -0
  57. data/test/dummy/config/environments/production.rb +80 -0
  58. data/test/dummy/config/environments/test.rb +36 -0
  59. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  61. data/test/dummy/config/initializers/inflections.rb +16 -0
  62. data/test/dummy/config/initializers/mime_types.rb +5 -0
  63. data/test/dummy/config/initializers/secret_token.rb +12 -0
  64. data/test/dummy/config/initializers/session_store.rb +3 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +23 -0
  67. data/test/dummy/config/routes.rb +4 -0
  68. data/test/dummy/db/migrate/20131111135531_create_paymill_on_rails_plans.paymill_on_rails.rb +9 -0
  69. data/test/dummy/db/migrate/20131111135532_create_paymill_on_rails_subscriptions.paymill_on_rails.rb +9 -0
  70. data/test/dummy/public/404.html +58 -0
  71. data/test/dummy/public/422.html +58 -0
  72. data/test/dummy/public/500.html +57 -0
  73. data/test/dummy/public/favicon.ico +0 -0
  74. data/test/fixtures/paymill_on_rails/plans.yml +11 -0
  75. data/test/fixtures/paymill_on_rails/subscriptions.yml +11 -0
  76. data/test/helpers/paymill_on_rails/plans_helper_test.rb +6 -0
  77. data/test/helpers/paymill_on_rails/subscriptions_helper_test.rb +6 -0
  78. data/test/integration/navigation_test.rb +10 -0
  79. data/test/models/paymill_on_rails/plan_test.rb +9 -0
  80. data/test/models/paymill_on_rails/subscription_test.rb +9 -0
  81. data/test/paymill_on_rails_test.rb +7 -0
  82. data/test/test_helper.rb +15 -0
  83. 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,6 @@
1
+ <h1>Editing plan</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @plan %> |
6
+ <%= link_to 'Back', plans_path %>
@@ -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,5 @@
1
+ <h1>New plan</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', plans_path %>
@@ -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,6 @@
1
+ <h1>Editing subscription</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @subscription %> |
6
+ <%= link_to 'Back', subscriptions_path %>
@@ -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
+
@@ -0,0 +1,6 @@
1
+
2
+ <div id="subscription">
3
+ <h1>Your Subscription</h1>
4
+ <p>You have signed up for the <strong><%= @subscription.plan.name %></strong> plan </strong> for just <strong><%= number_to_currency @subscription.plan.price, currency: "€" %></strong> per month!</p>
5
+ </div>
6
+
@@ -0,0 +1,5 @@
1
+
2
+ Paymill.api_key = ENV['API_KEY']
3
+ PAYMILL_PUBLIC_KEY = ENV['PAYMILL_PUBLIC_KEY']
4
+
5
+
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ PaymillOnRails::Engine.routes.draw do
2
+
3
+ root to: 'plans#index'
4
+ resources :subscriptions
5
+ resources :plans
6
+
7
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePaymillOnRailsPlans < ActiveRecord::Migration
2
+ def change
3
+ create_table :paymill_on_rails_plans do |t|
4
+
5
+ t.string :name
6
+ t.string :price
7
+ t.string :paymill_id
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreatePaymillOnRailsSubscriptions < ActiveRecord::Migration
2
+ def change
3
+ create_table :paymill_on_rails_subscriptions do |t|
4
+
5
+ t.string :name
6
+ t.string :email
7
+ t.integer :plan_id
8
+ t.string :paymill_id
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ require "paymill_on_rails/engine"
2
+
3
+ module PaymillOnRails
4
+ end
@@ -0,0 +1,7 @@
1
+ require "paymill"
2
+
3
+ module PaymillOnRails
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace PaymillOnRails
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module PaymillOnRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -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>.