flowcommerce_spree 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
---
|
2
|
-
SHA256:
|
3
|
-
metadata.gz: c53cdffe59a872bd84ce53aedf0765dff2f282a09114b49da5835ce16b612eb6
|
4
|
-
data.tar.gz: c4279e859c545ce2b7e212fb388b461956aa53ce26fa85db352395e4d9ade47e
|
5
2
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95290cdfeae1006b8ebedf57d37755bf553c11111d09bb6fb81e856e15672763ecefb751f2a3d928e6e81c27f8a62fdc1c96de562b8b86ecb12c790735b02234
|
4
|
+
data.tar.gz: 6fc0c835d7c0e6fc9ee7e0dd95e6faa4924c81c09f8014cba04c1fb053825157f76415a9f15dc7c4f6b4098344bce937e151da84c359619f34f55dbed5b17cb2
|
@@ -36,8 +36,7 @@ module FlowcommerceSpree
|
|
36
36
|
|
37
37
|
def store_payment_capture(order, capture)
|
38
38
|
upsert_order_captures(order, capture)
|
39
|
-
|
40
|
-
map_payment_captures_to_spree(order, payments) if payments.present?
|
39
|
+
map_payment_captures_to_spree(order)
|
41
40
|
order
|
42
41
|
end
|
43
42
|
|
@@ -52,33 +51,31 @@ module FlowcommerceSpree
|
|
52
51
|
order.update_column(:meta, order.meta.to_json)
|
53
52
|
end
|
54
53
|
|
55
|
-
def map_payment_captures_to_spree(order
|
54
|
+
def map_payment_captures_to_spree(order)
|
55
|
+
payments = order.flow_io_payments
|
56
56
|
order.flow_data['captures']&.each do |c|
|
57
|
-
next unless
|
57
|
+
next unless c['status'] == 'succeeded'
|
58
|
+
|
59
|
+
payment = map_payment(payments, c, order)
|
60
|
+
next unless payment
|
58
61
|
|
59
62
|
payment.capture_events.create!(amount: c['amount'], meta: { 'flow_data' => { 'id' => c['id'] } })
|
60
63
|
return if payment.completed? || payment.capture_events.sum(:amount) < payment.amount
|
61
64
|
|
62
65
|
payment.complete
|
63
66
|
end
|
64
|
-
|
65
67
|
return if order.completed?
|
66
68
|
return unless order.flow_io_captures_sum >= order.flow_io_total_amount && order.flow_io_balance_amount <= 0
|
67
69
|
|
68
70
|
FlowcommerceSpree::OrderUpdater.new(order: order).finalize_order
|
69
71
|
end
|
70
72
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
payment = order.payments.first
|
73
|
+
def map_payment(payments, capture, order)
|
74
|
+
payments.present? ? captured_payment(payments, capture) : get_payments_from_flow(order, capture)
|
75
|
+
end
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
payment.identifier = capture.dig('authorization', 'key')
|
79
|
-
payment.save
|
80
|
-
return payment
|
81
|
-
end
|
77
|
+
def captured_payment(flow_order_payments, capture)
|
78
|
+
auth = capture.dig('authorization', 'id')
|
82
79
|
|
83
80
|
return unless flow_order_payments&.find { |p| p['reference'] == auth }
|
84
81
|
|
@@ -88,6 +85,23 @@ module FlowcommerceSpree
|
|
88
85
|
|
89
86
|
payment
|
90
87
|
end
|
88
|
+
|
89
|
+
def get_payments_from_flow(order, capture)
|
90
|
+
flow_io_order ||= FlowcommerceSpree.client.orders
|
91
|
+
.get_by_number(FlowcommerceSpree::ORGANIZATION, order.number).to_hash
|
92
|
+
return unless flow_io_order[:payments]
|
93
|
+
|
94
|
+
order.flow_data['order']['payments'] = flow_io_order[:payments]
|
95
|
+
attrs_to_update = { meta: order.meta.to_json }
|
96
|
+
attrs_to_update.merge!(order.prepare_flow_addresses)
|
97
|
+
order.update_columns(attrs_to_update)
|
98
|
+
payment = order.payments.first
|
99
|
+
payment.response_code = capture.dig('authorization', 'id')
|
100
|
+
payment.identifier = capture.dig('authorization', 'id')
|
101
|
+
payment.save
|
102
|
+
|
103
|
+
payment
|
104
|
+
end
|
91
105
|
end
|
92
106
|
end
|
93
107
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurel Branzeanu
|
8
8
|
- Sebastian De Luca
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-03-
|
12
|
+
date: 2022-03-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_model_serializers
|
@@ -270,7 +270,7 @@ homepage: https://github.com/mejuri-inc/flowcommerce_spree
|
|
270
270
|
licenses:
|
271
271
|
- MIT
|
272
272
|
metadata: {}
|
273
|
-
post_install_message:
|
273
|
+
post_install_message:
|
274
274
|
rdoc_options: []
|
275
275
|
require_paths:
|
276
276
|
- lib
|
@@ -285,8 +285,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
285
|
- !ruby/object:Gem::Version
|
286
286
|
version: '0'
|
287
287
|
requirements: []
|
288
|
-
rubygems_version: 3.0.
|
289
|
-
signing_key:
|
288
|
+
rubygems_version: 3.0.9
|
289
|
+
signing_key:
|
290
290
|
specification_version: 4
|
291
291
|
summary: Integration of Spree with Flow API
|
292
292
|
test_files: []
|