effective_orders 5.2.10 → 5.2.14
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: ae0df61fdb7c2803f9995ae38a41bcc827bd99d454d3675b7584ffe04b5500af
|
4
|
+
data.tar.gz: 0b5bb484fa7dde9ea40562bf36376e43ec006a0e7b56ed73495a660970e23180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8957ad6317f7a94de506f9e3ab55ea1df775ce589c744e3c49dd65929df2a63221930622c01163ba5b88292b8c5b34652e32d3025cefd0c4e56281e6ebb6bc5d
|
7
|
+
data.tar.gz: b05fc9a89f5ddd375dd0569a6b6e92b0ea06669a83e540e77730ace9983a3cfd47065785bcc4d9beb5a840452c295511dada7e132933cbbbe61f597dd5f095f1
|
@@ -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, '').first(50)
|
69
|
+
end
|
70
|
+
|
65
71
|
end
|
@@ -484,7 +484,7 @@ module Effective
|
|
484
484
|
self.payment = payment_to_h(payment) if self.payment.blank?
|
485
485
|
|
486
486
|
begin
|
487
|
-
|
487
|
+
Effective::Order.transaction do
|
488
488
|
run_purchasable_callbacks(:before_purchase)
|
489
489
|
|
490
490
|
save!
|
@@ -493,7 +493,7 @@ module Effective
|
|
493
493
|
run_purchasable_callbacks(:after_purchase)
|
494
494
|
end
|
495
495
|
rescue => e
|
496
|
-
|
496
|
+
Effective::Order.transaction do
|
497
497
|
save!(validate: false)
|
498
498
|
update_purchasables_purchased_order!
|
499
499
|
end
|
@@ -533,7 +533,7 @@ module Effective
|
|
533
533
|
skip_buyer_validations: true
|
534
534
|
)
|
535
535
|
|
536
|
-
|
536
|
+
Effective::Order.transaction do
|
537
537
|
begin
|
538
538
|
run_purchasable_callbacks(:before_decline)
|
539
539
|
save!(validate: validate)
|
@@ -611,7 +611,7 @@ module Effective
|
|
611
611
|
|
612
612
|
def assign_order_totals
|
613
613
|
self.subtotal = present_order_items.map { |oi| oi.subtotal }.sum
|
614
|
-
self.tax_rate = get_tax_rate()
|
614
|
+
self.tax_rate = get_tax_rate()
|
615
615
|
self.tax = get_tax()
|
616
616
|
self.total = subtotal + (tax || 0)
|
617
617
|
end
|
@@ -665,11 +665,19 @@ module Effective
|
|
665
665
|
|
666
666
|
def run_purchasable_callbacks(name)
|
667
667
|
order_items.select { |item| item.purchasable.respond_to?(name) }.each do |item|
|
668
|
-
|
668
|
+
if item.class.respond_to?(:transaction)
|
669
|
+
item.class.transaction { item.purchasable.public_send(name, self, item) }
|
670
|
+
else
|
671
|
+
item.purchasable.public_send(name, self, item)
|
672
|
+
end
|
669
673
|
end
|
670
674
|
|
671
675
|
if parent.respond_to?(name)
|
672
|
-
|
676
|
+
if parent.class.respond_to?(:transaction)
|
677
|
+
parent.class.transaction { parent.public_send(name, self) }
|
678
|
+
else
|
679
|
+
parent.public_send(name, self)
|
680
|
+
end
|
673
681
|
end
|
674
682
|
|
675
683
|
true
|
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.14
|
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:
|
11
|
+
date: 2022-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|