flowcommerce_spree 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/services/flowcommerce_spree/webhooks/capture_upserted_v2.rb +13 -4
- data/app/workers/flowcommerce_spree/flow_io_worker.rb +16 -0
- data/app/workers/flowcommerce_spree/import_item_worker.rb +1 -11
- data/app/workers/flowcommerce_spree/update_payment_capture_worker.rb +15 -0
- data/lib/flowcommerce_spree/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad7616da6a9fb5e7fbffe0a8869730ffedacb91deec3a5d08f328d2b876338ad
|
4
|
+
data.tar.gz: 76ffd0d23d05028ba0d24df80fa5a092efe62f0b5f14ddde339e73ede5ee53bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb2b92c39dd528cc4990d9957ee5dba29fbdfa39d7f7a4b821d07a6f5cb366541821b67a6d23ccbc9854b3c3c0867e0cd3fff8b36f64cea627b2fa6d7da47df
|
7
|
+
data.tar.gz: 75175908d8ff3a85ca061ea82890af39544e66bf5898409e0b38d467bc40880eb6ac8e1773263cc5e933ef54d28bf00a2fb1a3f5cddbd935793b92c7fa0e89f2
|
@@ -22,16 +22,25 @@ module FlowcommerceSpree
|
|
22
22
|
errors << { message: 'Order number param missing' } && (return self) unless order_number
|
23
23
|
|
24
24
|
if (order = Spree::Order.find_by(number: order_number))
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
if order.payments.any?
|
26
|
+
store_payment_capture(order, capture)
|
27
|
+
else
|
28
|
+
FlowcommerceSpree::UpdatePaymentCaptureWorker.perform_in(1.minute, order.number, capture)
|
29
|
+
order
|
30
|
+
end
|
29
31
|
else
|
30
32
|
errors << { message: "Order #{order_number} not found" }
|
31
33
|
self
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
37
|
+
def store_payment_capture(order, capture)
|
38
|
+
upsert_order_captures(order, capture)
|
39
|
+
payments = order.flow_io_payments
|
40
|
+
map_payment_captures_to_spree(order, payments) if payments.present?
|
41
|
+
order
|
42
|
+
end
|
43
|
+
|
35
44
|
private
|
36
45
|
|
37
46
|
def upsert_order_captures(order, capture)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FlowcommerceSpree
|
4
|
+
class FlowIoWorker
|
5
|
+
include Sidekiq::Worker
|
6
|
+
|
7
|
+
sidekiq_retries_exhausted do |message, exception|
|
8
|
+
Rails.logger.warn("[!] #{self.class} max attempts reached: #{message} - #{exception}")
|
9
|
+
notification_setting = FlowcommerceSpree::Config.notification_setting
|
10
|
+
return unless notification_setting[:slack].present?
|
11
|
+
|
12
|
+
slack_message = "[#{Rails.env}] #{message}"
|
13
|
+
Slack_client.chat_postMessage(channel: notification_setting[:slack][:channel], text: slack_message)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,19 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module FlowcommerceSpree
|
4
|
-
class ImportItemWorker
|
5
|
-
include Sidekiq::Worker
|
4
|
+
class ImportItemWorker < FlowIoWorker
|
6
5
|
sidekiq_options retry: 3, queue: :flow_io
|
7
6
|
|
8
|
-
sidekiq_retries_exhausted do |message, exception|
|
9
|
-
Rails.logger.warn("[!] FlowcommerceSpree::ImportItemWorker max attempts reached: #{message} - #{exception}")
|
10
|
-
notification_setting = FlowcommerceSpree::Config.notification_setting
|
11
|
-
return unless notification_setting[:slack].present?
|
12
|
-
|
13
|
-
slack_message = "[#{Rails.env}] #{message}"
|
14
|
-
Slack_client.chat_postMessage(channel: notification_setting[:slack][:channel], text: slack_message)
|
15
|
-
end
|
16
|
-
|
17
7
|
def perform(variant_sku)
|
18
8
|
variant = Spree::Variant.find_by sku: variant_sku
|
19
9
|
return unless variant
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FlowcommerceSpree
|
4
|
+
class UpdatePaymentCaptureWorker < FlowIoWorker
|
5
|
+
sidekiq_options retry: 3, queue: :flow_io
|
6
|
+
|
7
|
+
def perform(order_number, capture = {})
|
8
|
+
order = Spree::Order.find_by number: order_number
|
9
|
+
raise 'Order has no payments' if order.payments.empty?
|
10
|
+
|
11
|
+
FlowcommerceSpree::Webhooks::CaptureUpsertedV2.new({ capture: capture }.as_json)
|
12
|
+
.store_payment_capture(order, capture)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flowcommerce_spree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurel Branzeanu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_model_serializers
|
@@ -244,7 +244,9 @@ files:
|
|
244
244
|
- app/views/spree/admin/promotions/edit.html.erb
|
245
245
|
- app/views/spree/admin/shared/_order_summary.html.erb
|
246
246
|
- app/views/spree/admin/shared/_order_summary_flow.html.erb
|
247
|
+
- app/workers/flowcommerce_spree/flow_io_worker.rb
|
247
248
|
- app/workers/flowcommerce_spree/import_item_worker.rb
|
249
|
+
- app/workers/flowcommerce_spree/update_payment_capture_worker.rb
|
248
250
|
- config/rails_best_practices.yml
|
249
251
|
- config/routes.rb
|
250
252
|
- db/migrate/20201021160159_add_type_and_meta_to_spree_zone.rb
|