tb_checkout 1.0.3

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 (122) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +162 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/images/tb_checkout/admin/shopping_carts.png +0 -0
  6. data/app/assets/images/tb_checkout/admin/transactions.png +0 -0
  7. data/app/assets/javascripts/tb_checkout/admin/carts.js +2 -0
  8. data/app/assets/javascripts/tb_checkout/admin/transactions.js +2 -0
  9. data/app/assets/javascripts/tb_checkout/application.js +13 -0
  10. data/app/assets/javascripts/tb_checkout/cart_items.js +2 -0
  11. data/app/assets/javascripts/tb_checkout/carts.js +2 -0
  12. data/app/assets/javascripts/tb_checkout/transactions.js +2 -0
  13. data/app/assets/stylesheets/tb_checkout/admin/carts.css +4 -0
  14. data/app/assets/stylesheets/tb_checkout/admin/transactions.css +4 -0
  15. data/app/assets/stylesheets/tb_checkout/application.css +15 -0
  16. data/app/assets/stylesheets/tb_checkout/cart_items.css +4 -0
  17. data/app/assets/stylesheets/tb_checkout/carts.css +4 -0
  18. data/app/assets/stylesheets/tb_checkout/transactions.css +4 -0
  19. data/app/controllers/concerns/tb_checkout/controller_helpers.rb +16 -0
  20. data/app/controllers/tb_checkout/admin/carts_controller.rb +39 -0
  21. data/app/controllers/tb_checkout/admin/transactions_controller.rb +26 -0
  22. data/app/controllers/tb_checkout/application_controller.rb +6 -0
  23. data/app/controllers/tb_checkout/cart_items_controller.rb +63 -0
  24. data/app/controllers/tb_checkout/carts_controller.rb +8 -0
  25. data/app/controllers/tb_checkout/transactions_controller.rb +87 -0
  26. data/app/helpers/tb_checkout/admin/carts_helper.rb +13 -0
  27. data/app/helpers/tb_checkout/admin/transactions_helper.rb +16 -0
  28. data/app/helpers/tb_checkout/application_helper.rb +138 -0
  29. data/app/helpers/tb_checkout/transactions_helper.rb +2 -0
  30. data/app/models/concerns/tb_checkout/belongs_to_user_session.rb +15 -0
  31. data/app/models/concerns/tb_checkout/purchasable.rb +81 -0
  32. data/app/models/tb_checkout/basic_product.rb +6 -0
  33. data/app/models/tb_checkout/cart.rb +56 -0
  34. data/app/models/tb_checkout/cart_item.rb +48 -0
  35. data/app/models/tb_checkout/transaction.rb +253 -0
  36. data/app/views/tb_checkout/admin/carts/index.html.erb +54 -0
  37. data/app/views/tb_checkout/admin/carts/show.html.erb +45 -0
  38. data/app/views/tb_checkout/admin/transactions/_table.html.erb +24 -0
  39. data/app/views/tb_checkout/admin/transactions/index.html.erb +7 -0
  40. data/app/views/tb_checkout/admin/transactions/show.html.erb +70 -0
  41. data/app/views/tb_checkout/cart_items/create.html.erb +2 -0
  42. data/app/views/tb_checkout/cart_items/destroy.html.erb +2 -0
  43. data/app/views/tb_checkout/cart_items/update.html.erb +2 -0
  44. data/app/views/tb_checkout/carts/_cart.html.erb +65 -0
  45. data/app/views/tb_checkout/carts/show.html.erb +10 -0
  46. data/app/views/tb_checkout/transactions/_details.html.erb +17 -0
  47. data/app/views/tb_checkout/transactions/confirm.html.erb +11 -0
  48. data/app/views/tb_checkout/transactions/index.html.erb +29 -0
  49. data/app/views/tb_checkout/transactions/new.html.erb +90 -0
  50. data/app/views/tb_checkout/transactions/show.html.erb +14 -0
  51. data/config/locales/en.yml +23 -0
  52. data/config/routes.rb +20 -0
  53. data/db/migrate/20140703185256_create_tb_checkout_carts.rb +12 -0
  54. data/db/migrate/20140703185258_create_tb_checkout_cart_items.rb +15 -0
  55. data/db/migrate/20140703185259_create_tb_checkout_transactions.rb +23 -0
  56. data/db/migrate/20140707142350_create_tb_checkout_basic_products.rb +8 -0
  57. data/db/migrate/20140915202848_add_spud_user_and_session_id_to_transactions.rb +10 -0
  58. data/lib/tasks/tb_checkout_tasks.rake +19 -0
  59. data/lib/tb_checkout.rb +4 -0
  60. data/lib/tb_checkout/configuration.rb +8 -0
  61. data/lib/tb_checkout/engine.rb +36 -0
  62. data/lib/tb_checkout/schema.rb +51 -0
  63. data/lib/tb_checkout/version.rb +3 -0
  64. data/spec/controllers/tb_checkout/carts_controller_spec.rb +11 -0
  65. data/spec/controllers/tb_checkout/transactions_controller_spec.rb +110 -0
  66. data/spec/dummy/README.rdoc +28 -0
  67. data/spec/dummy/Rakefile +6 -0
  68. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  69. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  70. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  71. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  72. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  73. data/spec/dummy/bin/bundle +3 -0
  74. data/spec/dummy/bin/rails +4 -0
  75. data/spec/dummy/bin/rake +4 -0
  76. data/spec/dummy/config.ru +4 -0
  77. data/spec/dummy/config/application.rb +30 -0
  78. data/spec/dummy/config/boot.rb +5 -0
  79. data/spec/dummy/config/database.yml +13 -0
  80. data/spec/dummy/config/environment.rb +5 -0
  81. data/spec/dummy/config/environments/development.rb +37 -0
  82. data/spec/dummy/config/environments/production.rb +82 -0
  83. data/spec/dummy/config/environments/test.rb +39 -0
  84. data/spec/dummy/config/initializers/assets.rb +8 -0
  85. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  86. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  87. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  88. data/spec/dummy/config/initializers/inflections.rb +16 -0
  89. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  90. data/spec/dummy/config/initializers/session_store.rb +3 -0
  91. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  92. data/spec/dummy/config/locales/en.yml +23 -0
  93. data/spec/dummy/config/routes.rb +4 -0
  94. data/spec/dummy/config/secrets.yml +22 -0
  95. data/spec/dummy/db/migrate/20140915202259_create_spud_admin_permissions.tb_core.rb +12 -0
  96. data/spec/dummy/db/migrate/20140915202260_create_spud_users.tb_core.rb +30 -0
  97. data/spec/dummy/db/migrate/20140915202261_add_time_zone_to_spud_user.tb_core.rb +7 -0
  98. data/spec/dummy/db/migrate/20140915202262_add_scope_to_spud_admin_permissions.tb_core.rb +7 -0
  99. data/spec/dummy/db/migrate/20140915202263_create_spud_user_settings.tb_core.rb +12 -0
  100. data/spec/dummy/db/migrate/20140915202264_create_spud_roles.tb_core.rb +11 -0
  101. data/spec/dummy/db/migrate/20140915202265_create_spud_permissions.tb_core.rb +11 -0
  102. data/spec/dummy/db/migrate/20140915202266_create_spud_role_permissions.tb_core.rb +12 -0
  103. data/spec/dummy/db/migrate/20140915202267_drop_spud_admin_permissions.tb_core.rb +16 -0
  104. data/spec/dummy/db/migrate/20140915202268_create_tb_checkout_carts.tb_checkout_engine.rb +13 -0
  105. data/spec/dummy/db/migrate/20140915202269_create_tb_checkout_cart_items.tb_checkout_engine.rb +16 -0
  106. data/spec/dummy/db/migrate/20140915202270_create_tb_checkout_transactions.tb_checkout_engine.rb +24 -0
  107. data/spec/dummy/db/migrate/20140915202271_create_tb_checkout_basic_products.tb_checkout_engine.rb +9 -0
  108. data/spec/dummy/db/migrate/20140915234534_add_spud_user_and_session_id_to_transactions.tb_checkout_engine.rb +11 -0
  109. data/spec/dummy/db/schema.rb +135 -0
  110. data/spec/dummy/public/404.html +67 -0
  111. data/spec/dummy/public/422.html +67 -0
  112. data/spec/dummy/public/500.html +66 -0
  113. data/spec/dummy/public/favicon.ico +0 -0
  114. data/spec/factories/spud_users.rb +16 -0
  115. data/spec/factories/tb_checkout_basic_products.rb +8 -0
  116. data/spec/factories/tb_checkout_cart_items.rb +11 -0
  117. data/spec/factories/tb_checkout_carts.rb +14 -0
  118. data/spec/factories/tb_checkout_transactions.rb +37 -0
  119. data/spec/models/tb_checkout/transaction_spec.rb +5 -0
  120. data/spec/rails_helper.rb +73 -0
  121. data/spec/spec_helper.rb +85 -0
  122. metadata +335 -0
@@ -0,0 +1,2 @@
1
+ <h1>TbCheckout::CartItems#create</h1>
2
+ <p>Find me in app/views/tb_checkout/cart_items/create.html.erb</p>
@@ -0,0 +1,2 @@
1
+ <h1>TbCheckout::CartItems#destroy</h1>
2
+ <p>Find me in app/views/tb_checkout/cart_items/destroy.html.erb</p>
@@ -0,0 +1,2 @@
1
+ <h1>TbCheckout::CartItems#update</h1>
2
+ <p>Find me in app/views/tb_checkout/cart_items/update.html.erb</p>
@@ -0,0 +1,65 @@
1
+ <% editable = true if local_assigns[:editable].nil? %>
2
+ <% cart = local_assigns[:cart].nil? ? @cart : cart %>
3
+
4
+ <% cache [cart, cart.cart_items, editable] do %>
5
+ <div class="table-responsive">
6
+ <table class="table tb-checkout-cart-table">
7
+ <thead>
8
+ <tr>
9
+ <th>Product</th>
10
+ <th>Quantity</th>
11
+ <th>Price</th>
12
+ <% if editable %>
13
+ <th></th>
14
+ <% end %>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <% cart.cart_items.each do |cart_item| %>
19
+ <% cache [cart, cart_item, editable] do %>
20
+ <tr class="tb-checkout-cart-row">
21
+ <td>
22
+ <% if cart_item.has_item_url? %>
23
+ <%= link_to cart_item.item_description, cart_item.item_url(self) %>
24
+ <% else %>
25
+ <%= cart_item.item_description %>
26
+ <% end %>
27
+ <% if cart.is_completed? && cart_item.has_detail_view? %>
28
+ <div class="tb-checkout-cart-row-detail">
29
+ <%= render :partial => cart_item.detail_view, :locals => {:item => cart_item.item} %>
30
+ </div>
31
+ <% end %>
32
+ </td>
33
+ <td>
34
+ <% if editable && cart_item.item.class.quantity_is_editable %>
35
+ <%= form_for cart_item, :html => {:class => 'tb-checkout-cart-item-update-form'} do |f| %>
36
+ <%= f.number_field :quantity %>
37
+ <%= f.submit 'Update', :class => 'btn btn-sm tb-checkout-cart-item-update-submit' %>
38
+ <% end %>
39
+ <% else %>
40
+ <%= cart_item.quantity %>
41
+ <% end %>
42
+ </td>
43
+ <td><%= number_to_currency cart_item.total_price %></td>
44
+ <td>
45
+ <% if editable %>
46
+ <%= link_to 'Remove', tb_checkout_cart_item_path(cart_item), :method => :delete, :class => 'btn btn-sm btn-danger tb-checkout-cart-item-remove' %>
47
+ <% end %>
48
+ </td>
49
+ </tr>
50
+ <% end %>
51
+ <% end %>
52
+ </tbody>
53
+ <tfoot>
54
+ <tr>
55
+ <td colspan="2">
56
+ Total
57
+ </td>
58
+ <td><%= number_to_currency cart.total_price %></td>
59
+ <td></td>
60
+ </tr>
61
+ </tfoot>
62
+ </table>
63
+ <% end %>
64
+
65
+ </div>
@@ -0,0 +1,10 @@
1
+ <h1>My Cart</h1>
2
+
3
+ <% cache @cart do %>
4
+ <% if @cart.blank? || @cart.is_empty? %>
5
+ <p>Your shopping cart is currently empty.</p>
6
+ <% else %>
7
+ <%= render 'cart' %>
8
+ <p><%= link_to 'Check Out', new_tb_checkout_transaction_path, :class => 'btn btn-primary' %></p>
9
+ <% end %>
10
+ <% end %>
@@ -0,0 +1,17 @@
1
+ <h4>Credit Card</h4>
2
+ <dl class="dl-horizontal tb-checkout-transaction-confirm-info">
3
+ <dt>Number</dt>
4
+ <dd><%= @transaction.card_display %></dd>
5
+ <dt>Type</dt>
6
+ <dd><%= @transaction.card_type.titleize %></dd>
7
+ <dt>Amount Charged</dt>
8
+ <dd><%= number_to_currency @transaction.amount_charged %></dd>
9
+ </dl>
10
+
11
+ <h4>Billing Address</h4>
12
+ <dl class="dl-horizontal tb-checkout-transaction-confirm-info">
13
+ <dt>Name</dt>
14
+ <dd><%= @transaction.billing_full_name %></dd>
15
+ <dt>Address</dt>
16
+ <dd><%= @transaction.billing_full_address %></dd>
17
+ </dl>
@@ -0,0 +1,11 @@
1
+ <h1>Confirm Payment</h1>
2
+
3
+ <p>Click "Confirm" below to finish your transaction.</p>
4
+
5
+ <% cache [@transaction, 'details'] do %>
6
+ <%= render 'details' %>
7
+ <% end %>
8
+
9
+ <%= form_for [:capture, @transaction] do |f| %>
10
+ <%= f.submit 'Confirm', :class => 'btn btn-primary' %>
11
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <h1>My Orders</h1>
2
+
3
+ <table class="table tb-checkout-transactions-table">
4
+ <thead>
5
+ <tr>
6
+ <th>Date</th>
7
+ <th>Description</th>
8
+ <th>Card</th>
9
+ <th>Amount</th>
10
+ <th></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <% cache @transactions do %>
15
+ <% @transactions.each do |transaction| %>
16
+ <% cache transaction do %>
17
+ <tr>
18
+ <td><%= transaction.created_at.strftime('%D') %></td>
19
+ <td><%= transaction.cart.description %></td>
20
+ <td><%= transaction.card_display %> (<%= transaction.card_type.titleize %>)</td>
21
+ <td><%= number_to_currency transaction.amount_charged %></td>
22
+ <td><%= link_to 'Details', tb_checkout_transaction_path(transaction) %>
23
+ </tr>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ <%= will_paginate @transactions %>
@@ -0,0 +1,90 @@
1
+ <h1>Check Out</h1>
2
+
3
+ <% cache @cart do %>
4
+ <%= render :partial => '/tb_checkout/carts/cart', :locals => {:editable => false, :cart => @cart} %>
5
+ <% end %>
6
+
7
+ <h2>Billing Info</h2>
8
+
9
+ <%= form_for @transaction, :url => new_tb_checkout_transaction_path, :html => {:class => 'tb-checkout-checkout-form form-horizontal'} do |f| %>
10
+
11
+ <%= tb_form_errors(@transaction) %>
12
+
13
+ <div class="form-group">
14
+ <%= f.label :card_type, :class => 'col-sm-2 control-label' %>
15
+ <div class="col-sm-10">
16
+ <%= f.select :card_type, tb_checkout_credit_card_types, {}, :class => 'form-control' %>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="form-group">
21
+ <%= f.label :card_number, :class => 'col-sm-2 control-label' %>
22
+ <div class="col-sm-10">
23
+ <%= f.text_field :card_number, :class => 'form-control' %>
24
+ </div>
25
+ </div>
26
+
27
+ <div class="form-group">
28
+ <%= f.label :card_expiration, :class => 'col-sm-2 control-label' %>
29
+ <div class="col-sm-10">
30
+ <%= f.date_select :card_expiration, {:discard_day => true, :start_year => Date.today.year}, {:class => 'form-control form-control-date-select'} %>
31
+ </div>
32
+ </div>
33
+
34
+ <div class="form-group">
35
+ <%= f.label :card_ccv, :class => 'col-sm-2 control-label' %>
36
+ <div class="col-sm-10">
37
+ <%= f.text_field :card_ccv, :class => 'form-control' %>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="form-group">
42
+ <%= f.label :billing_first_name, :class => 'col-sm-2 control-label' %>
43
+ <div class="col-sm-10">
44
+ <%= f.text_field :billing_first_name, :class => 'form-control' %>
45
+ </div>
46
+ </div>
47
+
48
+ <div class="form-group">
49
+ <%= f.label :billing_last_name, :class => 'col-sm-2 control-label' %>
50
+ <div class="col-sm-10">
51
+ <%= f.text_field :billing_last_name, :class => 'form-control' %>
52
+ </div>
53
+ </div>
54
+
55
+ <div class="form-group">
56
+ <%= f.label :billing_address_1, :class => 'col-sm-2 control-label' %>
57
+ <div class="col-sm-10">
58
+ <%= f.text_field :billing_address_1, :class => 'form-control' %>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="form-group">
63
+ <%= f.label :billing_city, :class => 'col-sm-2 control-label' %>
64
+ <div class="col-sm-10">
65
+ <%= f.text_field :billing_city, :class => 'form-control' %>
66
+ </div>
67
+ </div>
68
+
69
+ <div class="form-group">
70
+ <%= f.label :billing_state, :class => 'col-sm-2 control-label' %>
71
+ <div class="col-sm-10">
72
+ <%= f.select :billing_state, tb_checkout_options_for_states, {:prompt => 'Select State'}, :class => 'form-control' %>
73
+ </div>
74
+ </div>
75
+
76
+ <div class="form-group">
77
+ <%= f.label :billing_postal, :class => 'col-sm-2 control-label' %>
78
+ <div class="col-sm-10">
79
+ <%= f.text_field :billing_postal, :class => 'form-control' %>
80
+ </div>
81
+ </div>
82
+
83
+ <div class="form-group form-actions">
84
+ <div class="col-sm-offset-2 col-sm-10">
85
+ <%= f.submit 'Submit', :class => 'btn btn-primary' %>
86
+ <%= link_to 'Back', tb_checkout_cart_path, :class => 'btn btn-default' %>
87
+ </div>
88
+ </div>
89
+
90
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h1>Invoice</h1>
2
+
3
+ <p>Print this page for your records.</p>
4
+
5
+ <h4>Your Order</h4>
6
+ <% cache @transaction.cart do %>
7
+ <%= render :partial => '/tb_checkout/carts/cart', :locals => {:editable => false, :cart => @transaction.cart} %>
8
+ <% end %>
9
+
10
+ <% cache @transaction do %>
11
+ <%= render 'details' %>
12
+ <% end %>
13
+
14
+ <p><%= link_to 'View My Orders', tb_checkout_transactions_path %></p>
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ tb_checkout:
data/config/routes.rb ADDED
@@ -0,0 +1,20 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :tb_checkout, :path => '/' do
4
+
5
+ get 'cart' => 'carts#show'
6
+ resources :cart_items, :only => [:create, :update, :destroy]
7
+
8
+ resources :transactions, :path => 'orders', :only => [:index, :show]
9
+ resources :transactions, :path => 'checkout', :only => [:new, :create], :path_names => {:new => '/'} do
10
+ get :confirm, :on => :member
11
+ patch :capture, :on => :member
12
+ end
13
+
14
+ namespace :admin do
15
+ resources :carts, :only => [:index, :show]
16
+ resources :transactions, :only => [:index, :show]
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTbCheckoutCarts < ActiveRecord::Migration
2
+ def change
3
+ create_table :tb_checkout_carts do |t|
4
+ t.integer :spud_user_id
5
+ t.index :spud_user_id
6
+ t.string :session_id, :limit => 32
7
+ t.boolean :is_completed, :default => false
8
+ t.boolean :is_abandoned, :default => false
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ class CreateTbCheckoutCartItems < ActiveRecord::Migration
2
+ def change
3
+ create_table :tb_checkout_cart_items do |t|
4
+ t.integer :cart_id, :null => false
5
+ t.integer :item_id, :null => false
6
+ t.string :item_type, :null => false
7
+ t.string :item_description
8
+ t.decimal :item_price, :precision => 8, :scale => 2
9
+ t.integer :quantity, :default => 1
10
+ t.timestamps
11
+ end
12
+ add_index :tb_checkout_cart_items, :cart_id
13
+ add_index :tb_checkout_cart_items, [:item_id, :item_type]
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ class CreateTbCheckoutTransactions < ActiveRecord::Migration
2
+ def change
3
+ create_table :tb_checkout_transactions do |t|
4
+ t.integer :cart_id
5
+ t.string :status, :default => 'pending'
6
+ t.string :invoice_num
7
+ t.integer :gateway_transaction_id, :limit => 8
8
+ t.decimal :amount_charged, :precision => 8, :scale => 2
9
+ t.string :card_display
10
+ t.string :card_type
11
+ t.string :billing_first_name
12
+ t.string :billing_last_name
13
+ t.string :billing_address_1
14
+ t.string :billing_address_2
15
+ t.string :billing_city
16
+ t.string :billing_state
17
+ t.string :billing_postal
18
+ t.text :response_text
19
+ t.timestamps
20
+ end
21
+ add_index :tb_checkout_transactions, :cart_id
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ class CreateTbCheckoutBasicProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :tb_checkout_basic_products do |t|
4
+ t.tb_checkout_purchasable
5
+ t.timestamps
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class AddSpudUserAndSessionIdToTransactions < ActiveRecord::Migration
2
+ def change
3
+ change_table :tb_checkout_transactions do |t|
4
+ t.integer :spud_user_id
5
+ t.index :spud_user_id
6
+ t.string :session_id, :limit => 32
7
+ t.index :session_id
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ # desc "Explaining what the task does"
2
+ # task :tb_checkout do
3
+ # # Task goes here
4
+ # end
5
+
6
+ namespace :tb_checkout do
7
+
8
+ desc "Look for old carts and mark them as abandoned"
9
+ task :check_abandoned => :environment do
10
+ result = TbCheckout::Cart.check_abandoned!
11
+ logger.debug("Marked #{result} shopping carts as abandoned")
12
+ end
13
+
14
+ def logger
15
+ @_logger = Logger.new(STDOUT) if @_logger.nil?
16
+ return @_logger
17
+ end
18
+
19
+ end
@@ -0,0 +1,4 @@
1
+ require "tb_checkout/engine"
2
+
3
+ module TbCheckout
4
+ end
@@ -0,0 +1,8 @@
1
+ module TbCheckout
2
+ include ActiveSupport::Configurable
3
+ config_accessor :gateway, :canada_is_real, :card_types, :layout, :cart_lifespan
4
+ self.canada_is_real = true
5
+ self.card_types = [:visa, :master, :discover, :american_express]
6
+ self.layout = nil
7
+ self.cart_lifespan = 3.days
8
+ end
@@ -0,0 +1,36 @@
1
+ require "tb_core"
2
+ require "activemerchant"
3
+ require "tb_checkout/configuration"
4
+ require 'tb_checkout/schema'
5
+
6
+ module TbCheckout
7
+ class Engine < ::Rails::Engine
8
+ include TbCheckout::Schema
9
+
10
+ initializer 'tb_checkout.cart_helpers' do |config|
11
+ ActiveSupport.on_load :spud_application_controller do
12
+ Spud::ApplicationController.send :include, TbCheckout::ControllerHelpers
13
+ end
14
+ end
15
+
16
+ initializer 'tb_checkout.admin' do |config|
17
+ Spud::Core.admin_applications += [{
18
+ :name => 'Shopping Carts',
19
+ :url => '/admin/carts',
20
+ :thumbnail => 'tb_checkout/admin/shopping_carts.png'
21
+ },{
22
+ :name => 'Transactions',
23
+ :url => '/admin/transactions',
24
+ :thumbnail => 'tb_checkout/admin/transactions.png'
25
+ }]
26
+ end
27
+
28
+ config.generators do |g|
29
+ g.test_framework :rspec, :fixture => false
30
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
31
+ g.assets false
32
+ g.helper true
33
+ end
34
+
35
+ end
36
+ end