mangopay 3.18.0 → 3.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +19 -0
- data/lib/mangopay/pay_in.rb +20 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +33 -0
- data/spec/mangopay/configuration_spec.rb +68 -0
- data/spec/mangopay/payin_giropay_web_spec.rb +30 -0
- data/spec/mangopay/payin_ideal_web_spec.rb +30 -0
- data/spec/mangopay/shared_resources.rb +32 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22a75f6a785d55c368cc565e3d9b2dc399c5b08cb8b4b8ed27f24762ee9b6a2
|
4
|
+
data.tar.gz: 7b1b066c802f7716aa500267349928ed05d7df7ac9be74e63855376c284e2c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51efb4cb9942a749604b7f44e0fb79958b862ab03a0aa742c70af9bc650001aff7b339d43e56011392556e2e38572343c19a243e5218e09b24d4960346d3c10c
|
7
|
+
data.tar.gz: 1b8d01d73103c23d7e999e6c4e49ae2d57f5161ecb20626be0465d581de3e4c606b38549c4bde0fc4e4b2d27d4a7684c6cd1566b949f32463bf52ace34b309cf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
## [3.20.0] - 2023-11-15
|
2
|
+
### Added
|
3
|
+
|
4
|
+
Now, our SDK enables seamless integration with multiple clientIDs, offering enhanced flexibility and customization.
|
5
|
+
|
6
|
+
You can effortlessly create multiple configuration objects tailored to your specific needs:
|
7
|
+
|
8
|
+
```
|
9
|
+
config = MangoPay::Configuration.new
|
10
|
+
config.client_id = 'your-client-id'
|
11
|
+
config.client_apiKey = 'your-api-key'
|
12
|
+
config.preproduction = true
|
13
|
+
```
|
14
|
+
add them using :
|
15
|
+
|
16
|
+
`MangoPay.add_config('config1', config)`
|
17
|
+
|
18
|
+
and perform a call with them using :
|
19
|
+
|
20
|
+
`MangoPay.get_config('config1').apply_configuration`
|
21
|
+
|
22
|
+
The previous method configure() is still working.
|
23
|
+
|
24
|
+
## [3.19.0] - 2023-11-02
|
25
|
+
### Updated
|
26
|
+
|
27
|
+
- Giropay and Ideal integrations with Mangopay have been improved.
|
28
|
+
- Klarna param "MerchantOrderId" has been renamed to "Reference"
|
29
|
+
|
1
30
|
## [3.18.0] - 2023-09-29
|
2
31
|
### Added
|
3
32
|
- Instantly convert funds between 2 wallets of different currencies owned by the same user with the new SPOT FX endpoints
|
data/README.md
CHANGED
@@ -85,6 +85,25 @@ rescue MangoPay::ResponseError => ex
|
|
85
85
|
end
|
86
86
|
```
|
87
87
|
|
88
|
+
### Using multiple clientIDs
|
89
|
+
You can effortlessly create multiple configuration objects tailored to your specific needs:
|
90
|
+
|
91
|
+
```
|
92
|
+
config = MangoPay::Configuration.new
|
93
|
+
config.client_id = 'your-client-id'
|
94
|
+
config.client_apiKey = 'your-api-key'
|
95
|
+
config.preproduction = true
|
96
|
+
```
|
97
|
+
add them using :
|
98
|
+
|
99
|
+
`MangoPay.add_config('config1', config)`
|
100
|
+
|
101
|
+
and perform a call with them using :
|
102
|
+
|
103
|
+
`MangoPay.get_config('config1').apply_configuration`
|
104
|
+
|
105
|
+
The previous method configure() is still working.
|
106
|
+
|
88
107
|
### Accessing RateLimit Headers
|
89
108
|
Along with each request, the rate limiting headers are automatically updated in MangoPay object:
|
90
109
|
|
data/lib/mangopay/pay_in.rb
CHANGED
@@ -197,6 +197,26 @@ module MangoPay
|
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
200
|
+
module Ideal
|
201
|
+
class Web < Resource
|
202
|
+
include HTTPCalls::Create
|
203
|
+
|
204
|
+
def self.url(*)
|
205
|
+
"#{MangoPay.api_path}/payins/payment-methods/ideal"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
module Giropay
|
211
|
+
class Web < Resource
|
212
|
+
include HTTPCalls::Create
|
213
|
+
|
214
|
+
def self.url(*)
|
215
|
+
"#{MangoPay.api_path}/payins/payment-methods/giropay"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
200
220
|
module RecurringPayments
|
201
221
|
class Recurring < Resource
|
202
222
|
include HTTPCalls::Create
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay.rb
CHANGED
@@ -49,6 +49,8 @@ module MangoPay
|
|
49
49
|
# temporary
|
50
50
|
autoload :Temp, 'mangopay/temp'
|
51
51
|
|
52
|
+
@configurations = {}
|
53
|
+
|
52
54
|
class Configuration
|
53
55
|
attr_accessor :preproduction, :root_url,
|
54
56
|
:client_id, :client_apiKey,
|
@@ -56,6 +58,20 @@ module MangoPay
|
|
56
58
|
:http_max_retries, :http_open_timeout,
|
57
59
|
:logger, :use_ssl
|
58
60
|
|
61
|
+
def apply_configuration
|
62
|
+
MangoPay.configure do |config|
|
63
|
+
config.preproduction = @preproduction
|
64
|
+
config.client_id = @client_id
|
65
|
+
config.client_apiKey = @client_apiKey
|
66
|
+
config.log_file = @log_file
|
67
|
+
config.http_timeout = @http_timeout
|
68
|
+
config.http_max_retries = @http_max_retries
|
69
|
+
config.http_open_timeout = @http_open_timeout
|
70
|
+
config.use_ssl = @use_ssl
|
71
|
+
config.logger = @logger
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
59
75
|
def preproduction
|
60
76
|
@preproduction || false
|
61
77
|
end
|
@@ -138,6 +154,23 @@ module MangoPay
|
|
138
154
|
@ratelimit = obj
|
139
155
|
end
|
140
156
|
|
157
|
+
# Add MangoPay.Configuration to the list of configs
|
158
|
+
def add_config(name, config)
|
159
|
+
@configurations[name] = config
|
160
|
+
end
|
161
|
+
|
162
|
+
# Fetch a MangoPay configuration from the list of configs. Throw error if not found
|
163
|
+
def get_config(name)
|
164
|
+
config = @configurations[name]
|
165
|
+
raise "Could not find any configuration with name '#{name}'" unless config
|
166
|
+
config
|
167
|
+
end
|
168
|
+
|
169
|
+
def remove_config(name)
|
170
|
+
raise "Could not find any configuration with name '#{name}'" unless @configurations[name]
|
171
|
+
@configurations[name] = nil
|
172
|
+
end
|
173
|
+
|
141
174
|
#
|
142
175
|
# - +method+: HTTP method; lowercase symbol, e.g. :get, :post etc.
|
143
176
|
# - +url+: the part after Configuration#root_url
|
@@ -13,6 +13,74 @@ describe MangoPay::Configuration do
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'fails when calling with wrong client credentials, but succeeds after applying a new (correct) config' do
|
17
|
+
# create a wrong configuration
|
18
|
+
wrong_config = MangoPay::Configuration.new
|
19
|
+
wrong_config.client_id = 'placeholder'
|
20
|
+
wrong_config.client_apiKey = '0000'
|
21
|
+
wrong_config.preproduction = true
|
22
|
+
|
23
|
+
# create a valid configuration
|
24
|
+
valid_config = MangoPay::Configuration.new
|
25
|
+
valid_config.client_id = 'sdk-unit-tests'
|
26
|
+
valid_config.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
|
27
|
+
valid_config.preproduction = true
|
28
|
+
|
29
|
+
# add the 2 configs to the list of MangoPay configs
|
30
|
+
MangoPay.add_config('wrong', wrong_config)
|
31
|
+
MangoPay.add_config('valid', valid_config)
|
32
|
+
|
33
|
+
# apply wrong config
|
34
|
+
MangoPay.get_config('wrong').apply_configuration
|
35
|
+
|
36
|
+
expect {
|
37
|
+
MangoPay::User.fetch()
|
38
|
+
}.to raise_error { |err|
|
39
|
+
expect(err).to be_a MangoPay::ResponseError
|
40
|
+
expect(err.code).to eq '401'
|
41
|
+
expect(err.message).to eq 'invalid_client'
|
42
|
+
}
|
43
|
+
|
44
|
+
# apply valid configuration
|
45
|
+
MangoPay.get_config('valid').apply_configuration
|
46
|
+
|
47
|
+
# expect success
|
48
|
+
users = MangoPay::User.fetch()
|
49
|
+
expect(users).to be_kind_of(Array)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'fails when fetching a config that does not exist' do
|
53
|
+
expect {
|
54
|
+
MangoPay.get_config('placeholder')
|
55
|
+
}.to raise_error { |err|
|
56
|
+
expect(err).to be_a RuntimeError
|
57
|
+
expect(err.message).to eq "Could not find any configuration with name 'placeholder'"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'succeeds when removing config' do
|
62
|
+
wrong_config = MangoPay::Configuration.new
|
63
|
+
wrong_config.client_id = 'placeholder'
|
64
|
+
wrong_config.client_apiKey = '0000'
|
65
|
+
wrong_config.preproduction = true
|
66
|
+
|
67
|
+
MangoPay.add_config('wrong', wrong_config)
|
68
|
+
|
69
|
+
# pass when fetching config before removing it
|
70
|
+
MangoPay.get_config('wrong')
|
71
|
+
|
72
|
+
# remove config
|
73
|
+
MangoPay.remove_config('wrong')
|
74
|
+
|
75
|
+
# fail when trying to fetch after removal
|
76
|
+
expect {
|
77
|
+
MangoPay.get_config('wrong')
|
78
|
+
}.to raise_error { |err|
|
79
|
+
expect(err).to be_a RuntimeError
|
80
|
+
expect(err.message).to eq "Could not find any configuration with name 'wrong'"
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
16
84
|
it 'goes ok when calling with correct client credentials' do
|
17
85
|
reset_mangopay_configuration
|
18
86
|
users = MangoPay::User.fetch()
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe MangoPay::PayIn::Giropay::Web, type: :feature do
|
2
|
+
include_context 'wallets'
|
3
|
+
include_context 'payins'
|
4
|
+
|
5
|
+
def check_type_and_status(payin)
|
6
|
+
expect(payin['Type']).to eq('PAYIN')
|
7
|
+
expect(payin['Nature']).to eq('REGULAR')
|
8
|
+
expect(payin['PaymentType']).to eq('GIROPAY')
|
9
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
10
|
+
expect(payin['Status']).to eq('CREATED')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'CREATE' do
|
14
|
+
it 'creates a giropay web payin' do
|
15
|
+
created = new_payin_giropay_web
|
16
|
+
expect(created['Id']).not_to be_nil
|
17
|
+
check_type_and_status(created)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'FETCH' do
|
22
|
+
it 'fetches a payin' do
|
23
|
+
created = new_payin_giropay_web
|
24
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
25
|
+
expect(fetched['Id']).to eq(created['Id'])
|
26
|
+
check_type_and_status(created)
|
27
|
+
check_type_and_status(fetched)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
describe MangoPay::PayIn::Ideal::Web, type: :feature do
|
2
|
+
include_context 'wallets'
|
3
|
+
include_context 'payins'
|
4
|
+
|
5
|
+
def check_type_and_status(payin)
|
6
|
+
expect(payin['Type']).to eq('PAYIN')
|
7
|
+
expect(payin['Nature']).to eq('REGULAR')
|
8
|
+
expect(payin['PaymentType']).to eq('IDEAL')
|
9
|
+
expect(payin['ExecutionType']).to eq('WEB')
|
10
|
+
expect(payin['Status']).to eq('CREATED')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'CREATE' do
|
14
|
+
it 'creates a ideal web payin' do
|
15
|
+
created = new_payin_ideal_web
|
16
|
+
expect(created['Id']).not_to be_nil
|
17
|
+
check_type_and_status(created)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'FETCH' do
|
22
|
+
it 'fetches a payin' do
|
23
|
+
created = new_payin_ideal_web
|
24
|
+
fetched = MangoPay::PayIn.fetch(created['Id'])
|
25
|
+
expect(fetched['Id']).to eq(created['Id'])
|
26
|
+
check_type_and_status(created)
|
27
|
+
check_type_and_status(fetched)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -562,11 +562,42 @@ shared_context 'payins' do
|
|
562
562
|
FirstName: 'Joe',
|
563
563
|
LastName: 'Blogs'
|
564
564
|
},
|
565
|
-
|
565
|
+
Reference: 'afd48-879d-48fg',
|
566
566
|
Tag: 'Test PayIn/Klarna/Web'
|
567
567
|
)
|
568
568
|
end
|
569
569
|
|
570
|
+
###############################################
|
571
|
+
# IDEAL/web
|
572
|
+
###############################################
|
573
|
+
let(:new_payin_ideal_web) do
|
574
|
+
MangoPay::PayIn::Ideal::Web.create(
|
575
|
+
AuthorId: new_natural_user['Id'],
|
576
|
+
CreditedWalletId: new_wallet['Id'],
|
577
|
+
DebitedFunds: {Currency: 'EUR', Amount: 400},
|
578
|
+
Fees: {Currency: 'EUR', Amount: 10},
|
579
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
580
|
+
Bic: 'REVOLT21',
|
581
|
+
StatementDescriptor: "test",
|
582
|
+
Tag: 'Test PayIn/Ideal/Web'
|
583
|
+
)
|
584
|
+
end
|
585
|
+
|
586
|
+
###############################################
|
587
|
+
# Giropay/web
|
588
|
+
###############################################
|
589
|
+
let(:new_payin_giropay_web) do
|
590
|
+
MangoPay::PayIn::Giropay::Web.create(
|
591
|
+
AuthorId: new_natural_user['Id'],
|
592
|
+
CreditedWalletId: new_wallet['Id'],
|
593
|
+
DebitedFunds: {Currency: 'EUR', Amount: 400},
|
594
|
+
Fees: {Currency: 'EUR', Amount: 10},
|
595
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
596
|
+
StatementDescriptor: "test",
|
597
|
+
Tag: 'Test PayIn/Giropay/Web'
|
598
|
+
)
|
599
|
+
end
|
600
|
+
|
570
601
|
###############################################
|
571
602
|
# PAYPAL/web V2
|
572
603
|
###############################################
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangopay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.20.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: 2023-
|
12
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -137,7 +137,9 @@ files:
|
|
137
137
|
- spec/mangopay/payin_card_web_spec.rb
|
138
138
|
- spec/mangopay/payin_directdebit_direct_spec.rb
|
139
139
|
- spec/mangopay/payin_directdebit_web_spec.rb
|
140
|
+
- spec/mangopay/payin_giropay_web_spec.rb
|
140
141
|
- spec/mangopay/payin_googlepay_direct_spec.rb
|
142
|
+
- spec/mangopay/payin_ideal_web_spec.rb
|
141
143
|
- spec/mangopay/payin_klarna_web_spec.rb
|
142
144
|
- spec/mangopay/payin_mbway_web_spec.rb
|
143
145
|
- spec/mangopay/payin_multibanco_web_spec.rb
|
@@ -212,7 +214,9 @@ test_files:
|
|
212
214
|
- spec/mangopay/payin_card_web_spec.rb
|
213
215
|
- spec/mangopay/payin_directdebit_direct_spec.rb
|
214
216
|
- spec/mangopay/payin_directdebit_web_spec.rb
|
217
|
+
- spec/mangopay/payin_giropay_web_spec.rb
|
215
218
|
- spec/mangopay/payin_googlepay_direct_spec.rb
|
219
|
+
- spec/mangopay/payin_ideal_web_spec.rb
|
216
220
|
- spec/mangopay/payin_klarna_web_spec.rb
|
217
221
|
- spec/mangopay/payin_mbway_web_spec.rb
|
218
222
|
- spec/mangopay/payin_multibanco_web_spec.rb
|