mangopay4-ruby-sdk 3.46.0 → 3.47.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 +4 -0
- data/README.md +55 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +41 -10
- 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: 8cc10e268ef7f7029a76cd99da66abdcfbe9a76c7cd1b938992e102758e4396e
|
|
4
|
+
data.tar.gz: 947581ca00b8c352e07be28d4bf5f21f28211a15f6c69afc6595aa669f201249
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7deab526bea4f06430b8b0ce51ee9d7208a7c6e103abb0cced837e4463bf634f5a686215e8ca3a547d57a685b0a7b61912efcb9fb46455c592a96555d6b5a2de
|
|
7
|
+
data.tar.gz: 1dd444f37f32c14ea3f74d9fa12e40a1d1957eee20be9bb121c8707e7df13d6d92a7bd3e07e37756abec1addb3f53e9b0320fa84d451e69dcb02abff99533db8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -19,6 +19,61 @@ or by adding it to your Gemfile ```gem 'mangopay4-ruby-sdk'```
|
|
|
19
19
|
|
|
20
20
|
* Call ```MangoPay.configure``` in your script as shown in the snippet below.
|
|
21
21
|
|
|
22
|
+
## mTLS configuration
|
|
23
|
+
### Set the base URL for mTLS
|
|
24
|
+
|
|
25
|
+
Using mTLS authentication requires your integration to call a base URL with a different hostname from the standard API:
|
|
26
|
+
|
|
27
|
+
* Sandbox: `https://api-mtls.sandbox.mangopay.com`
|
|
28
|
+
* Production: `https://api-mtls.mangopay.com`
|
|
29
|
+
|
|
30
|
+
If using mTLS, your integration should use the `api-mtls` URLs for all API calls, including OAuth token generation.
|
|
31
|
+
|
|
32
|
+
**Caution:** Ensure you set the mTLS base URL, as shown in the configuration examples below. If you don’t, the mTLS certificate will not be transferred to Mangopay. When mTLS is enforced, your integration will result in an error.
|
|
33
|
+
|
|
34
|
+
### Configure the SDK’s mTLS properties
|
|
35
|
+
|
|
36
|
+
The Ruby SDK’s mTLS properties accept one of:
|
|
37
|
+
|
|
38
|
+
* **Base64-encoded string** – To load the certificate content from environment variables
|
|
39
|
+
* **File path** – To point to the locally stored file, for example during testing
|
|
40
|
+
|
|
41
|
+
| Property | Type | Description |
|
|
42
|
+
| --------------------- | ----------------- |------------------------------------------------------------------------------------------|
|
|
43
|
+
| `mtls_cert` | string | Base64-encoded string of the certificate content or path to the certificate `.pem` file. |
|
|
44
|
+
| `mtls_private_key` | string | Base64-encoded string of the private key content or path to the private `.key` file. |
|
|
45
|
+
| `mtls_key_passphrase` | string (optional) | String passphrase if the private key is encrypted. |
|
|
46
|
+
|
|
47
|
+
#### Base64-encoded strings
|
|
48
|
+
|
|
49
|
+
```ruby theme={null}
|
|
50
|
+
MangoPay.configure do |c|
|
|
51
|
+
c.client_id = 'your-mangopay-client-id'
|
|
52
|
+
c.client_apiKey = 'your-mangopay-api-key'
|
|
53
|
+
c.root_url = 'https://api-mtls.sandbox.mangopay.com' # mTLS base URL
|
|
54
|
+
c.preproduction = true
|
|
55
|
+
|
|
56
|
+
c.mtls_cert = ENV['CERTIFICATE_PEM_B64'] # Base64-encoded string
|
|
57
|
+
c.mtls_key = ENV['PRIVATE_KEY_B64'] # Base64-encoded string
|
|
58
|
+
c.mtls_key_passphrase = ENV['YOUR_CERT_PASSPHRASE'] # optional, if encrypted
|
|
59
|
+
end
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### File paths
|
|
63
|
+
|
|
64
|
+
```ruby theme={null}
|
|
65
|
+
MangoPay.configure do |c|
|
|
66
|
+
c.client_id = 'your-mangopay-client-id'
|
|
67
|
+
c.client_apiKey = 'your-mangopay-api-key'
|
|
68
|
+
c.root_url = 'https://api-mtls.sandbox.mangopay.com' # mTLS base URL
|
|
69
|
+
c.preproduction = true
|
|
70
|
+
|
|
71
|
+
c.mtls_cert = '/path/to/certificate.pem' # file path
|
|
72
|
+
c.mtls_key = '/path/to/private.key' # file path
|
|
73
|
+
c.mtls_key_passphrase = 'your-cert-passphrase' # optional, if encrypted
|
|
74
|
+
end
|
|
75
|
+
```
|
|
76
|
+
|
|
22
77
|
### Usage
|
|
23
78
|
|
|
24
79
|
```ruby
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
|
+
require 'openssl'
|
|
3
|
+
require 'base64'
|
|
2
4
|
require 'cgi/util'
|
|
3
5
|
require 'digest/md5'
|
|
4
6
|
require 'multi_json'
|
|
@@ -67,7 +69,8 @@ module MangoPay
|
|
|
67
69
|
:temp_dir, :log_file, :log_trace_headers, :http_timeout,
|
|
68
70
|
:http_max_retries, :http_open_timeout,
|
|
69
71
|
:logger, :use_ssl, :uk_header_flag,
|
|
70
|
-
:after_request_proc
|
|
72
|
+
:after_request_proc,
|
|
73
|
+
:mtls_cert, :mtls_key, :mtls_key_passphrase
|
|
71
74
|
|
|
72
75
|
def apply_configuration
|
|
73
76
|
MangoPay.configure do |config|
|
|
@@ -83,6 +86,9 @@ module MangoPay
|
|
|
83
86
|
config.logger = @logger
|
|
84
87
|
config.uk_header_flag = @uk_header_flag
|
|
85
88
|
config.after_request_proc = @after_request_proc
|
|
89
|
+
config.mtls_cert = @mtls_cert
|
|
90
|
+
config.mtls_key = @mtls_key
|
|
91
|
+
config.mtls_key_passphrase = @mtls_key_passphrase
|
|
86
92
|
end
|
|
87
93
|
end
|
|
88
94
|
|
|
@@ -226,9 +232,7 @@ module MangoPay
|
|
|
226
232
|
headers['x-tenant-id'] = 'uk'
|
|
227
233
|
end
|
|
228
234
|
|
|
229
|
-
res = Net::HTTP.start(uri.host, uri.port,
|
|
230
|
-
:max_retries => configuration.http_max_retries,
|
|
231
|
-
:open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
|
|
235
|
+
res = Net::HTTP.start(uri.host, uri.port, **ssl_options) do |http|
|
|
232
236
|
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
|
233
237
|
req.body = JSON.dump(params)
|
|
234
238
|
before_request_proc.call(req) if before_request_proc
|
|
@@ -296,12 +300,7 @@ module MangoPay
|
|
|
296
300
|
# Join string parts and ensure binary content is preserved
|
|
297
301
|
body = multipart_body.map { |part| part.is_a?(String) ? part.force_encoding("ASCII-8BIT") : part }.join("\r\n")
|
|
298
302
|
|
|
299
|
-
res = Net::HTTP.start(uri.host, uri.port,
|
|
300
|
-
use_ssl: configuration.use_ssl?,
|
|
301
|
-
read_timeout: configuration.http_timeout,
|
|
302
|
-
open_timeout: configuration.http_open_timeout,
|
|
303
|
-
max_retries: configuration.http_max_retries,
|
|
304
|
-
ssl_version: :TLSv1_2) do |http|
|
|
303
|
+
res = Net::HTTP.start(uri.host, uri.port, **ssl_options) do |http|
|
|
305
304
|
req_class = Net::HTTP.const_get(method.capitalize)
|
|
306
305
|
req = req_class.new(uri.request_uri, headers)
|
|
307
306
|
req.body = body
|
|
@@ -380,6 +379,38 @@ module MangoPay
|
|
|
380
379
|
end
|
|
381
380
|
end
|
|
382
381
|
|
|
382
|
+
def ssl_options
|
|
383
|
+
opts = {
|
|
384
|
+
use_ssl: configuration.use_ssl?,
|
|
385
|
+
read_timeout: configuration.http_timeout,
|
|
386
|
+
open_timeout: configuration.http_open_timeout,
|
|
387
|
+
max_retries: configuration.http_max_retries,
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if defined?(OpenSSL::SSL::TLS1_2_VERSION)
|
|
391
|
+
opts[:min_version] = OpenSSL::SSL::TLS1_2_VERSION
|
|
392
|
+
else
|
|
393
|
+
opts[:ssl_version] = :TLSv1_2
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
if configuration.mtls_cert && configuration.mtls_key
|
|
397
|
+
cert_pem = file_or_pem(configuration.mtls_cert)
|
|
398
|
+
key_pem = file_or_pem(configuration.mtls_key)
|
|
399
|
+
opts[:cert] = OpenSSL::X509::Certificate.new(cert_pem)
|
|
400
|
+
opts[:key] = OpenSSL::PKey.read(key_pem, configuration.mtls_key_passphrase)
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
opts
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
def file_or_pem(value)
|
|
407
|
+
if File.exist?(value)
|
|
408
|
+
File.read(value)
|
|
409
|
+
else
|
|
410
|
+
Base64.decode64(value)
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
|
|
383
414
|
def do_request(http, req, uri)
|
|
384
415
|
if logs_required?
|
|
385
416
|
do_request_with_log(http, req, uri)
|
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: 3.
|
|
4
|
+
version: 3.47.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-03-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: multi_json
|