mangopay4-ruby-sdk 4.1.0 → 5.0.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/CHANGELOG.md +47 -0
- data/README.md +11 -0
- data/lib/mangopay/filter_parameters.rb +2 -0
- data/lib/mangopay/mandate.rb +5 -0
- data/lib/mangopay/pay_in.rb +8 -0
- data/lib/mangopay/settlement.rb +5 -0
- data/lib/mangopay/user.rb +4 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +1 -60
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bd7beac79732aa8cae909461d807f0cc3ef839853769c0ce64ef1d0c441f42f
|
|
4
|
+
data.tar.gz: d30d538650c57b7f7fd7d8b37a5bd67b48aba85c1640abef2abfb3dce7d759fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8698d33faee622d7c048f132c7dfecfb68a7acce58acedd859f5dd83f4dbac6cda79141c8f56cda1495bb06fed5e1ac408890a7d03b7f32175e83fb52c356e67
|
|
7
|
+
data.tar.gz: c3e03c384bfdb8ceff7ecc4a7cb6a4adb337c583170202cb38a8df1fda12f3a079f5a090d298fdae372aa367733c6dd66e580082bd6dad4ccaaf1099e8c231e2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
## [5.0.0] - 2026-11-04
|
|
2
|
+
### Added – Legal user PSCs
|
|
3
|
+
- Added `MangoPay::User.get_pscs` to fetch the PSCs (persons with significant control) of a legal user: `GET /users/{UserId}/pscs`
|
|
4
|
+
|
|
5
|
+
### Changed - `clientId` and `clientPassword` configuration for tests
|
|
6
|
+
- The sandbox credentials are now set as environment variables in the tests. The tests will not start if the variables are not set.
|
|
7
|
+
|
|
8
|
+
### Fixed – GET and DELETE requests no longer send a request body
|
|
9
|
+
Previously every request sent the JSON-encoded `params` as its body, regardless of the HTTP method. Since `params` defaults to `{}`, all GET and DELETE requests went out with a body of `{}` (`Content-Length: 2`). CloudFront (used by the new mTLS infrastructure) rejects GET requests with a body and responds immediately with `403 Forbidden`.
|
|
10
|
+
|
|
11
|
+
The body is now only attached for methods that allow one (POST, PUT, PATCH), using Ruby's built-in `Net::HTTPGenericRequest#request_body_permitted?`. In `MangoPay.request` (`lib/mangopay.rb`):
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
# before
|
|
15
|
+
req.body = JSON.dump(params)
|
|
16
|
+
|
|
17
|
+
# after
|
|
18
|
+
req.body = JSON.dump(params) if req.request_body_permitted?
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Impact
|
|
22
|
+
- **`params` on GET/DELETE are no longer sent.** Anything passed as `params` to a GET or DELETE call is now ignored. This affects direct calls to `MangoPay.request(:get, url, params)`. Query parameters must be passed as `filters` (4th argument) instead: `MangoPay.request(:get, url, {}, filters)`.
|
|
23
|
+
- **`before_request_proc` receives `req.body == nil` for GET and DELETE** (previously `"{}"`). Code inside the proc that parses the body, e.g. `JSON.parse(req.body)`, will raise `TypeError` and must handle `nil`. The proc still runs after the SDK assigns the body, so it can still set a body itself if needed.
|
|
24
|
+
- **`MangoPay::FilterParameters.request` now handles an empty body.** It returns `''` for a `nil` or empty body (matching `FilterParameters.response`), instead of raising `NoMethodError: undefined method 'each' for nil`. Without this, every GET and DELETE would have failed before being sent whenever request logging is enabled (`MangoPay.configuration.logger` or `MangoPay.configuration.log_file` set).
|
|
25
|
+
- **Request log lines for GET and DELETE no longer show `{}` as the request params.** The params part of the request line is now empty (the line ends right after the quoted URL). The response line is unchanged, e.g.:
|
|
26
|
+
```
|
|
27
|
+
# before
|
|
28
|
+
I [2026-11-03T10:00:00+01:00] GET "https://api.sandbox.mangopay.com/v2.01/client-id/users/123" {}
|
|
29
|
+
[85.2ms] 200 {"Id":"123", ...}
|
|
30
|
+
# after
|
|
31
|
+
I [2026-11-03T10:00:00+01:00] GET "https://api.sandbox.mangopay.com/v2.01/client-id/users/123"
|
|
32
|
+
[85.2ms] 200 {"Id":"123", ...}
|
|
33
|
+
```
|
|
34
|
+
Update any log parsing that expects the `{}` on GET/DELETE request lines. POST/PUT/PATCH log lines are unchanged.
|
|
35
|
+
- **Test stubs in your own test suite** (e.g. WebMock or VCR) that match GET/DELETE requests on `body: "{}"` will no longer match and need to be updated (or cassettes re-recorded).
|
|
36
|
+
- POST, PUT and PATCH requests, authentication and response handling are unchanged.
|
|
37
|
+
|
|
38
|
+
### Removed – unused `MangoPay.request_multipart`
|
|
39
|
+
- Removed `MangoPay.request_multipart` from `lib/mangopay.rb`. It was no longer called anywhere in the SDK. Note that the method was public: if your code calls `MangoPay.request_multipart` directly, it will now raise `NoMethodError`.
|
|
40
|
+
|
|
41
|
+
## [4.2.0] - 2026-10-15
|
|
42
|
+
### Added – Mandate recipients, PayIn Intents/Splits & Settlements listing
|
|
43
|
+
- Added `MangoPay::Mandate.fetch_for_recipient` to list the mandates belonging to a given user's recipient
|
|
44
|
+
- Added `MangoPay::PayIn::PayInIntent::Intent.get_all` to list pay-in intents
|
|
45
|
+
- Added `MangoPay::PayIn::PayInIntent::Split.get_all` to list pay-in intent splits
|
|
46
|
+
- Added `MangoPay::Settlement.get_all` to list settlements
|
|
47
|
+
|
|
1
48
|
## [4.1.0] - 2026-10-01
|
|
2
49
|
### Added – Extended Preauthorizations
|
|
3
50
|
- Added `MangoPay::ExtendedPreauthorization` with:
|
data/README.md
CHANGED
|
@@ -181,6 +181,17 @@ Make sure that you have run:
|
|
|
181
181
|
```
|
|
182
182
|
bundle install
|
|
183
183
|
```
|
|
184
|
+
|
|
185
|
+
#### Required environment variables
|
|
186
|
+
The test suite reads the MangoPay sandbox test credentials from environment
|
|
187
|
+
variables instead of hardcoding them. The specs fail fast with a clear message
|
|
188
|
+
if a required variable is missing.
|
|
189
|
+
|
|
190
|
+
| Variable | Description |
|
|
191
|
+
|----------------------------|----------------------------------------------------|
|
|
192
|
+
| `MANGOPAY_CLIENT_ID` | Client ID of the sandbox test client |
|
|
193
|
+
| `MANGOPAY_CLIENT_PASSWORD` | API key / password of the sandbox test client |
|
|
194
|
+
|
|
184
195
|
Then to run the test suite, run:
|
|
185
196
|
```
|
|
186
197
|
rspec
|
data/lib/mangopay/mandate.rb
CHANGED
|
@@ -27,6 +27,11 @@ module MangoPay
|
|
|
27
27
|
MangoPay.request(:get, url, {}, filters)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def fetch_for_recipient(user_id, recipient_id, filters = {})
|
|
31
|
+
url = "#{MangoPay.api_path}/users/#{user_id}/recipients/#{recipient_id}/mandates"
|
|
32
|
+
MangoPay.request(:get, url, {}, filters)
|
|
33
|
+
end
|
|
34
|
+
|
|
30
35
|
# Fetches list of transactions belonging to given +mandate_id+.
|
|
31
36
|
#
|
|
32
37
|
# Optional +filters+ is a hash accepting following keys:
|
data/lib/mangopay/pay_in.rb
CHANGED
|
@@ -432,6 +432,10 @@ module MangoPay
|
|
|
432
432
|
MangoPay.request(:get, "#{MangoPay.api_path_v3}/payins/intents/#{intent_id}")
|
|
433
433
|
end
|
|
434
434
|
|
|
435
|
+
def get_all(filters = {})
|
|
436
|
+
MangoPay.request(:get, "#{MangoPay.api_path_v3}/payins/intents", {}, filters)
|
|
437
|
+
end
|
|
438
|
+
|
|
435
439
|
def cancel(intent_id, params, idempotency_key = nil)
|
|
436
440
|
MangoPay.request(:post, "#{MangoPay.api_path_v3}/payins/intents/#{intent_id}/cancel", params, {}, idempotency_key)
|
|
437
441
|
end
|
|
@@ -460,6 +464,10 @@ module MangoPay
|
|
|
460
464
|
MangoPay.request(:get, "#{MangoPay.api_path_v3}/payins/intents/#{intent_id}/splits/#{split_id}")
|
|
461
465
|
end
|
|
462
466
|
|
|
467
|
+
def get_all(filters = {})
|
|
468
|
+
MangoPay.request(:get, "#{MangoPay.api_path_v3}/payins/intents/splits", {}, filters)
|
|
469
|
+
end
|
|
470
|
+
|
|
463
471
|
def update(intent_id, split_id, params)
|
|
464
472
|
MangoPay.request(:put, "#{MangoPay.api_path_v3}/payins/intents/#{intent_id}/splits/#{split_id}", params)
|
|
465
473
|
end
|
data/lib/mangopay/settlement.rb
CHANGED
|
@@ -12,6 +12,11 @@ module MangoPay
|
|
|
12
12
|
MangoPay.request(:get, url)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
def get_all(filters = {})
|
|
16
|
+
url = "#{MangoPay.api_path_v3}/payins/intents/settlements"
|
|
17
|
+
MangoPay.request(:get, url, {}, filters)
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
def generate_new_upload_url(settlement_id, settlement)
|
|
16
21
|
url = "#{MangoPay.api_path_v3}/payins/intents/settlements/#{settlement_id}"
|
|
17
22
|
MangoPay.request(:put, url, settlement, {})
|
data/lib/mangopay/user.rb
CHANGED
|
@@ -99,6 +99,10 @@ module MangoPay
|
|
|
99
99
|
def get_sca_status(user_id, filters = {})
|
|
100
100
|
MangoPay.request(:get, "#{MangoPay.api_path}/sca/users/#{user_id}/sca-status", {}, filters)
|
|
101
101
|
end
|
|
102
|
+
|
|
103
|
+
def get_pscs(user_id)
|
|
104
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/users/#{user_id}/pscs")
|
|
105
|
+
end
|
|
102
106
|
end
|
|
103
107
|
end
|
|
104
108
|
end
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay.rb
CHANGED
|
@@ -235,7 +235,7 @@ module MangoPay
|
|
|
235
235
|
|
|
236
236
|
res = Net::HTTP.start(uri.host, uri.port, **ssl_options) do |http|
|
|
237
237
|
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
|
238
|
-
req.body = JSON.dump(params)
|
|
238
|
+
req.body = JSON.dump(params) if req.request_body_permitted?
|
|
239
239
|
before_request_proc.call(req) if before_request_proc
|
|
240
240
|
do_request(http, req, uri)
|
|
241
241
|
end
|
|
@@ -279,65 +279,6 @@ module MangoPay
|
|
|
279
279
|
data
|
|
280
280
|
end
|
|
281
281
|
|
|
282
|
-
def request_multipart(method, url, file, file_name, idempotency_key = nil)
|
|
283
|
-
uri = api_uri(url)
|
|
284
|
-
|
|
285
|
-
# Set headers
|
|
286
|
-
headers = request_headers
|
|
287
|
-
headers['Idempotency-Key'] = idempotency_key if idempotency_key
|
|
288
|
-
headers['x-tenant-id'] = 'uk' if configuration.uk_header_flag
|
|
289
|
-
|
|
290
|
-
boundary = "#{SecureRandom.hex}"
|
|
291
|
-
headers['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
|
|
292
|
-
|
|
293
|
-
multipart_body = []
|
|
294
|
-
multipart_body << "--#{boundary}"
|
|
295
|
-
multipart_body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{file_name}\""
|
|
296
|
-
multipart_body << ""
|
|
297
|
-
multipart_body << file
|
|
298
|
-
multipart_body << "--#{boundary}--"
|
|
299
|
-
multipart_body << ""
|
|
300
|
-
|
|
301
|
-
# Join string parts and ensure binary content is preserved
|
|
302
|
-
body = multipart_body.map { |part| part.is_a?(String) ? part.force_encoding("ASCII-8BIT") : part }.join("\r\n")
|
|
303
|
-
|
|
304
|
-
res = Net::HTTP.start(uri.host, uri.port, **ssl_options) do |http|
|
|
305
|
-
req_class = Net::HTTP.const_get(method.capitalize)
|
|
306
|
-
req = req_class.new(uri.request_uri, headers)
|
|
307
|
-
req.body = body
|
|
308
|
-
do_request(http, req, uri)
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
raise MangoPay::ResponseError.new(uri, '408', { 'Message' => 'Request Timeout' }) if res.nil?
|
|
312
|
-
|
|
313
|
-
begin
|
|
314
|
-
data = res.body.to_s.empty? ? {} : JSON.load(res.body.to_s)
|
|
315
|
-
rescue MultiJson::ParseError
|
|
316
|
-
raise MangoPay::ResponseError.new(uri, res.code, { 'Message' => res.body })
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
unless res.is_a?(Net::HTTPOK) || res.is_a?(Net::HTTPCreated) || res.is_a?(Net::HTTPNoContent)
|
|
320
|
-
if res.is_a?(Net::HTTPUnauthorized) && res['www-authenticate']
|
|
321
|
-
redirect_url = res['www-authenticate'][/RedirectUrl=(.+)/, 1]
|
|
322
|
-
data['RedirectUrl'] = redirect_url
|
|
323
|
-
data['message'] = 'SCA required to perform this action.'
|
|
324
|
-
end
|
|
325
|
-
raise MangoPay::ResponseError.new(uri, res.code, data)
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
if res['x-ratelimit']
|
|
329
|
-
self.ratelimit = {
|
|
330
|
-
limit: res['x-ratelimit'].split(", "),
|
|
331
|
-
remaining: res['x-ratelimit-remaining'].split(", "),
|
|
332
|
-
reset: res['x-ratelimit-reset'].split(", ")
|
|
333
|
-
}
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
configuration.after_request_proc&.call(data)
|
|
337
|
-
|
|
338
|
-
data
|
|
339
|
-
end
|
|
340
|
-
|
|
341
282
|
# Retrieve a previous response by idempotency_key
|
|
342
283
|
# See https://docs.mangopay.com/api-references/idempotency-support/
|
|
343
284
|
def fetch_response(idempotency_key)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mangopay4-ruby-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geoffroy Lorieux
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-11-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: multi_json
|