mangopay 3.0.30 → 3.0.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -1
  3. data/CHANGELOG.md +35 -0
  4. data/README.md +5 -5
  5. data/lib/generators/mangopay/install_generator.rb +1 -1
  6. data/lib/generators/templates/mangopay.rb.erb +1 -1
  7. data/lib/mangopay.rb +19 -9
  8. data/lib/mangopay/authorization_token.rb +2 -2
  9. data/lib/mangopay/bank_account.rb +11 -0
  10. data/lib/mangopay/card.rb +15 -0
  11. data/lib/mangopay/filter_parameters.rb +6 -1
  12. data/lib/mangopay/http_calls.rb +7 -7
  13. data/lib/mangopay/legal_user.rb +0 -8
  14. data/lib/mangopay/mandate.rb +10 -0
  15. data/lib/mangopay/pay_in.rb +31 -0
  16. data/lib/mangopay/pay_out.rb +11 -0
  17. data/lib/mangopay/refund.rb +11 -0
  18. data/lib/mangopay/transfer.rb +11 -0
  19. data/lib/mangopay/ubo.rb +26 -0
  20. data/lib/mangopay/ubo_declaration.rb +22 -11
  21. data/lib/mangopay/user.rb +24 -6
  22. data/lib/mangopay/version.rb +1 -1
  23. data/spec/mangopay/bank_account_spec.rb +8 -0
  24. data/spec/mangopay/card_registration_spec.rb +7 -0
  25. data/spec/mangopay/client_spec.rb +17 -6
  26. data/spec/mangopay/configuration_spec.rb +53 -1
  27. data/spec/mangopay/event_spec.rb +12 -10
  28. data/spec/mangopay/mandate_spec.rb +7 -0
  29. data/spec/mangopay/payin_applepay_direct_spec.rb +20 -0
  30. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +43 -4
  31. data/spec/mangopay/payin_card_web_spec.rb +17 -0
  32. data/spec/mangopay/payin_paypal_web_spec.rb +13 -1
  33. data/spec/mangopay/payout_bankwire_spec.rb +8 -0
  34. data/spec/mangopay/preauthorization_spec.rb +9 -0
  35. data/spec/mangopay/refund_spec.rb +13 -0
  36. data/spec/mangopay/shared_resources.rb +346 -240
  37. data/spec/mangopay/transfer_spec.rb +8 -0
  38. data/spec/mangopay/ubo_declaration_spec.rb +13 -17
  39. data/spec/mangopay/ubo_spec.rb +39 -0
  40. data/spec/mangopay/user_spec.rb +51 -16
  41. data/spec/spec_helper.rb +1 -1
  42. metadata +9 -3
@@ -66,4 +66,12 @@ describe MangoPay::Transfer, type: :feature do
66
66
  wallets_reload_and_check_amounts(wlt1, 1000, wlt2, 0)
67
67
  end
68
68
  end
69
+
70
+ describe 'FETCH Refunds' do
71
+ it "fetches a transfer's refunds" do
72
+ transfer = new_transfer
73
+ refunds = MangoPay::Transfer.refunds(transfer['Id'])
74
+ expect(refunds).to be_an(Array)
75
+ end
76
+ end
69
77
  end
@@ -1,37 +1,33 @@
1
1
  describe MangoPay::UboDeclaration do
2
2
  include_context 'users'
3
+ include_context 'ubo'
3
4
 
4
5
  describe 'FETCH' do
5
6
  it 'can fetch a UBO declaration' do
6
7
  legal_user = new_legal_user
7
- natural_user = define_new_natural_user
8
- natural_user['Capacity'] = 'DECLARATIVE'
9
- natural_user = MangoPay::NaturalUser.create(natural_user)
10
- ubo_declaration = {
11
- DeclaredUBOs: [natural_user['Id']]
12
- }
13
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
14
- ubo_declaration = MangoPay::UboDeclaration.fetch(ubo_declaration['Id'])
8
+
9
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
10
+
11
+ ubo_declaration_byId = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
15
12
 
16
13
  expect(ubo_declaration).not_to be_nil
14
+ expect(ubo_declaration_byId).not_to be_nil
17
15
  end
18
16
 
19
17
  describe 'UPDATE' do
20
18
  it 'can update a UBO declaration' do
21
19
  legal_user = new_legal_user
22
- natural_user = define_new_natural_user
23
- natural_user['Capacity'] = 'DECLARATIVE'
24
- natural_user = MangoPay::NaturalUser.create(natural_user)
25
- ubo_declaration = {
26
- DeclaredUBOs: [natural_user['Id']]
27
- }
28
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
20
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
29
21
  ubo_declaration['Status'] = 'VALIDATION_ASKED'
30
- ubo_declaration = MangoPay::UboDeclaration.update(ubo_declaration['Id'], ubo_declaration)
22
+
23
+ ubo = new_ubo(legal_user, ubo_declaration)
24
+
25
+ ubo_declaration['Ubos'] = [ubo]
26
+ ubo_declaration = MangoPay::UboDeclaration.update(legal_user['Id'], ubo_declaration['Id'], ubo_declaration)
31
27
 
32
28
  expect(ubo_declaration).not_to be_nil
33
29
  expect(ubo_declaration['Status']).to eq 'VALIDATION_ASKED'
34
30
  end
35
31
  end
36
32
  end
37
- end
33
+ end
@@ -0,0 +1,39 @@
1
+ describe MangoPay::Ubo do
2
+ include_context 'users'
3
+ include_context 'ubo'
4
+
5
+ describe 'FETCH' do
6
+ it 'can fetch a Ubo' do
7
+ legal_user = new_legal_user
8
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
9
+ ubo = new_ubo(legal_user, ubo_declaration)
10
+ result = MangoPay::Ubo.fetch(legal_user['Id'], ubo_declaration['Id'], ubo['Id'])
11
+ expect(result).not_to be_nil
12
+ expect(result['Id']).equal? ubo['Id']
13
+ end
14
+ end
15
+
16
+ describe 'CREATE' do
17
+ it 'can create a new Ubo' do
18
+ legal_user = new_legal_user
19
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
20
+ result = new_ubo(legal_user, ubo_declaration)
21
+ expect(result).not_to be_nil
22
+ end
23
+ end
24
+
25
+ describe 'UPDATE' do
26
+ it 'can update a Ubo' do
27
+ legal_user = new_legal_user
28
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
29
+ ubo = new_ubo(legal_user, ubo_declaration)
30
+ ubo['FirstName'] = 'Santa'
31
+ ubo['LastName'] = 'Clause'
32
+
33
+ result = MangoPay::Ubo.update(legal_user['Id'], ubo_declaration['Id'], ubo['Id'], ubo)
34
+ expect(result).not_to be_nil
35
+ expect(result['FirstName']).equal? ubo['FirstName']
36
+ expect(result['LastName']).equal? ubo['LastName']
37
+ end
38
+ end
39
+ end
@@ -3,6 +3,7 @@ describe MangoPay::User do
3
3
  include_context 'payins'
4
4
  include_context 'payouts'
5
5
  include_context 'wallets'
6
+ include_context 'kyc_documents'
6
7
 
7
8
  describe 'CREATE' do
8
9
  it 'creates a new natural user' do
@@ -12,6 +13,10 @@ describe MangoPay::User do
12
13
  it 'creates a new legal user' do
13
14
  expect(new_legal_user["LegalRepresentativeFirstName"]).to eq('John')
14
15
  end
16
+
17
+ it 'creates a new legal user' do
18
+ expect(new_legal_user["CompanyNumber"]).to eq('LU123456789')
19
+ end
15
20
  end
16
21
 
17
22
  describe 'UPDATE' do
@@ -146,31 +151,61 @@ describe MangoPay::User do
146
151
  end
147
152
 
148
153
  describe 'FETCH EMONEY' do
149
- it 'fetches emoney for the user' do
150
- emoney = MangoPay::User.emoney(new_natural_user['Id'])
154
+ it 'fetches emoney for the user for year 2019' do
155
+ emoney = MangoPay::User.emoney(new_natural_user['Id'], 2019)
151
156
  expect(emoney['UserId']).to eq new_natural_user['Id']
152
157
  expect(emoney['CreditedEMoney']['Amount']).to eq 0
153
158
  expect(emoney['CreditedEMoney']['Currency']).to eq 'EUR'
154
159
  expect(emoney['DebitedEMoney']['Amount']).to eq 0
155
160
  expect(emoney['DebitedEMoney']['Currency']).to eq 'EUR'
156
161
  end
162
+
163
+ it 'fetches emoney for the user for date 08/2019' do
164
+ emoney = MangoPay::User.emoney(new_natural_user['Id'], 2019, 8)
165
+ expect(emoney['UserId']).to eq new_natural_user['Id']
166
+ expect(emoney['CreditedEMoney']['Amount']).to eq 0
167
+ expect(emoney['CreditedEMoney']['Currency']).to eq 'EUR'
168
+ expect(emoney['DebitedEMoney']['Amount']).to eq 0
169
+ expect(emoney['DebitedEMoney']['Currency']).to eq 'EUR'
170
+ end
171
+ end
172
+
173
+ describe 'FETCH Kyc Document' do
174
+ it 'fetches empty list of kyc documents if no kyc document created' do
175
+ documents = MangoPay::User.kyc_documents(new_natural_user['Id'])
176
+ expect(documents).to be_kind_of(Array)
177
+ expect(documents).to be_empty
178
+ end
179
+
180
+ it 'fetches list with single kyc document after created' do
181
+ document = new_document
182
+ documents = MangoPay::User.kyc_documents(document['UserId'])
183
+ expect(documents).to be_kind_of(Array)
184
+ expect(documents.count).to eq 1
185
+ expect(documents.first['Id']).to eq document['Id']
186
+ end
157
187
  end
158
188
 
159
- describe 'CREATE UBO DECLARATION' do
160
- it 'creates a UBO declaration' do
189
+ #describe 'CREATE UBO DECLARATION' do
190
+ # it 'creates a UBO declaration' do
191
+ # legal_user = new_legal_user
192
+ # natural_user = define_new_natural_user
193
+ # natural_user['Capacity'] = 'DECLARATIVE'
194
+ # natural_user = MangoPay::NaturalUser.create(natural_user)
195
+ # ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'])
196
+
197
+ # expect(ubo_declaration).not_to be_nil
198
+ # expect(ubo_declaration['Status']).to eq 'CREATED'
199
+ # expect(ubo_declaration['UserId']).to eq legal_user['Id']
200
+ # expect(ubo_declaration['DeclaredUBOs'][0]['UserId']).to eq natural_user['Id']
201
+ # end
202
+ #end
203
+
204
+ describe 'FETCH Pre-Authorizations' do
205
+ it "fetches list of user's pre-authorizations belonging" do
161
206
  legal_user = new_legal_user
162
- natural_user = define_new_natural_user
163
- natural_user['Capacity'] = 'DECLARATIVE'
164
- natural_user = MangoPay::NaturalUser.create(natural_user)
165
- ubo_declaration = {
166
- DeclaredUBOs: [natural_user['Id']]
167
- }
168
- ubo_declaration = MangoPay::LegalUser.create_ubo_declaration(legal_user['Id'], ubo_declaration)
169
-
170
- expect(ubo_declaration).not_to be_nil
171
- expect(ubo_declaration['Status']).to eq 'CREATED'
172
- expect(ubo_declaration['UserId']).to eq legal_user['Id']
173
- expect(ubo_declaration['DeclaredUBOs'][0]['UserId']).to eq natural_user['Id']
207
+ pre_authorizations = MangoPay::User.pre_authorizations(legal_user['Id'])
208
+ expect(pre_authorizations).to be_an(Array)
174
209
  end
175
210
  end
176
211
  end
@@ -11,7 +11,7 @@ def reset_mangopay_configuration
11
11
 
12
12
  # sandbox environment:
13
13
  c.root_url = 'https://api.sandbox.mangopay.com'
14
- c.client_passphrase = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
14
+ c.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
15
15
 
16
16
  c.temp_dir = File.expand_path('../tmp', __FILE__)
17
17
  require 'fileutils'
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.30
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: 2017-12-26 00:00:00.000000000 Z
12
+ date: 2020-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -66,6 +66,7 @@ files:
66
66
  - ".gitignore"
67
67
  - ".rspec"
68
68
  - ".travis.yml"
69
+ - CHANGELOG.md
69
70
  - Gemfile
70
71
  - LICENSE
71
72
  - README.md
@@ -99,6 +100,7 @@ files:
99
100
  - lib/mangopay/resource.rb
100
101
  - lib/mangopay/transaction.rb
101
102
  - lib/mangopay/transfer.rb
103
+ - lib/mangopay/ubo.rb
102
104
  - lib/mangopay/ubo_declaration.rb
103
105
  - lib/mangopay/user.rb
104
106
  - lib/mangopay/version.rb
@@ -121,6 +123,7 @@ files:
121
123
  - spec/mangopay/kyc_document_spec.rb
122
124
  - spec/mangopay/log_requests_filter_spec.rb
123
125
  - spec/mangopay/mandate_spec.rb
126
+ - spec/mangopay/payin_applepay_direct_spec.rb
124
127
  - spec/mangopay/payin_bankwire_direct_spec.rb
125
128
  - spec/mangopay/payin_bankwire_external_instruction_spec.rb
126
129
  - spec/mangopay/payin_card_direct_spec.rb
@@ -138,6 +141,7 @@ files:
138
141
  - spec/mangopay/transaction_spec.rb
139
142
  - spec/mangopay/transfer_spec.rb
140
143
  - spec/mangopay/ubo_declaration_spec.rb
144
+ - spec/mangopay/ubo_spec.rb
141
145
  - spec/mangopay/user_spec.rb
142
146
  - spec/mangopay/wallet_spec.rb
143
147
  - spec/spec_helper.rb
@@ -162,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
166
  version: '0'
163
167
  requirements: []
164
168
  rubyforge_project:
165
- rubygems_version: 2.7.4
169
+ rubygems_version: 2.7.7
166
170
  signing_key:
167
171
  specification_version: 4
168
172
  summary: Ruby bindings for the version 2 of the MANGOPAY API
@@ -184,6 +188,7 @@ test_files:
184
188
  - spec/mangopay/kyc_document_spec.rb
185
189
  - spec/mangopay/log_requests_filter_spec.rb
186
190
  - spec/mangopay/mandate_spec.rb
191
+ - spec/mangopay/payin_applepay_direct_spec.rb
187
192
  - spec/mangopay/payin_bankwire_direct_spec.rb
188
193
  - spec/mangopay/payin_bankwire_external_instruction_spec.rb
189
194
  - spec/mangopay/payin_card_direct_spec.rb
@@ -201,6 +206,7 @@ test_files:
201
206
  - spec/mangopay/transaction_spec.rb
202
207
  - spec/mangopay/transfer_spec.rb
203
208
  - spec/mangopay/ubo_declaration_spec.rb
209
+ - spec/mangopay/ubo_spec.rb
204
210
  - spec/mangopay/user_spec.rb
205
211
  - spec/mangopay/wallet_spec.rb
206
212
  - spec/spec_helper.rb