effective_orders 5.2.7 → 5.2.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed1d4a8621f678e9117f8e6e562220ebe988ce26febfbf30cf7b842ff1a2c04
|
4
|
+
data.tar.gz: 97271616a90392d36fbe3ff5302b5f3437a6fafb010ca478a386a28265939aaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd81818649ad2d7527492260d7e84ad2cbf4a2fbc3af3d0aef32f2385bec5b7ae891ec176e02955a6e479090f1092a19ea1b06bcea9fdbc79fb62466e6ca2aab
|
7
|
+
data.tar.gz: c1d4d06ced8f1b9910c6b0610ca44a6dfb981448400876df1f1bdcd68d282e1d4ee1984c018adcca6bd1be367b548d02a9769bd9cb312fa850cacf7ca08e5113
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module EffectiveMonerisCheckoutHelper
|
2
|
+
SCRUB = /[^\w\d#,\s]/
|
2
3
|
|
3
4
|
def moneris_checkout_preload_request(order)
|
4
5
|
# Make the Preload Request
|
@@ -19,8 +20,8 @@ module EffectiveMonerisCheckoutHelper
|
|
19
20
|
language: 'en',
|
20
21
|
|
21
22
|
contact_details: {
|
22
|
-
first_name: order.billing_first_name,
|
23
|
-
last_name: order.billing_last_name,
|
23
|
+
first_name: moneris_checkout_scrub(order.billing_first_name),
|
24
|
+
last_name: moneris_checkout_scrub(order.billing_last_name),
|
24
25
|
email: order.email,
|
25
26
|
}
|
26
27
|
}
|
@@ -28,9 +29,9 @@ module EffectiveMonerisCheckoutHelper
|
|
28
29
|
if (address = order.billing_address).present?
|
29
30
|
params.merge!(
|
30
31
|
billing_details: {
|
31
|
-
address_1: address.address1,
|
32
|
-
address_2: address.address2,
|
33
|
-
city: address.city,
|
32
|
+
address_1: moneris_checkout_scrub(address.address1),
|
33
|
+
address_2: moneris_checkout_scrub(address.address2),
|
34
|
+
city: moneris_checkout_scrub(address.city),
|
34
35
|
province: address.state_code,
|
35
36
|
country: address.country_code,
|
36
37
|
postal_code: address.postal_code
|
@@ -41,8 +42,8 @@ module EffectiveMonerisCheckoutHelper
|
|
41
42
|
if (address = order.shipping_address).present?
|
42
43
|
params.merge!(
|
43
44
|
shipping_details: {
|
44
|
-
address_1: address.address1,
|
45
|
-
address_2: address.address2,
|
45
|
+
address_1: moneris_checkout_scrub(address.address1),
|
46
|
+
address_2: moneris_checkout_scrub(address.address2),
|
46
47
|
city: address.city,
|
47
48
|
province: address.state_code,
|
48
49
|
country: address.country_code,
|
@@ -62,4 +63,9 @@ module EffectiveMonerisCheckoutHelper
|
|
62
63
|
}
|
63
64
|
end
|
64
65
|
|
66
|
+
def moneris_checkout_scrub(value)
|
67
|
+
return value unless value.kind_of?(String)
|
68
|
+
value.gsub(SCRUB, '')
|
69
|
+
end
|
70
|
+
|
65
71
|
end
|
@@ -103,7 +103,7 @@ module Effective
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# User validations -- An admin skips these when working in the admin/ namespace
|
106
|
-
with_options unless: -> { pending? || skip_buyer_validations? } do
|
106
|
+
with_options unless: -> { pending? || skip_buyer_validations? || purchased? } do
|
107
107
|
validates :tax_rate, presence: { message: "can't be determined based on billing address" }
|
108
108
|
validates :tax, presence: true
|
109
109
|
|
@@ -190,6 +190,31 @@ module Effective
|
|
190
190
|
self
|
191
191
|
end
|
192
192
|
|
193
|
+
def remove(*items)
|
194
|
+
raise 'unable to alter a purchased order' if purchased?
|
195
|
+
raise 'unable to alter a declined order' if declined?
|
196
|
+
|
197
|
+
removed = items.map do |item|
|
198
|
+
order_item = if item.kind_of?(Effective::OrderItem)
|
199
|
+
order_items.find { |oi| oi == item }
|
200
|
+
else
|
201
|
+
order_items.find { |oi| oi.purchasable == item }
|
202
|
+
end
|
203
|
+
|
204
|
+
raise("Unable to find order item for #{item}") if order_item.blank?
|
205
|
+
order_item
|
206
|
+
end
|
207
|
+
|
208
|
+
removed.each { |order_item| order_item.mark_for_destruction }
|
209
|
+
|
210
|
+
# Make sure to reset stored aggregates
|
211
|
+
self.total = nil
|
212
|
+
self.subtotal = nil
|
213
|
+
self.tax = nil
|
214
|
+
|
215
|
+
removed.length == 1 ? removed.first : removed
|
216
|
+
end
|
217
|
+
|
193
218
|
# Items can be an Effective::Cart, an Effective::order, a single acts_as_purchasable, or multiple acts_as_purchasables
|
194
219
|
# add(Product.first) => returns an Effective::OrderItem
|
195
220
|
# add(Product.first, current_cart) => returns an array of Effective::OrderItems
|
@@ -249,7 +274,7 @@ module Effective
|
|
249
274
|
raise('already purchased') if purchased?
|
250
275
|
raise('must be pending or confirmed') unless pending? || confirmed?
|
251
276
|
|
252
|
-
|
277
|
+
present_order_items.each do |item|
|
253
278
|
purchasable = item.purchasable
|
254
279
|
|
255
280
|
if purchasable.blank? || purchasable.marked_for_destruction?
|
@@ -318,9 +343,9 @@ module Effective
|
|
318
343
|
Effective::Order.new(self)
|
319
344
|
end
|
320
345
|
|
321
|
-
# For moneris and moneris_checkout. Just a unique value.
|
346
|
+
# For moneris and moneris_checkout. Just a unique value. Must be 50 characters or fewer or will raise moneris error.
|
322
347
|
def transaction_id
|
323
|
-
[to_param, billing_name.to_s.parameterize.presence, Time.zone.now.to_i, rand(
|
348
|
+
[to_param, billing_name.to_s.parameterize.first(20).presence, Time.zone.now.to_i, rand(1000..9999)].compact.join('-')
|
324
349
|
end
|
325
350
|
|
326
351
|
def billing_first_name
|
@@ -358,11 +383,11 @@ module Effective
|
|
358
383
|
end
|
359
384
|
|
360
385
|
def purchasables
|
361
|
-
|
386
|
+
present_order_items.map { |order_item| order_item.purchasable }
|
362
387
|
end
|
363
388
|
|
364
389
|
def subtotal
|
365
|
-
self[:subtotal] ||
|
390
|
+
self[:subtotal] || present_order_items.map { |oi| oi.subtotal }.sum
|
366
391
|
end
|
367
392
|
|
368
393
|
def tax_rate
|
@@ -386,7 +411,7 @@ module Effective
|
|
386
411
|
end
|
387
412
|
|
388
413
|
def num_items
|
389
|
-
|
414
|
+
present_order_items.map { |oi| oi.quantity }.sum
|
390
415
|
end
|
391
416
|
|
392
417
|
def send_order_receipt_to_admin?
|
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.2.
|
4
|
+
version: 5.2.11
|
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-12-
|
11
|
+
date: 2021-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|