effective_orders 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +67 -1
  3. data/app/assets/config/effective_orders_manifest.js +3 -0
  4. data/app/assets/images/effective_orders/logo.png +0 -0
  5. data/app/assets/javascripts/effective_orders.js +1 -1
  6. data/app/assets/javascripts/effective_orders/providers/moneris_checkout.js.coffee +71 -0
  7. data/app/assets/stylesheets/effective_orders/_order.scss +4 -0
  8. data/app/controllers/effective/concerns/purchase.rb +14 -21
  9. data/app/controllers/effective/orders_controller.rb +2 -2
  10. data/app/controllers/effective/providers/free.rb +0 -1
  11. data/app/controllers/effective/providers/mark_as_paid.rb +1 -2
  12. data/app/controllers/effective/providers/moneris_checkout.rb +59 -0
  13. data/app/controllers/effective/providers/pretend.rb +1 -2
  14. data/app/controllers/effective/providers/refund.rb +1 -2
  15. data/app/controllers/effective/providers/stripe.rb +1 -2
  16. data/app/datatables/admin/effective_orders_datatable.rb +5 -8
  17. data/app/datatables/effective_orders_datatable.rb +3 -7
  18. data/app/helpers/effective_moneris_checkout_helper.rb +65 -0
  19. data/app/helpers/effective_orders_helper.rb +3 -26
  20. data/app/mailers/effective/orders_mailer.rb +6 -4
  21. data/app/models/concerns/acts_as_purchasable.rb +2 -0
  22. data/app/models/concerns/acts_as_subscribable.rb +1 -0
  23. data/app/models/concerns/acts_as_subscribable_buyer.rb +2 -1
  24. data/app/models/effective/order.rb +56 -35
  25. data/app/models/effective/order_item.rb +10 -0
  26. data/app/models/effective/product.rb +2 -0
  27. data/app/views/effective/orders/_checkout_step2.html.haml +3 -0
  28. data/app/views/effective/orders/_order.html.haml +1 -1
  29. data/app/views/effective/orders/_order_actions.html.haml +1 -1
  30. data/app/views/effective/orders/_order_footer.html.haml +3 -1
  31. data/app/views/effective/orders/_order_header.html.haml +4 -20
  32. data/app/views/effective/orders/_order_payment.html.haml +7 -18
  33. data/app/views/effective/orders/declined.html.haml +2 -4
  34. data/app/views/effective/orders/deferred.html.haml +2 -4
  35. data/app/views/effective/orders/moneris_checkout/_element.html.haml +4 -0
  36. data/app/views/effective/orders/moneris_checkout/_form.html.haml +23 -0
  37. data/app/views/effective/orders/purchased.html.haml +2 -4
  38. data/app/views/effective/orders/show.html.haml +5 -2
  39. data/config/effective_orders.rb +19 -0
  40. data/config/routes.rb +1 -0
  41. data/lib/effective_orders.rb +23 -2
  42. data/lib/effective_orders/engine.rb +2 -2
  43. data/lib/effective_orders/version.rb +1 -1
  44. data/lib/generators/templates/effective_orders_mailer_preview.rb +6 -0
  45. metadata +69 -6
@@ -1,12 +1,10 @@
1
1
  %h1.effective-heading= @page_title
2
2
 
3
- %p.effective-orders-page-content
4
- = link_to 'Home', root_path
5
-
6
3
  %p.effective-orders-page-content
7
4
  - if current_cart.present?
8
5
  Your #{link_to_current_cart(label: 'Cart')} items have been saved. Please try again.
9
6
  - else
10
7
  Please try again.
11
8
 
12
- = link_to 'Continue', root_path, class: 'btn btn-primary'
9
+ %p.text-center
10
+ = link_to 'Continue', root_path, class: 'btn btn-primary'
@@ -1,8 +1,5 @@
1
1
  %h1.effective-heading= @page_title
2
2
 
3
- %p.effective-orders-page-content
4
- = link_to 'Home', root_path
5
-
6
3
  %p.effective-orders-page-content
7
4
  You have indicated that this order will be paid by #{@order.payment_provider}.
8
5
  Your order will not be considered purchased until we receive your payment.
@@ -10,4 +7,5 @@
10
7
 
11
8
  = render @order
12
9
 
13
- = link_to 'Continue', root_path, class: 'btn btn-primary'
10
+ %p.text-center
11
+ = link_to 'Continue', root_path, class: 'btn btn-primary'
@@ -0,0 +1,4 @@
1
+ .effective-moneris-checkout
2
+ #moneris-checkout-error.text-center.alert-danger
3
+ #moneris-checkout-success.text-center
4
+ #monerisCheckout
@@ -0,0 +1,23 @@
1
+ = javascript_include_tag(EffectiveOrders.moneris_checkout_script_url)
2
+
3
+ - moneris_checkout = moneris_checkout_preload_request(order)
4
+
5
+ .card
6
+ .card-body.bg-light
7
+ .mb-3.text-center
8
+ %h2 Checkout
9
+
10
+ = effective_form_with(scope: :moneris_checkout, url: effective_orders.moneris_checkout_order_path(order), data: { 'moneris-checkout-form': moneris_checkout.to_json }) do |f|
11
+ = f.hidden_field :purchased_url, value: purchased_url
12
+ = f.hidden_field :declined_url, value: declined_url
13
+
14
+ -# This is set by the moneris_checkout.js javascript
15
+ = f.hidden_field :ticket
16
+
17
+ = render('effective/orders/moneris_checkout/element')
18
+
19
+ .mt-3.text-center
20
+ %em
21
+ This checkout provided by
22
+ = succeed('.') do
23
+ = link_to('Moneris', 'https://www.moneris.com', target: '_blank', class: 'btn-link')
@@ -1,11 +1,9 @@
1
1
  %h1.effective-heading= @page_title
2
2
 
3
- %p.effective-orders-page-content
4
- = link_to 'Home', root_path
5
-
6
3
  %p.effective-orders-page-content
7
4
  You have successfully purchased the following:
8
5
 
9
6
  = render @order
10
7
 
11
- = link_to 'Continue', root_path, class: 'btn btn-primary'
8
+ %p.text-center
9
+ = link_to 'Continue', root_path, class: 'btn btn-primary'
@@ -1,6 +1,9 @@
1
1
  %h1.effective-heading= @page_title
2
2
 
3
- - if @order.user == current_user
3
+ - if !@order.purchased? && @order.user == current_user
4
4
  = render_checkout(@order)
5
5
  - else
6
- = render @order
6
+ = render(@order)
7
+
8
+ %p.text-center
9
+ = link_to 'Continue', effective_orders.orders_path, class: 'btn btn-primary'
@@ -166,6 +166,25 @@ EffectiveOrders.setup do |config|
166
166
  # }
167
167
  # end
168
168
 
169
+ # Moneris Checkout
170
+ config.moneris_checkout = false
171
+
172
+ # if Rails.env.production?
173
+ # config.moneris_checkout = {
174
+ # environment: 'prod',
175
+ # store_id: '',
176
+ # api_token: '',
177
+ # checkout_id: '',
178
+ # }
179
+ # else
180
+ # config.moneris_checkout = {
181
+ # environment: 'qa',
182
+ # store_id: 'store1',
183
+ # api_token: 'yesguy1',
184
+ # checkout_id: 'chktJF76Btore1',
185
+ # }
186
+ # end
187
+
169
188
  # Paypal
170
189
  config.paypal = false
171
190
 
data/config/routes.rb CHANGED
@@ -10,6 +10,7 @@ EffectiveOrders::Engine.routes.draw do
10
10
  post :free
11
11
  post :mark_as_paid
12
12
  post :cheque
13
+ post :moneris_checkout
13
14
  post :phone
14
15
  post :pretend
15
16
  post :refund
@@ -34,7 +34,7 @@ module EffectiveOrders
34
34
  # Features
35
35
  :free_enabled, :mark_as_paid_enabled, :pretend_enabled, :pretend_message,
36
36
  # Payment processors. false or Hash
37
- :cheque, :moneris, :paypal, :phone, :refund, :stripe, :subscriptions, :trial
37
+ :cheque, :moneris, :moneris_checkout, :paypal, :phone, :refund, :stripe, :subscriptions, :trial
38
38
  ]
39
39
  end
40
40
 
@@ -69,6 +69,10 @@ module EffectiveOrders
69
69
  moneris.kind_of?(Hash)
70
70
  end
71
71
 
72
+ def self.moneris_checkout?
73
+ moneris_checkout.kind_of?(Hash)
74
+ end
75
+
72
76
  def self.paypal?
73
77
  paypal.kind_of?(Hash)
74
78
  end
@@ -98,7 +102,7 @@ module EffectiveOrders
98
102
  end
99
103
 
100
104
  def self.single_payment_processor?
101
- [moneris?, paypal?, stripe?].select { |enabled| enabled }.length == 1
105
+ [moneris?, moneris_checkout?, paypal?, stripe?].select { |enabled| enabled }.length == 1
102
106
  end
103
107
 
104
108
  # The Effective::Order.payment_provider value must be in this collection
@@ -108,6 +112,7 @@ module EffectiveOrders
108
112
  ('credit card' if mark_as_paid?),
109
113
  ('free' if free?),
110
114
  ('moneris' if moneris?),
115
+ ('moneris_checkout' if moneris_checkout?),
111
116
  ('paypal' if paypal?),
112
117
  ('phone' if phone?),
113
118
  ('pretend' if pretend?),
@@ -197,6 +202,22 @@ module EffectiveOrders
197
202
  stripe_plans.map { |plan| [plan[:name], plan[:id]] }
198
203
  end
199
204
 
205
+ def self.moneris_checkout_script_url
206
+ case EffectiveOrders.moneris_checkout.fetch(:environment)
207
+ when 'prod' then 'https://gateway.moneris.com/chkt/js/chkt_v1.00.js'
208
+ when 'qa' then 'https://gatewayt.moneris.com/chkt/js/chkt_v1.00.js'
209
+ else raise('unexpected EffectiveOrders.moneris_checkout :environment key. Please check your config/initializers/effective_orders.rb file')
210
+ end
211
+ end
212
+
213
+ def self.moneris_request_url
214
+ case EffectiveOrders.moneris_checkout.fetch(:environment)
215
+ when 'prod' then 'https://gateway.moneris.com/chkt/request/request.php'
216
+ when 'qa' then 'https://gatewayt.moneris.com/chkt/request/request.php'
217
+ else raise('unexpected EffectiveOrders.moneris_checkout :environment key. Please check your config/initializers/effective_orders.rb file')
218
+ end
219
+ end
220
+
200
221
  class SoldOutException < Exception; end
201
222
  class AlreadyPurchasedException < Exception; end
202
223
  end
@@ -16,8 +16,8 @@ module EffectiveOrders
16
16
  eval File.read("#{config.root}/config/effective_orders.rb")
17
17
  end
18
18
 
19
- initializer "effective_orders.append_precompiled_assets" do |app|
20
- Rails.application.config.assets.precompile += ['effective_orders/*']
19
+ initializer 'effective_orders.assets' do |app|
20
+ app.config.assets.precompile += ['effective_orders_manifest.js', 'effective_orders/*']
21
21
  end
22
22
 
23
23
  initializer 'effective_orders.refund', after: :load_config_initializers do
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.0.1'.freeze
2
+ VERSION = '5.1.0'.freeze
3
3
  end
@@ -61,6 +61,12 @@ class EffectiveOrdersMailerPreview < ActionMailer::Preview
61
61
  order = Effective::Order.new(id: 1)
62
62
  order.user = preview_user
63
63
  preview_order_items.each { |atts| order.order_items.build(atts) }
64
+
65
+ order.state = 'purchased'
66
+ order.payment_card = 'visa'
67
+ order.purchased_at = Time.zone.now
68
+ order.payment = { 'f4l4' => '1234'}
69
+
64
70
  order.valid?
65
71
  order
66
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: devise
42
+ name: sassc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: sass
56
+ name: effective_addresses
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 4.0.0
75
+ version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 4.0.0
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: effective_bootstrap
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,62 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: devise
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: haml-rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry-byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
111
167
  description: Quickly build an online store with carts, orders, automatic email receipts
112
168
  and payment collection via Stripe, StripeConnect, PayPal and Moneris.
113
169
  email:
@@ -118,9 +174,12 @@ extra_rdoc_files: []
118
174
  files:
119
175
  - MIT-LICENSE
120
176
  - README.md
177
+ - app/assets/config/effective_orders_manifest.js
178
+ - app/assets/images/effective_orders/logo.png
121
179
  - app/assets/images/effective_orders/stripe.png
122
180
  - app/assets/javascripts/effective_orders.js
123
181
  - app/assets/javascripts/effective_orders/customers.js.coffee
182
+ - app/assets/javascripts/effective_orders/providers/moneris_checkout.js.coffee
124
183
  - app/assets/javascripts/effective_orders/providers/stripe.js.coffee
125
184
  - app/assets/javascripts/effective_orders/subscriptions.js.coffee
126
185
  - app/assets/stylesheets/effective_orders.scss
@@ -137,6 +196,7 @@ files:
137
196
  - app/controllers/effective/providers/free.rb
138
197
  - app/controllers/effective/providers/mark_as_paid.rb
139
198
  - app/controllers/effective/providers/moneris.rb
199
+ - app/controllers/effective/providers/moneris_checkout.rb
140
200
  - app/controllers/effective/providers/paypal.rb
141
201
  - app/controllers/effective/providers/phone.rb
142
202
  - app/controllers/effective/providers/pretend.rb
@@ -148,6 +208,7 @@ files:
148
208
  - app/datatables/admin/effective_orders_datatable.rb
149
209
  - app/datatables/effective_orders_datatable.rb
150
210
  - app/helpers/effective_carts_helper.rb
211
+ - app/helpers/effective_moneris_checkout_helper.rb
151
212
  - app/helpers/effective_orders_helper.rb
152
213
  - app/helpers/effective_paypal_helper.rb
153
214
  - app/helpers/effective_stripe_helper.rb
@@ -213,6 +274,8 @@ files:
213
274
  - app/views/effective/orders/index.html.haml
214
275
  - app/views/effective/orders/mark_as_paid/_form.html.haml
215
276
  - app/views/effective/orders/moneris/_form.html.haml
277
+ - app/views/effective/orders/moneris_checkout/_element.html.haml
278
+ - app/views/effective/orders/moneris_checkout/_form.html.haml
216
279
  - app/views/effective/orders/new.html.haml
217
280
  - app/views/effective/orders/paypal/_form.html.haml
218
281
  - app/views/effective/orders/phone/_form.html.haml