defra_ruby_govpay 0.2.8 → 1.0.1
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/CHANGELOG.md +21 -0
- data/Gemfile.lock +50 -46
- data/README.md +4 -4
- data/lib/defra_ruby_govpay/object.rb +1 -1
- data/lib/defra_ruby_govpay/services/{govpay_webhook_base_service.rb → webhook_base_service.rb} +6 -6
- data/lib/defra_ruby_govpay/services/{govpay_webhook_body_validator_service.rb → webhook_body_validator_service.rb} +2 -2
- data/lib/defra_ruby_govpay/services/{govpay_webhook_payment_service.rb → webhook_payment_service.rb} +4 -4
- data/lib/defra_ruby_govpay/services/{govpay_webhook_refund_service.rb → webhook_refund_service.rb} +1 -1
- data/lib/defra_ruby_govpay/services/{govpay_webhook_sanitizer_service.rb → webhook_sanitizer_service.rb} +1 -1
- data/lib/defra_ruby_govpay/services/{govpay_webhook_signature_service.rb → webhook_signature_service.rb} +2 -2
- data/lib/defra_ruby_govpay/version.rb +1 -1
- data/lib/defra_ruby_govpay.rb +6 -6
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e5fd2d57466db964dd8229643792ecec297ce9b4d154d282e34c01ce6b5503a
|
4
|
+
data.tar.gz: d6eb1d75bc6e05124f23b30b6aabfb1b8d612ff1afba2e23b312e31b14269970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b107a66a0d092c18f17ce65b5712fa6d48698f770d5fb606a7cefe5e66c3da09816378327781cc2ee69916d22ad2560f90b6477d52823c18a426ff10b7018e18
|
7
|
+
data.tar.gz: d1297c85b66ce8716440a339fb08cf4efb7b06e87bb1dfa9d646cc5de03e1b1354604ffdcb6af61e0d20ce79cf267d25ab6342236c609811ca411d77e4889aec
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/DEFRA/defra-ruby-govpay/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v1.0.0...HEAD)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Fix/ruby 3682 webhook payment not found [\#36](https://github.com/DEFRA/defra-ruby-govpay/pull/36) ([PaulDoyle-EA](https://github.com/PaulDoyle-EA))
|
10
|
+
|
11
|
+
## [v1.0.0](https://github.com/DEFRA/defra-ruby-govpay/tree/v1.0.0) (2025-04-30)
|
12
|
+
|
13
|
+
[Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.8...v1.0.0)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Version 1.0.0 - Major release for renamed webhook services [\#35](https://github.com/DEFRA/defra-ruby-govpay/pull/35) ([jjromeo](https://github.com/jjromeo))
|
18
|
+
- \[RUBY-3757\] Refactor webhook handling services in Govpay gem [\#34](https://github.com/DEFRA/defra-ruby-govpay/pull/34) ([jjromeo](https://github.com/jjromeo))
|
19
|
+
|
3
20
|
## [v0.2.8](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.8) (2025-04-29)
|
4
21
|
|
5
22
|
[Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.7...v0.2.8)
|
@@ -8,6 +25,10 @@
|
|
8
25
|
|
9
26
|
- RUBY 3757 wcr tech move govpay webhook handling to the govpay gem [\#32](https://github.com/DEFRA/defra-ruby-govpay/pull/32) ([jjromeo](https://github.com/jjromeo))
|
10
27
|
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- Bump version to 0.2.8 and update changelog [\#33](https://github.com/DEFRA/defra-ruby-govpay/pull/33) ([jjromeo](https://github.com/jjromeo))
|
31
|
+
|
11
32
|
## [v0.2.7](https://github.com/DEFRA/defra-ruby-govpay/tree/v0.2.7) (2025-04-28)
|
12
33
|
|
13
34
|
[Full Changelog](https://github.com/DEFRA/defra-ruby-govpay/compare/v0.2.6...v0.2.7)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
defra_ruby_govpay (0.
|
4
|
+
defra_ruby_govpay (1.0.1)
|
5
5
|
rest-client (~> 2.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -17,9 +17,9 @@ GEM
|
|
17
17
|
minitest (>= 5.1)
|
18
18
|
mutex_m
|
19
19
|
tzinfo (~> 2.0)
|
20
|
-
addressable (2.8.
|
21
|
-
public_suffix (>= 2.0.2, <
|
22
|
-
ast (2.4.
|
20
|
+
addressable (2.8.7)
|
21
|
+
public_suffix (>= 2.0.2, < 7.0)
|
22
|
+
ast (2.4.3)
|
23
23
|
async (2.6.5)
|
24
24
|
console (~> 1.10)
|
25
25
|
fiber-annotation
|
@@ -41,21 +41,22 @@ GEM
|
|
41
41
|
async-pool (0.4.0)
|
42
42
|
async (>= 1.25)
|
43
43
|
base64 (0.1.1)
|
44
|
-
bigdecimal (3.
|
44
|
+
bigdecimal (3.2.2)
|
45
45
|
byebug (11.1.3)
|
46
46
|
concurrent-ruby (1.2.2)
|
47
47
|
connection_pool (2.4.1)
|
48
48
|
console (1.23.2)
|
49
49
|
fiber-annotation
|
50
50
|
fiber-local
|
51
|
-
crack (0.
|
51
|
+
crack (1.0.0)
|
52
|
+
bigdecimal
|
52
53
|
rexml
|
53
54
|
defra_ruby_style (0.4.0)
|
54
55
|
rubocop (>= 1.0, < 2.0)
|
55
56
|
rubocop-factory_bot
|
56
57
|
rubocop-rake
|
57
58
|
rubocop-rspec
|
58
|
-
diff-lcs (1.
|
59
|
+
diff-lcs (1.6.2)
|
59
60
|
domain_name (0.5.20190701)
|
60
61
|
unf (>= 0.0.5, < 1.0.0)
|
61
62
|
drb (2.1.1)
|
@@ -78,15 +79,16 @@ GEM
|
|
78
79
|
octokit (~> 4.6)
|
79
80
|
rainbow (>= 2.2.1)
|
80
81
|
rake (>= 10.0)
|
81
|
-
hashdiff (1.0
|
82
|
+
hashdiff (1.2.0)
|
82
83
|
http-accept (1.7.0)
|
83
84
|
http-cookie (1.0.5)
|
84
85
|
domain_name (~> 0.5)
|
85
86
|
i18n (1.14.1)
|
86
87
|
concurrent-ruby (~> 1.0)
|
87
88
|
io-event (1.3.3)
|
88
|
-
json (2.
|
89
|
-
language_server-protocol (3.17.0.
|
89
|
+
json (2.13.2)
|
90
|
+
language_server-protocol (3.17.0.5)
|
91
|
+
lint_roller (1.1.0)
|
90
92
|
mime-types (3.5.1)
|
91
93
|
mime-types-data (~> 3.2015)
|
92
94
|
mime-types-data (3.2023.0808)
|
@@ -97,10 +99,11 @@ GEM
|
|
97
99
|
octokit (4.25.1)
|
98
100
|
faraday (>= 1, < 3)
|
99
101
|
sawyer (~> 0.9)
|
100
|
-
parallel (1.
|
101
|
-
parser (3.
|
102
|
+
parallel (1.27.0)
|
103
|
+
parser (3.3.9.0)
|
102
104
|
ast (~> 2.4.1)
|
103
105
|
racc
|
106
|
+
prism (1.4.0)
|
104
107
|
protocol-hpack (1.4.2)
|
105
108
|
protocol-http (0.25.0)
|
106
109
|
protocol-http1 (0.16.0)
|
@@ -108,53 +111,52 @@ GEM
|
|
108
111
|
protocol-http2 (0.15.1)
|
109
112
|
protocol-hpack (~> 1.4)
|
110
113
|
protocol-http (~> 0.18)
|
111
|
-
public_suffix (
|
112
|
-
racc (1.
|
114
|
+
public_suffix (6.0.2)
|
115
|
+
racc (1.8.1)
|
113
116
|
rainbow (3.1.1)
|
114
117
|
rake (13.1.0)
|
115
|
-
regexp_parser (2.
|
118
|
+
regexp_parser (2.11.0)
|
116
119
|
rest-client (2.1.0)
|
117
120
|
http-accept (>= 1.7.0, < 2.0)
|
118
121
|
http-cookie (>= 1.0.2, < 2.0)
|
119
122
|
mime-types (>= 1.16, < 4.0)
|
120
123
|
netrc (~> 0.8)
|
121
|
-
rexml (3.
|
122
|
-
rspec (3.
|
123
|
-
rspec-core (~> 3.
|
124
|
-
rspec-expectations (~> 3.
|
125
|
-
rspec-mocks (~> 3.
|
126
|
-
rspec-core (3.
|
127
|
-
rspec-support (~> 3.
|
128
|
-
rspec-expectations (3.
|
124
|
+
rexml (3.4.1)
|
125
|
+
rspec (3.13.1)
|
126
|
+
rspec-core (~> 3.13.0)
|
127
|
+
rspec-expectations (~> 3.13.0)
|
128
|
+
rspec-mocks (~> 3.13.0)
|
129
|
+
rspec-core (3.13.5)
|
130
|
+
rspec-support (~> 3.13.0)
|
131
|
+
rspec-expectations (3.13.5)
|
129
132
|
diff-lcs (>= 1.2.0, < 2.0)
|
130
|
-
rspec-support (~> 3.
|
131
|
-
rspec-mocks (3.
|
133
|
+
rspec-support (~> 3.13.0)
|
134
|
+
rspec-mocks (3.13.5)
|
132
135
|
diff-lcs (>= 1.2.0, < 2.0)
|
133
|
-
rspec-support (~> 3.
|
134
|
-
rspec-support (3.
|
135
|
-
rubocop (1.
|
136
|
+
rspec-support (~> 3.13.0)
|
137
|
+
rspec-support (3.13.4)
|
138
|
+
rubocop (1.79.1)
|
136
139
|
json (~> 2.3)
|
137
|
-
language_server-protocol (
|
140
|
+
language_server-protocol (~> 3.17.0.2)
|
141
|
+
lint_roller (~> 1.1.0)
|
138
142
|
parallel (~> 1.10)
|
139
|
-
parser (>= 3.
|
143
|
+
parser (>= 3.3.0.2)
|
140
144
|
rainbow (>= 2.2.2, < 4.0)
|
141
|
-
regexp_parser (>=
|
142
|
-
|
143
|
-
rubocop-ast (>= 1.28.1, < 2.0)
|
145
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
146
|
+
rubocop-ast (>= 1.46.0, < 2.0)
|
144
147
|
ruby-progressbar (~> 1.7)
|
145
|
-
unicode-display_width (>= 2.4.0, <
|
146
|
-
rubocop-ast (1.
|
147
|
-
parser (>= 3.
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
rubocop (~> 1.
|
148
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
149
|
+
rubocop-ast (1.46.0)
|
150
|
+
parser (>= 3.3.7.2)
|
151
|
+
prism (~> 1.4)
|
152
|
+
rubocop-factory_bot (2.27.1)
|
153
|
+
lint_roller (~> 1.1)
|
154
|
+
rubocop (~> 1.72, >= 1.72.1)
|
152
155
|
rubocop-rake (0.6.0)
|
153
156
|
rubocop (~> 1.0)
|
154
|
-
rubocop-rspec (
|
155
|
-
|
156
|
-
rubocop
|
157
|
-
rubocop-factory_bot (~> 2.22)
|
157
|
+
rubocop-rspec (3.6.0)
|
158
|
+
lint_roller (~> 1.1)
|
159
|
+
rubocop (~> 1.72, >= 1.72.1)
|
158
160
|
ruby-progressbar (1.13.0)
|
159
161
|
ruby2_keywords (0.0.5)
|
160
162
|
sawyer (0.9.2)
|
@@ -167,8 +169,10 @@ GEM
|
|
167
169
|
unf (0.1.4)
|
168
170
|
unf_ext
|
169
171
|
unf_ext (0.0.8.2)
|
170
|
-
unicode-display_width (
|
171
|
-
|
172
|
+
unicode-display_width (3.1.4)
|
173
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
174
|
+
unicode-emoji (4.0.4)
|
175
|
+
webmock (3.25.1)
|
172
176
|
addressable (>= 2.8.0)
|
173
177
|
crack (>= 0.3.2)
|
174
178
|
hashdiff (>= 0.4.0, < 2.0.0)
|
data/README.md
CHANGED
@@ -88,11 +88,11 @@ The webhook services extract and return data from the webhook payload:
|
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
# For payment webhooks
|
91
|
-
result = DefraRubyGovpay::
|
91
|
+
result = DefraRubyGovpay::WebhookPaymentService.run(webhook_body)
|
92
92
|
# => { id: "hu20sqlact5260q2nanm0q8u93", status: "success" }
|
93
93
|
|
94
94
|
# For refund webhooks
|
95
|
-
result = DefraRubyGovpay::
|
95
|
+
result = DefraRubyGovpay::WebhookRefundService.run(webhook_body)
|
96
96
|
# => { id: "789", payment_id: "original-payment-123", status: "success" }
|
97
97
|
```
|
98
98
|
|
@@ -123,8 +123,8 @@ The gem can handle both payment and refund webhooks:
|
|
123
123
|
|
124
124
|
The appropriate service class will be used based on the webhook type:
|
125
125
|
|
126
|
-
- `
|
127
|
-
- `
|
126
|
+
- `WebhookPaymentService` for payment webhooks
|
127
|
+
- `WebhookRefundService` for refund webhooks
|
128
128
|
|
129
129
|
## Testing
|
130
130
|
|
data/lib/defra_ruby_govpay/services/{govpay_webhook_base_service.rb → webhook_base_service.rb}
RENAMED
@@ -3,8 +3,8 @@
|
|
3
3
|
require "active_support/core_ext/object/blank"
|
4
4
|
|
5
5
|
module DefraRubyGovpay
|
6
|
-
class
|
7
|
-
class
|
6
|
+
class WebhookBaseService
|
7
|
+
class InvalidStatusTransition < StandardError; end
|
8
8
|
|
9
9
|
attr_accessor :webhook_body, :previous_status
|
10
10
|
|
@@ -31,7 +31,7 @@ module DefraRubyGovpay
|
|
31
31
|
else
|
32
32
|
DefraRubyGovpay.logger.warn(
|
33
33
|
"Status \"#{@previous_status}\" unchanged in #{payment_or_refund_str} webhook update " \
|
34
|
-
"#{log_webhook_context}"
|
34
|
+
"#{log_webhook_context} "
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
@@ -44,9 +44,9 @@ module DefraRubyGovpay
|
|
44
44
|
def validate_status_transition
|
45
45
|
return if self.class::VALID_STATUS_TRANSITIONS[previous_status]&.include?(webhook_payment_or_refund_status)
|
46
46
|
|
47
|
-
raise
|
48
|
-
|
49
|
-
|
47
|
+
raise InvalidStatusTransition, "Invalid #{payment_or_refund_str} status transition " \
|
48
|
+
"from #{previous_status} to #{webhook_payment_or_refund_status}" \
|
49
|
+
"#{log_webhook_context}"
|
50
50
|
end
|
51
51
|
|
52
52
|
def extract_data_from_webhook
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DefraRubyGovpay
|
4
|
-
class
|
4
|
+
class WebhookBodyValidatorService
|
5
5
|
class ValidationFailure < StandardError; end
|
6
6
|
|
7
7
|
def self.run(body:, signature:)
|
8
8
|
raise ValidationFailure, "Missing expected signature" if signature.blank?
|
9
9
|
|
10
|
-
body_signatures =
|
10
|
+
body_signatures = WebhookSignatureService.run(body:)
|
11
11
|
return true if body_signatures[:front_office] == signature || body_signatures[:back_office] == signature
|
12
12
|
|
13
13
|
raise ValidationFailure, "digest/signature header mismatch"
|
data/lib/defra_ruby_govpay/services/{govpay_webhook_payment_service.rb → webhook_payment_service.rb}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DefraRubyGovpay
|
4
|
-
class
|
4
|
+
class WebhookPaymentService < WebhookBaseService
|
5
5
|
|
6
6
|
VALID_STATUS_TRANSITIONS = {
|
7
|
-
"created" => %w[started submitted success failed cancelled error],
|
8
|
-
"started" => %w[submitted success failed cancelled error],
|
9
|
-
"submitted" => %w[success failed cancelled error],
|
7
|
+
"created" => %w[started submitted success failed cancelled expired error],
|
8
|
+
"started" => %w[submitted success failed cancelled expired error],
|
9
|
+
"submitted" => %w[success failed cancelled expired error],
|
10
10
|
"success" => %w[],
|
11
11
|
"failed" => %w[],
|
12
12
|
"cancelled" => %w[],
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DefraRubyGovpay
|
4
|
-
class
|
4
|
+
class WebhookSignatureService
|
5
5
|
class DigestFailure < StandardError; end
|
6
6
|
|
7
7
|
def self.run(body:)
|
@@ -11,7 +11,7 @@ module DefraRubyGovpay
|
|
11
11
|
def run(body:)
|
12
12
|
generate_signatures(body.to_s)
|
13
13
|
rescue StandardError => e
|
14
|
-
DefraRubyGovpay.logger.error "
|
14
|
+
DefraRubyGovpay.logger.error "Payment webhook signature generation failed: #{e}"
|
15
15
|
raise DigestFailure, e
|
16
16
|
end
|
17
17
|
|
data/lib/defra_ruby_govpay.rb
CHANGED
@@ -9,12 +9,12 @@ require_relative "defra_ruby_govpay/payment"
|
|
9
9
|
require_relative "defra_ruby_govpay/refund"
|
10
10
|
require_relative "defra_ruby_govpay/error"
|
11
11
|
require_relative "defra_ruby_govpay/api"
|
12
|
-
require_relative "defra_ruby_govpay/services/
|
13
|
-
require_relative "defra_ruby_govpay/services/
|
14
|
-
require_relative "defra_ruby_govpay/services/
|
15
|
-
require_relative "defra_ruby_govpay/services/
|
16
|
-
require_relative "defra_ruby_govpay/services/
|
17
|
-
require_relative "defra_ruby_govpay/services/
|
12
|
+
require_relative "defra_ruby_govpay/services/webhook_base_service"
|
13
|
+
require_relative "defra_ruby_govpay/services/webhook_payment_service"
|
14
|
+
require_relative "defra_ruby_govpay/services/webhook_refund_service"
|
15
|
+
require_relative "defra_ruby_govpay/services/webhook_sanitizer_service"
|
16
|
+
require_relative "defra_ruby_govpay/services/webhook_signature_service"
|
17
|
+
require_relative "defra_ruby_govpay/services/webhook_body_validator_service"
|
18
18
|
|
19
19
|
# The DefraRubyGovpay module facilitates integration with Govpay services.
|
20
20
|
# It provides a convenient and configurable way to interact with Govpay APIs in Defra's ruby applications.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defra_ruby_govpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerome Pratt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04
|
11
|
+
date: 2025-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -53,12 +53,12 @@ files:
|
|
53
53
|
- lib/defra_ruby_govpay/object.rb
|
54
54
|
- lib/defra_ruby_govpay/payment.rb
|
55
55
|
- lib/defra_ruby_govpay/refund.rb
|
56
|
-
- lib/defra_ruby_govpay/services/
|
57
|
-
- lib/defra_ruby_govpay/services/
|
58
|
-
- lib/defra_ruby_govpay/services/
|
59
|
-
- lib/defra_ruby_govpay/services/
|
60
|
-
- lib/defra_ruby_govpay/services/
|
61
|
-
- lib/defra_ruby_govpay/services/
|
56
|
+
- lib/defra_ruby_govpay/services/webhook_base_service.rb
|
57
|
+
- lib/defra_ruby_govpay/services/webhook_body_validator_service.rb
|
58
|
+
- lib/defra_ruby_govpay/services/webhook_payment_service.rb
|
59
|
+
- lib/defra_ruby_govpay/services/webhook_refund_service.rb
|
60
|
+
- lib/defra_ruby_govpay/services/webhook_sanitizer_service.rb
|
61
|
+
- lib/defra_ruby_govpay/services/webhook_signature_service.rb
|
62
62
|
- lib/defra_ruby_govpay/version.rb
|
63
63
|
- sig/defra_ruby_govpay.rbs
|
64
64
|
homepage: https://github.com/DEFRA/defra-ruby-govpay
|