mangopay 3.0.33 → 3.0.34
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/.travis.yml +6 -1
- data/CHANGELOG.md +16 -1
- data/README.md +2 -2
- data/lib/mangopay.rb +17 -8
- data/lib/mangopay/filter_parameters.rb +6 -1
- data/lib/mangopay/http_calls.rb +7 -7
- data/lib/mangopay/pay_in.rb +10 -0
- data/lib/mangopay/version.rb +1 -1
- data/spec/mangopay/client_spec.rb +1 -0
- data/spec/mangopay/configuration_spec.rb +52 -0
- data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +36 -0
- data/spec/mangopay/payin_card_web_spec.rb +9 -0
- data/spec/mangopay/shared_resources.rb +49 -0
- data/spec/mangopay/ubo_declaration_spec.rb +2 -1
- 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: cb254e350875d634519586fc4e451a4c83148886522287f266ed1306131235b4
|
4
|
+
data.tar.gz: ef04474a28bf48dbef09cb20cf48375fdac3183546d30631b1f443aa0f9f21b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ddc8e015f6ffe95c3947f063a2736a9863b19cf24a02d389fa00d9b9f623c27e083468e7c6eb9d2fcde31a974d3cb73da2674e76b09f53a14b80aaf6c59ca4
|
7
|
+
data.tar.gz: 49ce455ede60281e5c6b430c2c722d7c0c0f3abcc15204beaedd8c3954621d8f0057f05493ebd47df84f02cb91ea0d63db4e247b984f28091edcb525326b7158
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## [Unreleased]
|
2
|
-
|
2
|
+
- New v4 SDK version (available as a beta version here: https://rubygems.org/gems/mangopay-v4) - will be shortly merged on master.
|
3
|
+
|
4
|
+
## [3.0.34] - 2020-06-25
|
5
|
+
### Added
|
6
|
+
- This SDK is now GooglePay-ready ! Feel free to ask our lovely support for more infos about its activation.
|
7
|
+
- `UBODeclaration` is now directly available through its ID.
|
8
|
+
- If a bankwire is done from a UK bankaccount on one of your `BankingAlias`, you could find its `AccountNumber` on `GET /payins/` response
|
9
|
+
- You can now send a `Culture` parameter for Paypal PayIns. Thanks to it, payment page can be displayed in various languages.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- `PAYLINEV2`value for Payin Web has been added on `TemplateURLOptions` object. You now should use it instead of `PAYLINE` for page customization.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Missing filters parameters have been added
|
16
|
+
- You can now send headers in update requests
|
17
|
+
- Loggers have been enhanced
|
3
18
|
|
4
19
|
## [3.0.33] - 2019-09-23
|
5
20
|
### Added
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ The gem for interacting with the version 2 of the Mangopay API.
|
|
4
4
|
See the [API documentation](http://docs.mangopay.com/api-references/)
|
5
5
|
for more details on the API.
|
6
6
|
|
7
|
-
Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0
|
7
|
+
Tested on the following versions of Ruby: 1.9.2, 1.9.3, 2.0.0 and 2.x up to 2.5
|
8
8
|
|
9
9
|
## NEWS
|
10
10
|
|
@@ -102,7 +102,7 @@ Along with each request, the rate limiting headers are automatically updated in
|
|
102
102
|
}
|
103
103
|
```
|
104
104
|
|
105
|
-
Read more about rate limiting on [our
|
105
|
+
Read more about rate limiting on [our documentation](https://docs.mangopay.com/guide/rate-limiting).
|
106
106
|
|
107
107
|
### Log requests and responses
|
108
108
|
You can easily enable logs by setting the ```log_file``` configuration option (see the section **configuration** above). If you don't want logs, remove the ```log_file``` line.
|
data/lib/mangopay.rb
CHANGED
@@ -49,7 +49,8 @@ module MangoPay
|
|
49
49
|
class Configuration
|
50
50
|
attr_accessor :preproduction, :root_url,
|
51
51
|
:client_id, :client_apiKey,
|
52
|
-
:temp_dir, :log_file, :http_timeout
|
52
|
+
:temp_dir, :log_file, :http_timeout,
|
53
|
+
:logger
|
53
54
|
|
54
55
|
def preproduction
|
55
56
|
@preproduction || false
|
@@ -158,7 +159,7 @@ module MangoPay
|
|
158
159
|
limit: res['x-ratelimit'].split(", "),
|
159
160
|
remaining: res['x-ratelimit-remaining'].split(", "),
|
160
161
|
reset: res['x-ratelimit-reset'].split(", ")
|
161
|
-
}
|
162
|
+
}
|
162
163
|
end
|
163
164
|
|
164
165
|
data
|
@@ -204,10 +205,10 @@ module MangoPay
|
|
204
205
|
end
|
205
206
|
|
206
207
|
def do_request(http, req, uri)
|
207
|
-
if
|
208
|
-
do_request_without_log(http, req)
|
209
|
-
else
|
208
|
+
if logs_required?
|
210
209
|
do_request_with_log(http, req, uri)
|
210
|
+
else
|
211
|
+
do_request_without_log(http, req)
|
211
212
|
end
|
212
213
|
end
|
213
214
|
|
@@ -236,15 +237,23 @@ module MangoPay
|
|
236
237
|
end
|
237
238
|
|
238
239
|
def logger
|
239
|
-
raise NotImplementedError
|
240
|
-
if @logger
|
240
|
+
raise NotImplementedError unless logs_required?
|
241
|
+
return @logger if @logger
|
242
|
+
|
243
|
+
if !configuration.logger.nil?
|
244
|
+
@logger = configuration.logger
|
245
|
+
elsif !configuration.log_file.nil?
|
241
246
|
@logger = Logger.new(configuration.log_file)
|
242
|
-
@logger.formatter = proc do |
|
247
|
+
@logger.formatter = proc do |_, _, _, msg|
|
243
248
|
"#{msg}\n"
|
244
249
|
end
|
245
250
|
end
|
251
|
+
|
246
252
|
@logger
|
247
253
|
end
|
248
254
|
|
255
|
+
def logs_required?
|
256
|
+
!configuration.log_file.nil? || !configuration.logger.nil?
|
257
|
+
end
|
249
258
|
end
|
250
259
|
end
|
@@ -13,7 +13,12 @@ module MangoPay
|
|
13
13
|
|
14
14
|
def self.response(body)
|
15
15
|
return '' if body.to_s.empty?
|
16
|
-
|
16
|
+
|
17
|
+
begin
|
18
|
+
body = JSON.load(body)
|
19
|
+
rescue MultiJson::LoadError => e
|
20
|
+
return body
|
21
|
+
end
|
17
22
|
filter_hash(body, res_confidential_params)
|
18
23
|
JSON.dump(body)
|
19
24
|
end
|
data/lib/mangopay/http_calls.rb
CHANGED
@@ -21,8 +21,8 @@ module MangoPay
|
|
21
21
|
|
22
22
|
module Update
|
23
23
|
module ClassMethods
|
24
|
-
def update(id = nil, params = {})
|
25
|
-
MangoPay.request(:put, url(id), params)
|
24
|
+
def update(id = nil, params = {}, idempotency_key = nil)
|
25
|
+
MangoPay.request(:put, url(id), params, {}, idempotency_key)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -35,20 +35,20 @@ module MangoPay
|
|
35
35
|
module ClassMethods
|
36
36
|
|
37
37
|
# - Fetching _single_entity_ by +id+:
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# MangoPay::User.fetch("user-id") # => {"FirstName"=>"Mango", "LastName"=>"Pay", ...}
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# - or fetching _multiple_entities_ with _optional_ +filters+ hash,
|
42
42
|
# including _pagination_ and _sorting_ params
|
43
43
|
# +page+, +per_page+, +sort+ (see http://docs.mangopay.com/api-references/pagination/):
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# MangoPay::User.fetch() # => [{...}, ...]: list of user data hashes (10 per page by default)
|
46
46
|
# MangoPay::User.fetch({'page' => 2, 'per_page' => 3}) # => list of 3 hashes from 2nd page
|
47
47
|
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc'}) # => bank accounts by user, sorting by date descending (with default pagination)
|
48
48
|
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc', 'page' => 2, 'per_page' => 3}) # both sorting and pagination params provided
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# - For paginated queries the +filters+ param will be supplemented by +total_pages+ and +total_items+ info:
|
51
|
-
#
|
51
|
+
#
|
52
52
|
# MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3})
|
53
53
|
# filter # => {"page"=>2, "per_page"=>3, "total_pages"=>1969, "total_items"=>5905}
|
54
54
|
#
|
data/lib/mangopay/pay_in.rb
CHANGED
@@ -116,5 +116,15 @@ module MangoPay
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
module GooglePay
|
120
|
+
class Direct < Resource
|
121
|
+
include HTTPCalls::Create
|
122
|
+
|
123
|
+
def self.url(*)
|
124
|
+
"#{MangoPay.api_path}/payins/googlepay/#{CGI.escape(class_name.downcase)}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
119
129
|
end
|
120
130
|
end
|
data/lib/mangopay/version.rb
CHANGED
@@ -15,6 +15,58 @@ describe MangoPay::Configuration do
|
|
15
15
|
expect(users).to be_kind_of(Array)
|
16
16
|
end
|
17
17
|
|
18
|
+
describe 'logger' do
|
19
|
+
around(:each) do |example|
|
20
|
+
c = MangoPay.configuration
|
21
|
+
c.logger = logger
|
22
|
+
c.log_file = log_file
|
23
|
+
example.run
|
24
|
+
c.logger = nil
|
25
|
+
c.log_file = nil
|
26
|
+
MangoPay.instance_variable_set(:@logger, nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when the logger is set' do
|
30
|
+
let(:logger) { Logger.new(STDOUT) }
|
31
|
+
|
32
|
+
context 'when the log_file is set' do
|
33
|
+
let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
|
34
|
+
|
35
|
+
it 'initializes the logger using the logger option' do
|
36
|
+
expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when the log_file is not set' do
|
41
|
+
let(:log_file) { nil }
|
42
|
+
|
43
|
+
it 'initializes the logger using the logger option' do
|
44
|
+
expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when the logger is not set' do
|
50
|
+
let(:logger) { nil }
|
51
|
+
|
52
|
+
context 'when the log_file is set' do
|
53
|
+
let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
|
54
|
+
|
55
|
+
it 'initializes the logger using the log file' do
|
56
|
+
expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(be_an_instance_of(File))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when the log_file is not set' do
|
61
|
+
let(:log_file) { nil }
|
62
|
+
|
63
|
+
it 'raises an error' do
|
64
|
+
expect{ MangoPay.send(:logger) }.to raise_error NotImplementedError
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
18
70
|
context 'with multithreading' do
|
19
71
|
after :all do
|
20
72
|
reset_mangopay_configuration
|
@@ -27,6 +27,42 @@ describe MangoPay::PayIn::BankWire::ExternalInstruction, type: :feature do
|
|
27
27
|
check_type_and_status(payIn)
|
28
28
|
MangoPay.configuration = backupConfig
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'fetches a bankwire external instruction with iban' do
|
32
|
+
backupConfig = MangoPay.configuration.clone
|
33
|
+
MangoPay.configure do |c|
|
34
|
+
c.preproduction = true
|
35
|
+
c.client_id = 'sdk-unit-tests'
|
36
|
+
c.root_url = 'https://api.sandbox.mangopay.com'
|
37
|
+
c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
|
38
|
+
c.http_timeout = 10000
|
39
|
+
end
|
40
|
+
|
41
|
+
payInId = "74980101"
|
42
|
+
payIn = MangoPay::PayIn.fetch(payInId)
|
43
|
+
expect(payIn).to_not be(nil)
|
44
|
+
expect(payIn['Id']).to eq(payInId)
|
45
|
+
check_type_and_status(payIn)
|
46
|
+
MangoPay.configuration = backupConfig
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'fetches a bankwire external instruction with account number' do
|
50
|
+
backupConfig = MangoPay.configuration.clone
|
51
|
+
MangoPay.configure do |c|
|
52
|
+
c.preproduction = true
|
53
|
+
c.client_id = 'sdk-unit-tests'
|
54
|
+
c.root_url = 'https://api.sandbox.mangopay.com'
|
55
|
+
c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
|
56
|
+
c.http_timeout = 10000
|
57
|
+
end
|
58
|
+
|
59
|
+
payInId = "74981216"
|
60
|
+
payIn = MangoPay::PayIn.fetch(payInId)
|
61
|
+
expect(payIn).to_not be(nil)
|
62
|
+
expect(payIn['Id']).to eq(payInId)
|
63
|
+
check_type_and_status(payIn)
|
64
|
+
MangoPay.configuration = backupConfig
|
65
|
+
end
|
30
66
|
end
|
31
67
|
|
32
68
|
###############################################
|
@@ -22,6 +22,15 @@ describe MangoPay::PayIn::Card::Web, type: :feature do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe 'CREATE with PaylineV2' do
|
26
|
+
it 'creates a card web payin with payline v2' do
|
27
|
+
created = new_payin_card_web_payline
|
28
|
+
expect(created['Id']).not_to be_nil
|
29
|
+
expect(created['RedirectURL']).to include('https://www.maysite.com/payline_template/')
|
30
|
+
check_type_and_status(created)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
describe 'EXTENDED' do
|
26
35
|
context 'when resource not exists' do
|
27
36
|
it 'fetches extended information' do
|
@@ -210,6 +210,7 @@ shared_context 'payins' do
|
|
210
210
|
DebitedFunds: {Currency: 'EUR', Amount: 1000},
|
211
211
|
Fees: {Currency: 'EUR', Amount: 0},
|
212
212
|
ReturnURL: MangoPay.configuration.root_url,
|
213
|
+
Culture: "FR",
|
213
214
|
Tag: 'Test PayIn/PayPal/Web'
|
214
215
|
)
|
215
216
|
end
|
@@ -237,6 +238,39 @@ shared_context 'payins' do
|
|
237
238
|
)
|
238
239
|
end
|
239
240
|
|
241
|
+
###############################################
|
242
|
+
# CANNOT BE TESTED AS WE CAN'T MOCK TOKEN GENERATION
|
243
|
+
# googlepay/direct
|
244
|
+
###############################################
|
245
|
+
let(:new_payin_googlepay_direct) do
|
246
|
+
MangoPay::PayIn::GooglePay::Direct.create(
|
247
|
+
AuthorId: new_natural_user['Id'],
|
248
|
+
CreditedUserId: new_wallet['Owners'][0],
|
249
|
+
CreditedWalletId: new_wallet['Id'],
|
250
|
+
DebitedFunds: {Currency: 'EUR', Amount: 199},
|
251
|
+
Fees: {Currency: 'EUR', Amount: 1},
|
252
|
+
PaymentData: {
|
253
|
+
TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
|
254
|
+
Network: 'VISA',
|
255
|
+
TokenData: "tokenData"
|
256
|
+
},
|
257
|
+
StatementDescriptor: "ruby",
|
258
|
+
ReturnURL: MangoPay.configuration.root_url,
|
259
|
+
Tag: 'Test PayIn/GooglePay/Direct',
|
260
|
+
Billing: {
|
261
|
+
Address: {
|
262
|
+
AddressLine1: 'AddressLine1',
|
263
|
+
AddressLine2: 'AddressLine2',
|
264
|
+
City: 'City',
|
265
|
+
Region: 'Region',
|
266
|
+
PostalCode: 'PostalCode',
|
267
|
+
CountryIso: 'FR'
|
268
|
+
}
|
269
|
+
}
|
270
|
+
)
|
271
|
+
end
|
272
|
+
|
273
|
+
|
240
274
|
###############################################
|
241
275
|
# directdebit/direct
|
242
276
|
###############################################
|
@@ -272,6 +306,21 @@ shared_context 'payins' do
|
|
272
306
|
)
|
273
307
|
end
|
274
308
|
|
309
|
+
let(:new_payin_card_web_payline) do
|
310
|
+
MangoPay::PayIn::Card::Web.create(
|
311
|
+
AuthorId: new_natural_user['Id'],
|
312
|
+
CreditedUserId: new_wallet['Owners'][0],
|
313
|
+
CreditedWalletId: new_wallet['Id'],
|
314
|
+
DebitedFunds: {Currency: 'EUR', Amount: 1000},
|
315
|
+
Fees: {Currency: 'EUR', Amount: 0},
|
316
|
+
CardType: 'CB_VISA_MASTERCARD',
|
317
|
+
ReturnURL: MangoPay.configuration.root_url,
|
318
|
+
Culture: 'FR',
|
319
|
+
Tag: 'Test PayIn/Card/Web',
|
320
|
+
TemplateURLOptions: {PAYLINEV2: "https://www.maysite.com/payline_template/"}
|
321
|
+
)
|
322
|
+
end
|
323
|
+
|
275
324
|
###############################################
|
276
325
|
# card/direct
|
277
326
|
###############################################
|
@@ -8,9 +8,10 @@ describe MangoPay::UboDeclaration do
|
|
8
8
|
|
9
9
|
ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
|
10
10
|
|
11
|
-
|
11
|
+
ubo_declaration_byId = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
|
12
12
|
|
13
13
|
expect(ubo_declaration).not_to be_nil
|
14
|
+
expect(ubo_declaration_byId).not_to be_nil
|
14
15
|
end
|
15
16
|
|
16
17
|
describe 'UPDATE' do
|
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.0.
|
4
|
+
version: 3.0.34
|
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:
|
12
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|