spree_vpago 2.2.0.pre.addpaymentlogger → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/spree/vpago_payments_controller.rb +6 -6
- data/app/controllers/spree/webhook/payways_controller.rb +3 -1
- data/app/jobs/vpago/payment_processor_job.rb +25 -42
- data/app/lib/vpago/timing_helper.rb +0 -7
- data/lib/spree_vpago/version.rb +1 -1
- metadata +3 -4
- data/lib/vpago_logger.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2271ef4085b1b2500020ecd39827f0f541aa3be1ad309c6e7c543886a96f187a
|
|
4
|
+
data.tar.gz: a27992641ba3daa6c8d2edc6f001ea44b0ee9ba02ec1f68f07a548375bf20d10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 886dba98f702d241f54ab46992ed61881f5ecc13a2577bc780cbdd4cfc21fc8e48b683578d9596215cb1a260d070e8b55e079627964be17a9b026a8bcce80274
|
|
7
|
+
data.tar.gz: d47511e24d645ff2d71ebc24b9f784525716466956b415f72bbc494803ffde5e8edc13ae5c3cba526b79c15669cae34b31367066e2a181cab0072568f5ba06a5
|
data/Gemfile.lock
CHANGED
|
@@ -102,9 +102,9 @@ module Spree
|
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def log_enqueue_start(payment, enqueued_at, return_params = {})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
Rails.logger.info(
|
|
106
|
+
{
|
|
107
|
+
event: 'vpago.payment_processor_job.enqueue',
|
|
108
108
|
payment_number: payment.number,
|
|
109
109
|
order_number: payment.order&.number,
|
|
110
110
|
request_id: request.request_id,
|
|
@@ -118,9 +118,9 @@ module Spree
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def log_enqueue_error(error)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
Rails.logger.error(
|
|
122
|
+
{
|
|
123
|
+
event: 'vpago.payment_processor_job.enqueue.error',
|
|
124
124
|
request_id: request.request_id,
|
|
125
125
|
payment_number: @payment&.number,
|
|
126
126
|
error_class: error.class.name,
|
|
@@ -6,66 +6,49 @@ module Vpago
|
|
|
6
6
|
queue_as :payment_processing
|
|
7
7
|
|
|
8
8
|
def perform(options)
|
|
9
|
-
started_at =
|
|
10
|
-
enqueued_at = options[:enqueued_at]
|
|
11
|
-
queue_wait_ms = calculate_queue_wait_ms(enqueued_at)
|
|
12
|
-
|
|
13
|
-
log_job_start(options[:payment_number], queue_wait_ms)
|
|
14
|
-
|
|
15
|
-
payment = Spree::Payment.find_by!(number: options[:payment_number])
|
|
16
|
-
Vpago::PaymentProcessor.new(payment: payment).call
|
|
17
|
-
|
|
18
|
-
log_job_finish(options[:payment_number], queue_wait_ms, started_at)
|
|
19
|
-
rescue StandardError => e
|
|
20
|
-
log_job_error(options[:payment_number], queue_wait_ms, started_at, e)
|
|
21
|
-
raise
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
def calculate_queue_wait_ms(enqueued_at)
|
|
27
|
-
return nil unless enqueued_at
|
|
9
|
+
started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
enqueued_at = options[:enqueued_at]
|
|
12
|
+
queue_wait_ms = if enqueued_at
|
|
13
|
+
((Time.now.to_f - enqueued_at.to_f) * 1000.0).round(1)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Rails.logger.info(
|
|
17
|
+
{
|
|
18
|
+
event: 'vpago.payment_processor_job.start',
|
|
19
|
+
payment_number: options[:payment_number],
|
|
37
20
|
queue: self.class.queue_name,
|
|
38
21
|
queue_wait_ms: queue_wait_ms
|
|
39
22
|
}
|
|
40
23
|
)
|
|
41
|
-
end
|
|
42
24
|
|
|
43
|
-
|
|
25
|
+
payment = Spree::Payment.find_by!(number: options[:payment_number])
|
|
26
|
+
Vpago::PaymentProcessor.new(payment: payment).call
|
|
27
|
+
|
|
44
28
|
runtime_ms = Vpago::TimingHelper.elapsed_ms(started_at)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
payment_number: payment_number,
|
|
29
|
+
Rails.logger.info(
|
|
30
|
+
{
|
|
31
|
+
event: 'vpago.payment_processor_job.finish',
|
|
32
|
+
payment_number: options[:payment_number],
|
|
49
33
|
queue: self.class.queue_name,
|
|
50
34
|
queue_wait_ms: queue_wait_ms,
|
|
51
35
|
runtime_ms: runtime_ms
|
|
52
36
|
}
|
|
53
37
|
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def log_job_error(payment_number, queue_wait_ms, started_at, error)
|
|
38
|
+
rescue StandardError => e
|
|
57
39
|
runtime_ms = Vpago::TimingHelper.elapsed_ms(started_at)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
payment_number: payment_number,
|
|
40
|
+
Rails.logger.error(
|
|
41
|
+
{
|
|
42
|
+
event: 'vpago.payment_processor_job.error',
|
|
43
|
+
payment_number: options[:payment_number],
|
|
62
44
|
queue: self.class.queue_name,
|
|
63
45
|
queue_wait_ms: queue_wait_ms,
|
|
64
46
|
runtime_ms: runtime_ms,
|
|
65
|
-
error_class:
|
|
66
|
-
error_message:
|
|
47
|
+
error_class: e.class.name,
|
|
48
|
+
error_message: e.message
|
|
67
49
|
}
|
|
68
50
|
)
|
|
51
|
+
raise
|
|
69
52
|
end
|
|
70
53
|
end
|
|
71
54
|
end
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
module Vpago
|
|
2
2
|
module TimingHelper
|
|
3
|
-
# Gets the current monotonic timestamp.
|
|
4
|
-
#
|
|
5
|
-
# @return [Float] current timestamp from Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
6
|
-
def self.current_time
|
|
7
|
-
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
3
|
# Measures elapsed time in milliseconds from a given start timestamp.
|
|
11
4
|
#
|
|
12
5
|
# @param started_at [Float] timestamp from Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
data/lib/spree_vpago/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_vpago
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.0
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
@@ -419,7 +419,6 @@ files:
|
|
|
419
419
|
- lib/vpago/wing_sdk/payment_retriever.rb
|
|
420
420
|
- lib/vpago/wing_sdk/transaction_status_checker.rb
|
|
421
421
|
- lib/vpago/wing_sdk/transaction_status_response.rb
|
|
422
|
-
- lib/vpago_logger.rb
|
|
423
422
|
- node_modules/.yarn-integrity
|
|
424
423
|
- package-lock.json
|
|
425
424
|
- package.json
|
|
@@ -441,9 +440,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
441
440
|
version: 3.2.0
|
|
442
441
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
443
442
|
requirements:
|
|
444
|
-
- - "
|
|
443
|
+
- - ">="
|
|
445
444
|
- !ruby/object:Gem::Version
|
|
446
|
-
version:
|
|
445
|
+
version: '0'
|
|
447
446
|
requirements:
|
|
448
447
|
- none
|
|
449
448
|
rubygems_version: 3.4.1
|
data/lib/vpago_logger.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module VpagoLogger
|
|
2
|
-
def self.log(event:, data: nil)
|
|
3
|
-
message = { event: event }
|
|
4
|
-
message.merge!(data) if data
|
|
5
|
-
|
|
6
|
-
Rails.logger.info(message.to_json)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def self.error(event:, data: nil)
|
|
10
|
-
message = { event: event }
|
|
11
|
-
message.merge!(data) if data
|
|
12
|
-
|
|
13
|
-
Rails.logger.error(message.to_json)
|
|
14
|
-
end
|
|
15
|
-
end
|