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: d0353cf2ee2aded74188e0b12ebf53688b379ef454ae9427a0f7be42f58d97b2
4
- data.tar.gz: 578ffb35d6763cd78abeb18857ce5f11fc9dc7a6acf452227a17e9675ad10f7a
3
+ metadata.gz: ae0df61fdb7c2803f9995ae38a41bcc827bd99d454d3675b7584ffe04b5500af
4
+ data.tar.gz: 0b5bb484fa7dde9ea40562bf36376e43ec006a0e7b56ed73495a660970e23180
5
5
  SHA512:
6
- metadata.gz: 0d0e19c0495b5b67fe7c66a1bf6cda6ce712221d87d6c6baea06a81212d8146ee49fc1237a193cc5340f57c19f426329b59804c97c6afc8c39d4b9a55eee9d2a
7
- data.tar.gz: c59b93ef057b4fc5ef519b4752619b0fe83e03a6e39403c05a1ae92838bcbb3bb8c647878805b2e812f38f98b355ef3306576f0b6a712569d77d73b77494fc35
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
- EffectiveResources.transaction do
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
- EffectiveResources.transaction do
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
- EffectiveResources.transaction do
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() unless (tax_rate || 0) > 0
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
- EffectiveResources.transaction(item) { item.purchasable.public_send(name, self, item) }
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
- EffectiveResources.transaction(parent) { parent.public_send(name, self) }
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.2.10'.freeze
2
+ VERSION = '5.2.14'.freeze
3
3
  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.2.10
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: 2021-12-22 00:00:00.000000000 Z
11
+ date: 2022-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails