effective_orders 1.2.3 → 1.2.4
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.
- checksums.yaml +4 -4
- data/README.md +2 -8
- data/app/controllers/effective/orders_controller.rb +2 -2
- data/app/controllers/effective/providers/moneris.rb +1 -8
- data/app/helpers/effective_paypal_helper.rb +1 -1
- data/app/models/effective/datatables/orders.rb +24 -7
- data/app/models/effective/order.rb +12 -5
- data/app/views/effective/orders/_order_shipping.html.haml +3 -4
- data/app/views/effective/orders/moneris/_form.html.haml +3 -5
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/templates/effective_orders.rb +2 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9019d34aa37326aedfa30f1109d9af5ced0de13a
|
4
|
+
data.tar.gz: ddb700b7fbf547e81cfc90bf4234aa57fb8139e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83339fe6de29de57ae6b909ee49d409500e93c1d6a1b9ac66e561d5181f093bc3a43e78f5647b2261128a93c857b6958c6315a32026b577060884c95d899aa35
|
7
|
+
data.tar.gz: a4d3ee975306f6e20b7852636f9dfb97e89b462d22c7deffdc7c04d6ac44a7ab1832c9cee1bd182394135a9e316960b1c3ba2fea2b1502e41657ff0161ded830
|
data/README.md
CHANGED
@@ -657,16 +657,14 @@ Copy these two values into the appropriate lines of config/effective_orders.rb i
|
|
657
657
|
:ps_store_id => '',
|
658
658
|
:hpp_key => '',
|
659
659
|
:hpp_url => 'https://www3.moneris.com/HPPDP/index.php',
|
660
|
-
:verify_url => 'https://www3.moneris.com/HPPDP/verifyTxn.php'
|
661
|
-
:order_nudge => 0
|
660
|
+
:verify_url => 'https://www3.moneris.com/HPPDP/verifyTxn.php'
|
662
661
|
}
|
663
662
|
else
|
664
663
|
config.moneris = {
|
665
664
|
:ps_store_id => 'VZ9BNtore1',
|
666
665
|
:hpp_key => 'hp1Y5J35GVDM',
|
667
666
|
:hpp_url => 'https://esqa.moneris.com/HPPDP/index.php',
|
668
|
-
:verify_url => 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
|
669
|
-
:order_nudge => 0
|
667
|
+
:verify_url => 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
|
670
668
|
}
|
671
669
|
end
|
672
670
|
```
|
@@ -753,10 +751,6 @@ https://www.google.ca/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CB8QFjAA&url
|
|
753
751
|
|
754
752
|
Once Order id=1 has been purchased/declined, you will be unable to purchase an order with id=1 ever again.
|
755
753
|
|
756
|
-
This is what the moneris order_nudge configuration setting is used for.
|
757
|
-
|
758
|
-
You can set this to 1000 to start the IDs at 1+1000 instead of 1.
|
759
|
-
|
760
754
|
|
761
755
|
## Paying via Stripe
|
762
756
|
|
@@ -40,11 +40,11 @@ module Effective
|
|
40
40
|
|
41
41
|
Effective::Order.transaction do
|
42
42
|
begin
|
43
|
-
if @order.save_billing_address? && @order.user.respond_to?(:billing_address)
|
43
|
+
if @order.save_billing_address? && @order.user.respond_to?(:billing_address) && @order.billing_address.try(:empty?) == false
|
44
44
|
@order.user.billing_address = @order.billing_address
|
45
45
|
end
|
46
46
|
|
47
|
-
if @order.save_shipping_address? && @order.user.respond_to?(:shipping_address)
|
47
|
+
if @order.save_shipping_address? && @order.user.respond_to?(:shipping_address) && @order.shipping_address.try(:empty?) == false
|
48
48
|
@order.user.shipping_address = @order.shipping_address
|
49
49
|
end
|
50
50
|
|
@@ -8,17 +8,10 @@ module Effective
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def moneris_postback
|
11
|
-
|
12
|
-
response_order_id = response_order_id - EffectiveOrders.moneris[:order_nudge].to_i
|
13
|
-
|
14
|
-
@order ||= Effective::Order.find_by_id(response_order_id)
|
15
|
-
raise ActiveRecord::RecordNotFound unless @order
|
11
|
+
@order ||= Effective::Order.find(params[:response_order_id])
|
16
12
|
|
17
13
|
EffectiveOrders.authorized?(self, :update, @order)
|
18
14
|
|
19
|
-
# Store the Order Nudge if present, so we can have this information in our order_purchased hash
|
20
|
-
params[:order_nudge] = EffectiveOrders.moneris[:order_nudge] if EffectiveOrders.moneris[:order_nudge].to_i > 0
|
21
|
-
|
22
15
|
# Delete the Purchased and Declined Redirect URLs
|
23
16
|
purchased_redirect_url = params.delete(:rvar_purchased_redirect_url)
|
24
17
|
declined_redirect_url = params.delete(:rvar_declined_redirect_url)
|
@@ -18,7 +18,7 @@ module EffectivePaypalHelper
|
|
18
18
|
:notify_url => effective_orders.paypal_postback_url,
|
19
19
|
:cert_id => EffectiveOrders.paypal[:cert_id],
|
20
20
|
:currency_code => EffectiveOrders.paypal[:currency],
|
21
|
-
:invoice => order.id
|
21
|
+
:invoice => order.id,
|
22
22
|
:amount => (order.subtotal / 100.0).round(2),
|
23
23
|
:tax_cart => (order.tax / 100.0).round(2)
|
24
24
|
}
|
@@ -4,22 +4,30 @@ if defined?(EffectiveDatatables)
|
|
4
4
|
class Orders < Effective::Datatable
|
5
5
|
default_order :purchased_at, :desc
|
6
6
|
|
7
|
-
table_column :id
|
8
|
-
order.to_param
|
9
|
-
end
|
7
|
+
table_column :id
|
10
8
|
|
11
|
-
table_column :email, :column => 'users.email', :label => 'Buyer', :if => Proc.new { attributes[:user_id].blank? } do |order|
|
9
|
+
table_column :email, :column => 'users.email', :label => 'Buyer Email', :if => Proc.new { attributes[:user_id].blank? } do |order|
|
12
10
|
link_to order[:email], (edit_admin_user_path(order.user_id) rescue admin_user_path(order.user_id) rescue '#')
|
13
11
|
end
|
14
12
|
|
13
|
+
if EffectiveOrders.require_billing_address
|
14
|
+
table_column :full_name, :sortable => false, :label => 'Buyer Name', :if => Proc.new { attributes[:user_id].blank? } do |order|
|
15
|
+
(order[:full_name] || '').split('!!SEP!!').find { |name| name.present? }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
15
19
|
table_column :order_items, :sortable => false, :column => 'order_items.title' do |order|
|
16
20
|
content_tag(:ul) do
|
17
|
-
order[:order_items].split('!!
|
21
|
+
(order[:order_items] || '').split('!!SEP!!').map { |oi| content_tag(:li, oi) }.join().html_safe
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
table_column :purchased_at
|
22
26
|
|
27
|
+
table_column :purchase_state, :filter => {:type => :select, :values => [['abandoned', 'abandoned'], [EffectiveOrders::PURCHASED, EffectiveOrders::PURCHASED], [EffectiveOrders::DECLINED, EffectiveOrders::DECLINED]], :selected => EffectiveOrders::PURCHASED} do |order|
|
28
|
+
order.purchase_state || 'abandoned'
|
29
|
+
end
|
30
|
+
|
23
31
|
table_column :total do |order|
|
24
32
|
price_to_currency(order[:total].to_i)
|
25
33
|
end
|
@@ -34,7 +42,7 @@ if defined?(EffectiveDatatables)
|
|
34
42
|
end
|
35
43
|
|
36
44
|
def collection
|
37
|
-
collection = Effective::Order.unscoped
|
45
|
+
collection = Effective::Order.unscoped
|
38
46
|
.joins(:user)
|
39
47
|
.joins(:order_items)
|
40
48
|
.group('users.email')
|
@@ -42,7 +50,14 @@ if defined?(EffectiveDatatables)
|
|
42
50
|
.select('users.email AS email')
|
43
51
|
.select('orders.*')
|
44
52
|
.select("#{query_total} AS total")
|
45
|
-
.select("string_agg(order_items.title, '!!
|
53
|
+
.select("string_agg(order_items.title, '!!SEP!!') AS order_items")
|
54
|
+
|
55
|
+
if EffectiveOrders.require_billing_address
|
56
|
+
collection = collection
|
57
|
+
.joins("LEFT OUTER JOIN addresses ON addresses.addressable_id = orders.id AND addresses.addressable_type = 'Effective::Order'")
|
58
|
+
.select("string_agg(addresses.full_name, '!!SEP!!') AS full_name")
|
59
|
+
.where("addresses IS NULL OR addresses.category = 'billing'")
|
60
|
+
end
|
46
61
|
|
47
62
|
if attributes[:user_id].present?
|
48
63
|
collection.where(:user_id => attributes[:user_id])
|
@@ -59,6 +74,8 @@ if defined?(EffectiveDatatables)
|
|
59
74
|
def search_column(collection, table_column, search_term)
|
60
75
|
if table_column[:name] == 'total'
|
61
76
|
collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
|
77
|
+
elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
|
78
|
+
collection.where(:purchase_state => nil)
|
62
79
|
else
|
63
80
|
super
|
64
81
|
end
|
@@ -6,7 +6,7 @@ module Effective
|
|
6
6
|
acts_as_obfuscated :format => '###-####-###'
|
7
7
|
end
|
8
8
|
|
9
|
-
acts_as_addressable :billing => EffectiveOrders.require_billing_address, :shipping => EffectiveOrders.require_shipping_address
|
9
|
+
acts_as_addressable :billing => {:presence => EffectiveOrders.require_billing_address, :use_full_name => true}, :shipping => {:presence => EffectiveOrders.require_shipping_address, :use_full_name => true}
|
10
10
|
attr_accessor :save_billing_address, :save_shipping_address, :shipping_address_same_as_billing # save these addresses to the user if selected
|
11
11
|
|
12
12
|
belongs_to :user # This is the user who purchased the order
|
@@ -96,8 +96,15 @@ module Effective
|
|
96
96
|
def user=(user)
|
97
97
|
super
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
if user.respond_to?(:billing_address) && EffectiveOrders.require_billing_address
|
100
|
+
self.billing_address = user.billing_address
|
101
|
+
self.billing_address.full_name = billing_name if self.billing_address.present? && self.billing_address.full_name.blank?
|
102
|
+
end
|
103
|
+
|
104
|
+
if user.respond_to?(:shipping_address) && EffectiveOrders.require_shipping_address
|
105
|
+
self.shipping_address = user.shipping_address
|
106
|
+
self.shipping_address.full_name = billing_name if self.shipping_address.present? && self.shipping_address.full_name.blank?
|
107
|
+
end
|
101
108
|
end
|
102
109
|
|
103
110
|
# This is used for updating Subscription codes.
|
@@ -160,12 +167,12 @@ module Effective
|
|
160
167
|
def billing_name
|
161
168
|
if billing_address.try(:full_name).present?
|
162
169
|
billing_address.full_name
|
163
|
-
elsif user.to_s.start_with?('#<User:') == false
|
164
|
-
user.to_s
|
165
170
|
elsif user.respond_to?(:full_name)
|
166
171
|
user.full_name.to_s
|
167
172
|
elsif user.respond_to?(:first_name) && user.respond_to?(:last_name)
|
168
173
|
user.first_name.to_s + ' ' + user.last_name.to_s
|
174
|
+
elsif user.to_s.start_with?('#<User:') == false
|
175
|
+
user.to_s
|
169
176
|
else
|
170
177
|
''
|
171
178
|
end
|
@@ -8,15 +8,14 @@
|
|
8
8
|
%tbody
|
9
9
|
%tr
|
10
10
|
%td{:style => 'text-align: left;'}
|
11
|
-
- if order.billing_address.
|
11
|
+
- if EffectiveOrders.require_billing_address && order.billing_address.present?
|
12
|
+
= render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => order.user.email}
|
13
|
+
- else
|
12
14
|
= order.billing_name
|
13
15
|
%br
|
14
16
|
= mail_to(order.user.email)
|
15
17
|
%br
|
16
18
|
|
17
|
-
- if order.billing_address.present?
|
18
|
-
= render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => (order.user.email if order.billing_address.try(:full_name).present?)}
|
19
|
-
|
20
19
|
- if EffectiveOrders.require_shipping_address && order.shipping_address.present?
|
21
20
|
%td{:style => 'text-align: left;'}
|
22
21
|
= render :partial => 'effective/addresses/address', :locals => {:address => order.shipping_address}
|
@@ -13,11 +13,7 @@
|
|
13
13
|
= hidden_field_tag(:email, order.user.try(:email))
|
14
14
|
= hidden_field_tag(:cust_id, order.user.to_param)
|
15
15
|
|
16
|
-
|
17
|
-
- if EffectiveOrders.moneris[:include_billing_name_in_order_id] == true
|
18
|
-
- moneris_order_id = moneris_order_id + '-' + order.billing_name.parameterize
|
19
|
-
|
20
|
-
= hidden_field_tag(:order_id, moneris_order_id)
|
16
|
+
= hidden_field_tag(:order_id, [order.to_param, order.billing_name.try(:parameterize).presence].compact.join('-'))
|
21
17
|
= hidden_field_tag(:gst, '%.2f' % (order.tax / 100.0))
|
22
18
|
= hidden_field_tag(:charge_total, '%.2f' % (order.total / 100.0))
|
23
19
|
|
@@ -30,6 +26,8 @@
|
|
30
26
|
|
31
27
|
- if order.billing_address.present?
|
32
28
|
- address = order.billing_address
|
29
|
+
= hidden_field_tag(:bill_first_name, address.first_name)
|
30
|
+
= hidden_field_tag(:bill_last_name, address.last_name)
|
33
31
|
= hidden_field_tag(:bill_address_one, address.address1)
|
34
32
|
= hidden_field_tag(:bill_city, address.city)
|
35
33
|
= hidden_field_tag(:bill_state_or_province, address.state)
|
@@ -142,18 +142,14 @@ EffectiveOrders.setup do |config|
|
|
142
142
|
:ps_store_id => '',
|
143
143
|
:hpp_key => '',
|
144
144
|
:hpp_url => 'https://www3.moneris.com/HPPDP/index.php',
|
145
|
-
:verify_url => 'https://www3.moneris.com/HPPDP/verifyTxn.php'
|
146
|
-
:order_nudge => 0,
|
147
|
-
:include_billing_name_in_order_id => false
|
145
|
+
:verify_url => 'https://www3.moneris.com/HPPDP/verifyTxn.php'
|
148
146
|
}
|
149
147
|
else
|
150
148
|
config.moneris = {
|
151
149
|
:ps_store_id => '',
|
152
150
|
:hpp_key => '',
|
153
151
|
:hpp_url => 'https://esqa.moneris.com/HPPDP/index.php',
|
154
|
-
:verify_url => 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
|
155
|
-
:order_nudge => 0,
|
156
|
-
:include_billing_name_in_order_id => false
|
152
|
+
:verify_url => 'https://esqa.moneris.com/HPPDP/verifyTxn.php'
|
157
153
|
}
|
158
154
|
end
|
159
155
|
|
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: 1.2.
|
4
|
+
version: 1.2.4
|
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: 2014-12-
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|