killbill-orbital 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/orbital/api.rb +19 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91350a421679b6f95e4962578817e7c0f0df4752
|
4
|
+
data.tar.gz: d4a57c435bd04c18aec2e350a82840860c507173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910086570f85138191317e400c3418dee367cde8f924d2ee12dd4460feb2e6daccf6765cde51ed3369246f715bef6d49aac438db3b705be0fa1746401377f552
|
7
|
+
data.tar.gz: cc81b8b0ee456cae8f15cabafb7e2cebc066b16ba30fe496de9f1f85b04f674e3e250b481cc072e2e9973a7547f0581a554405f2739707342c9210ac756f67df
|
data/lib/orbital/api.rb
CHANGED
@@ -148,36 +148,42 @@ module Killbill #:nodoc:
|
|
148
148
|
|
149
149
|
def try_fix_undefined_trxs(plugin_trxs_info, options, context)
|
150
150
|
stale = false
|
151
|
-
auth_order_id =
|
151
|
+
auth_order_id, authorization = find_auth_order_id_and_authorization(plugin_trxs_info)
|
152
152
|
plugin_trxs_info.each do |plugin_trx_info|
|
153
153
|
next unless should_try_to_fix_trx plugin_trx_info, options
|
154
154
|
# Resort to auth order id for scenarios like MarkForCapture where Orbital Order Id is not persisted
|
155
155
|
# when remote call fails.
|
156
156
|
order_id = plugin_trx_info.second_payment_reference_id.nil? ? auth_order_id : plugin_trx_info.second_payment_reference_id
|
157
|
-
stale = true if fix_undefined_trx plugin_trx_info, order_id, context, options
|
157
|
+
stale = true if fix_undefined_trx plugin_trx_info, order_id, authorization, context, options
|
158
158
|
end
|
159
159
|
stale
|
160
160
|
end
|
161
161
|
|
162
|
-
def
|
163
|
-
|
164
|
-
|
162
|
+
def find_auth_order_id_and_authorization(plugin_trxs_info)
|
163
|
+
auth_plugin_info = plugin_trxs_info.find { |info| info.transaction_type == :AUTHORIZE && !info.second_payment_reference_id.nil? }
|
164
|
+
if auth_plugin_info.nil?
|
165
|
+
return [nil, nil]
|
166
|
+
end
|
167
|
+
[auth_plugin_info.second_payment_reference_id,
|
168
|
+
find_value_from_properties(auth_plugin_info.properties, 'authorization')]
|
165
169
|
end
|
166
170
|
|
167
171
|
def should_try_to_fix_trx(plugin_trx_info, options)
|
168
172
|
plugin_trx_info.status == :UNDEFINED && pass_delay_time(plugin_trx_info, options)
|
169
173
|
end
|
170
174
|
|
171
|
-
def fix_undefined_trx(plugin_trx_info, order_id, context, options)
|
175
|
+
def fix_undefined_trx(plugin_trx_info, order_id, authorization, context, options)
|
172
176
|
payment_processor_account_id = find_value_from_properties(plugin_trx_info.properties, 'payment_processor_account_id')
|
173
177
|
trace_number = find_value_from_properties(plugin_trx_info.properties, 'trace_number')
|
174
178
|
return false if trace_number.nil? || order_id.nil? || payment_processor_account_id.nil?
|
175
179
|
|
176
180
|
gateway = lookup_gateway(payment_processor_account_id, context.tenant_id)
|
177
181
|
if plugin_trx_info.transaction_type == :CAPTURE
|
178
|
-
|
182
|
+
logger.info("Attempt to fix UNDEFINED capture for kb_transaction_id='#{plugin_trx_info.kb_transaction_payment_id}'")
|
183
|
+
response, amount, currency = retry_capture(plugin_trx_info, order_id, authorization, trace_number, context, gateway)
|
179
184
|
update_response_if_needed plugin_trx_info, order_id, response, options, amount, currency
|
180
185
|
else
|
186
|
+
logger.info("Attempt to query UNDEFINED transaction for kb_transaction_id='#{plugin_trx_info.kb_transaction_payment_id}'")
|
181
187
|
response = inquiry(order_id, trace_number, gateway)
|
182
188
|
update_response_if_needed plugin_trx_info, order_id, response, options
|
183
189
|
end
|
@@ -228,17 +234,18 @@ module Killbill #:nodoc:
|
|
228
234
|
gateway.inquiry(order_id, trace_number)
|
229
235
|
end
|
230
236
|
|
231
|
-
def retry_capture(plugin_trx_info, order_id, trace_number, context, gateway)
|
237
|
+
def retry_capture(plugin_trx_info, order_id, authorization, trace_number, context, gateway)
|
232
238
|
options = {:trace_number => trace_number, :order_id => order_id}
|
233
|
-
|
239
|
+
|
240
|
+
# Pass a cloned object of context to avoid being modified in get_payment via to_java
|
241
|
+
kb_payment = @kb_apis.payment_api.get_payment(plugin_trx_info.kb_payment_id, false, false, [], context.clone)
|
234
242
|
kb_transaction = kb_payment.transactions.detect {|trx| trx.id == plugin_trx_info.kb_transaction_payment_id}
|
235
|
-
linked_trx = @transaction_model.authorizations_from_kb_payment_id(plugin_trx_info.kb_payment_id, context.tenant_id).last
|
236
243
|
|
237
244
|
amount = kb_transaction.amount
|
238
245
|
currency = kb_transaction.currency
|
239
246
|
return [gateway.capture(to_cents(amount, currency),
|
240
|
-
|
241
|
-
|
247
|
+
authorization,
|
248
|
+
options),
|
242
249
|
amount,
|
243
250
|
currency]
|
244
251
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: killbill-orbital
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kill Bill core team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|