mangopay 3.31.0 → 3.32.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 +16 -0
- data/lib/mangopay/legal_user.rb +3 -0
- data/lib/mangopay/legal_user_sca.rb +4 -0
- data/lib/mangopay/natural_user.rb +6 -0
- data/lib/mangopay/natural_user_sca.rb +4 -0
- data/lib/mangopay/recipient.rb +35 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +2 -1
- data/spec/mangopay/client_spec.rb +2 -2
- data/spec/mangopay/kyc_document_spec.rb +2 -2
- data/spec/mangopay/recipient_spec.rb +113 -0
- data/spec/mangopay/shared_resources.rb +35 -0
- data/spec/mangopay/user_spec.rb +16 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e3054c801c2db4879dc5ee322b442204351fd2c96458345b865c7f30a8accf
|
4
|
+
data.tar.gz: e59f212b984b311a3999c1f768532798c072d60f40d692d1a90ae755a81a01d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ce73c93504fbecef0a12d7ff98bd5f192700b90cf0e555063af16fabf88ffbdf6cb88e973e705f642e870c239bf306c624d97f8c8cc021008e88638cd9d6a1
|
7
|
+
data.tar.gz: d48f4c254375d55ddd36e911fb7f84cd18f8eeb96ed28081501ed745249abacad3fd6a35ede4e6be972196c0611675e259fea41cdb8e0cee0687cd5d296e0a86
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## [3.32.0] - 2025-04-16
|
2
|
+
### Added
|
3
|
+
|
4
|
+
#### Recipients
|
5
|
+
- [GET View payout methods](/api-reference/recipients/view-payout-methods)
|
6
|
+
- [GET View the schema for a Recipient](/api-reference/recipients/view-recipient-schema)
|
7
|
+
- [POST Validate data for a Recipient](/api-reference/recipients/validate-recipient-data)
|
8
|
+
- [POST Create a Recipient](/api-reference/recipients/create-recipient)
|
9
|
+
- [GET View a Recipient](/api-reference/recipients/view-recipient)
|
10
|
+
- [GET List Recipients for a user](/api-reference/recipients/list-recipients-user)
|
11
|
+
- [PUT Deactivate a Recipient](/api-reference/recipients/deactivate-recipient)
|
12
|
+
|
13
|
+
#### Endpoints to close a user account
|
14
|
+
- [DELETE Close a Natural User](/api-reference/users/close-natural-user)
|
15
|
+
- [DELETE Close a Legal User](/api-reference/users/close-legal-user)
|
16
|
+
|
1
17
|
## [3.31.0] - 2025-04-16
|
2
18
|
### Added
|
3
19
|
- [POST Create a Pay by Bank PayIn](https://docs.mangopay.com/api-reference/pay-by-bank/create-pay-by-bank-payin)
|
data/lib/mangopay/legal_user.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
class Recipient < Resource
|
4
|
+
def self.create(params, user_id, idempotency_key = nil)
|
5
|
+
MangoPay.request(:post, "#{MangoPay.api_path}/users/#{user_id}/recipients", params, {}, idempotency_key)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.get(recipient_id, filters = {})
|
9
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/recipients/#{recipient_id}", {}, filters)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_user_recipients(user_id, filters = {})
|
13
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/users/#{user_id}/recipients", {}, filters)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_schema(payout_method_type, recipient_type, currency, filters = {})
|
17
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/recipients/schema?payoutMethodType=#{payout_method_type}&recipientType=#{recipient_type}¤cy=#{currency}", {}, filters)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get_payout_methods(country, currency, filters = {})
|
21
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/recipients/payout-methods?country=#{country}¤cy=#{currency}", {}, filters)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.validate(params, user_id, idempotency_key = nil)
|
25
|
+
MangoPay.request(:post, "#{MangoPay.api_path}/users/#{user_id}/recipients/validate", params, {}, idempotency_key)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.deactivate(recipient_id)
|
29
|
+
params = {
|
30
|
+
Status: 'DEACTIVATED'
|
31
|
+
}
|
32
|
+
MangoPay.request(:put, "#{MangoPay.api_path}/recipients/#{recipient_id}", params, {})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay.rb
CHANGED
@@ -51,6 +51,7 @@ module MangoPay
|
|
51
51
|
autoload :PaymentMethodMetadata, 'mangopay/payment_method_metadata'
|
52
52
|
autoload :VirtualAccount, 'mangopay/virtual_account'
|
53
53
|
autoload :IdentityVerification, 'mangopay/identity_verification'
|
54
|
+
autoload :Recipient, 'mangopay/recipient'
|
54
55
|
|
55
56
|
# temporary
|
56
57
|
autoload :Temp, 'mangopay/temp'
|
@@ -232,7 +233,7 @@ module MangoPay
|
|
232
233
|
raise MangoPay::ResponseError.new(uri, res.code, details)
|
233
234
|
end
|
234
235
|
|
235
|
-
unless res.is_a?(Net::HTTPOK)
|
236
|
+
unless res.is_a?(Net::HTTPOK) or res.is_a?(Net::HTTPCreated) or res.is_a?(Net::HTTPNoContent)
|
236
237
|
raise MangoPay::ResponseError.new(uri, res.code, data)
|
237
238
|
end
|
238
239
|
|
@@ -45,13 +45,13 @@ describe MangoPay::Client do
|
|
45
45
|
bts = File.open(fnm, 'rb') { |f| f.read }
|
46
46
|
b64 = Base64.encode64(bts)
|
47
47
|
ret = MangoPay::Client.upload_logo(b64)
|
48
|
-
expect(ret).
|
48
|
+
expect(ret).to_not be_nil
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'accepts file path' do
|
52
52
|
fnm = __FILE__.sub('.rb', '.png')
|
53
53
|
ret = MangoPay::Client.upload_logo(nil, fnm)
|
54
|
-
expect(ret).
|
54
|
+
expect(ret).to_not be_nil
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'fails when input string is not base64-encoded' do
|
@@ -86,13 +86,13 @@ describe MangoPay::KycDocument do
|
|
86
86
|
bts = File.open(fnm, 'rb') { |f| f.read }
|
87
87
|
b64 = Base64.encode64(bts)
|
88
88
|
ret = create_page(b64)
|
89
|
-
expect(ret).
|
89
|
+
expect(ret).to_not be_nil
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'accepts file path' do
|
93
93
|
fnm = __FILE__.sub('.rb', '.png')
|
94
94
|
ret = MangoPay::KycDocument.create_page(new_natural_user['Id'], new_document['Id'], nil, fnm)
|
95
|
-
expect(ret).
|
95
|
+
expect(ret).to_not be_nil
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'fails when input string is not base64-encoded' do
|
@@ -0,0 +1,113 @@
|
|
1
|
+
describe MangoPay::Recipient do
|
2
|
+
include_context 'recipient'
|
3
|
+
|
4
|
+
describe 'CREATE' do
|
5
|
+
it 'creates a new recipient' do
|
6
|
+
recipient = new_recipient
|
7
|
+
assert_recipient(recipient)
|
8
|
+
expect(recipient['PendingUserAction']).not_to be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'GET' do
|
13
|
+
it 'fetches a recipient' do
|
14
|
+
recipient = new_recipient
|
15
|
+
fetched = MangoPay::Recipient.get(recipient['Id'])
|
16
|
+
assert_recipient(fetched)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'GET User Recipients' do
|
21
|
+
it 'fetches a recipient' do
|
22
|
+
john = create_new_natural_user_sca_owner
|
23
|
+
create_new_recipient(john['Id'])
|
24
|
+
fetched = MangoPay::Recipient.get_user_recipients(john['Id'])
|
25
|
+
expect(fetched).not_to be_nil
|
26
|
+
expect(fetched).to be_kind_of(Array)
|
27
|
+
expect(fetched).not_to be_empty
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'GET Schema' do
|
32
|
+
it 'fetches schema for LocalBankTransfer, Individual' do
|
33
|
+
schema = MangoPay::Recipient.get_schema('LocalBankTransfer', 'Individual', 'GBP')
|
34
|
+
expect(schema).not_to be_nil
|
35
|
+
expect(schema['DisplayName']).not_to be_nil
|
36
|
+
expect(schema['Currency']).not_to be_nil
|
37
|
+
expect(schema['RecipientType']).not_to be_nil
|
38
|
+
expect(schema['PayoutMethodType']).not_to be_nil
|
39
|
+
expect(schema['RecipientScope']).not_to be_nil
|
40
|
+
expect(schema['Tag']).not_to be_nil
|
41
|
+
expect(schema['IndividualRecipient']).not_to be_nil
|
42
|
+
expect(schema['LocalBankTransfer']).not_to be_nil
|
43
|
+
expect(schema['BusinessRecipient']).to be_nil
|
44
|
+
expect(schema['InternationalBankTransfer']).to be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'fetches schema for InternationalBankTransfer, Business' do
|
48
|
+
schema = MangoPay::Recipient.get_schema('InternationalBankTransfer', 'Business', 'GBP')
|
49
|
+
expect(schema).not_to be_nil
|
50
|
+
expect(schema['DisplayName']).not_to be_nil
|
51
|
+
expect(schema['Currency']).not_to be_nil
|
52
|
+
expect(schema['RecipientType']).not_to be_nil
|
53
|
+
expect(schema['PayoutMethodType']).not_to be_nil
|
54
|
+
expect(schema['RecipientScope']).not_to be_nil
|
55
|
+
expect(schema['Tag']).not_to be_nil
|
56
|
+
expect(schema['BusinessRecipient']).not_to be_nil
|
57
|
+
expect(schema['InternationalBankTransfer']).not_to be_nil
|
58
|
+
expect(schema['IndividualRecipient']).to be_nil
|
59
|
+
expect(schema['LocalBankTransfer']).to be_nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'GET Payout Methods' do
|
64
|
+
it 'fetches payout methods' do
|
65
|
+
payout_methods = MangoPay::Recipient.get_payout_methods('DE', 'EUR')
|
66
|
+
expect(payout_methods).not_to be_nil
|
67
|
+
expect(payout_methods['AvailablePayoutMethods']).to be_kind_of(Array)
|
68
|
+
expect(payout_methods['AvailablePayoutMethods']).not_to be_empty
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'VALIDATE' do
|
73
|
+
it 'validates a recipient' do
|
74
|
+
recipient = define_new_recipient
|
75
|
+
john = create_new_natural_user_sca_owner
|
76
|
+
# it should pass
|
77
|
+
MangoPay::Recipient.validate(recipient, john['Id'])
|
78
|
+
|
79
|
+
# it should throw error
|
80
|
+
recipient['Currency'] = nil
|
81
|
+
expect { MangoPay::Recipient.validate(recipient, john['Id']) }.to raise_error { |err|
|
82
|
+
expect(err).to be_a MangoPay::ResponseError
|
83
|
+
expect(err.code).to eq '400'
|
84
|
+
expect(err.type).to eq 'param_error'
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'DEACTIVATE' do
|
90
|
+
it 'deactivates a recipient' do
|
91
|
+
pending("a recipient needs to be manually activated before running the test")
|
92
|
+
john = create_new_natural_user_sca_owner
|
93
|
+
recipient = create_new_recipient(john['Id'])
|
94
|
+
deactivated = MangoPay::Recipient.deactivate(recipient['Id'])
|
95
|
+
fetched = MangoPay::Recipient.get(recipient['Id'])
|
96
|
+
expect(deactivated['Status']).to eq('DEACTIVATED')
|
97
|
+
expect(fetched['Status']).to eq('DEACTIVATED')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def assert_recipient(recipient)
|
104
|
+
expect(recipient).not_to be_nil
|
105
|
+
expect(recipient['Status']).not_to be_nil
|
106
|
+
expect(recipient['DisplayName']).not_to be_nil
|
107
|
+
expect(recipient['PayoutMethodType']).not_to be_nil
|
108
|
+
expect(recipient['RecipientType']).not_to be_nil
|
109
|
+
expect(recipient['IndividualRecipient']).not_to be_nil
|
110
|
+
expect(recipient['LocalBankTransfer']).not_to be_nil
|
111
|
+
expect(recipient['RecipientScope']).not_to be_nil
|
112
|
+
expect(recipient['UserId']).not_to be_nil
|
113
|
+
end
|
@@ -1205,4 +1205,39 @@ shared_context 'virtual_account' do
|
|
1205
1205
|
|
1206
1206
|
MangoPay::VirtualAccount.create(wallet_id, create_virtual_account)
|
1207
1207
|
end
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
shared_context 'recipient' do
|
1211
|
+
include_context 'users'
|
1212
|
+
|
1213
|
+
let(:new_recipient) { create_new_recipient(create_new_natural_user_sca_owner['Id']) }
|
1214
|
+
|
1215
|
+
def create_new_recipient(user_id)
|
1216
|
+
MangoPay::Recipient.create(define_new_recipient, user_id)
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
def define_new_recipient
|
1220
|
+
{
|
1221
|
+
"DisplayName": "Alex Smith GBP account",
|
1222
|
+
"PayoutMethodType": "LocalBankTransfer",
|
1223
|
+
"RecipientType": "Individual",
|
1224
|
+
"Currency": "GBP",
|
1225
|
+
"IndividualRecipient": {
|
1226
|
+
"FirstName": "Alex",
|
1227
|
+
"LastName": "Smith",
|
1228
|
+
"Address": {
|
1229
|
+
"AddressLine1": "10 Kingsway",
|
1230
|
+
"City": "London",
|
1231
|
+
"PostalCode": "WC2B 6LH",
|
1232
|
+
"Country": "GB"
|
1233
|
+
}
|
1234
|
+
},
|
1235
|
+
"LocalBankTransfer": {
|
1236
|
+
"GBP": {
|
1237
|
+
"SortCode": "200000",
|
1238
|
+
"AccountNumber": "55779911"
|
1239
|
+
}
|
1240
|
+
}
|
1241
|
+
}
|
1242
|
+
end
|
1208
1243
|
end
|
data/spec/mangopay/user_spec.rb
CHANGED
@@ -367,4 +367,20 @@ describe MangoPay::User do
|
|
367
367
|
end
|
368
368
|
end
|
369
369
|
=end
|
370
|
+
|
371
|
+
describe 'CLOSE' do
|
372
|
+
it 'closes a natural user' do
|
373
|
+
new_user = create_new_natural_user
|
374
|
+
MangoPay::NaturalUser.close(new_user['Id'])
|
375
|
+
closed = MangoPay::User.fetch(new_user['Id'])
|
376
|
+
expect(closed['UserStatus']).to eq('CLOSED')
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'closes a legal user' do
|
380
|
+
new_user = new_legal_user
|
381
|
+
MangoPay::LegalUser.close(new_user['Id'])
|
382
|
+
closed = MangoPay::User.fetch(new_user['Id'])
|
383
|
+
expect(closed['UserStatus']).to eq('CLOSED')
|
384
|
+
end
|
385
|
+
end
|
370
386
|
end
|
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.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffroy Lorieux
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/mangopay/pay_out.rb
|
103
103
|
- lib/mangopay/payment_method_metadata.rb
|
104
104
|
- lib/mangopay/pre_authorization.rb
|
105
|
+
- lib/mangopay/recipient.rb
|
105
106
|
- lib/mangopay/refund.rb
|
106
107
|
- lib/mangopay/regulatory.rb
|
107
108
|
- lib/mangopay/report.rb
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- spec/mangopay/payment_method_metadata_spec.rb
|
161
162
|
- spec/mangopay/payout_bankwire_spec.rb
|
162
163
|
- spec/mangopay/preauthorization_spec.rb
|
164
|
+
- spec/mangopay/recipient_spec.rb
|
163
165
|
- spec/mangopay/recurring_payin_spec.rb
|
164
166
|
- spec/mangopay/refund_spec.rb
|
165
167
|
- spec/mangopay/regulatory_spec.rb
|
@@ -244,6 +246,7 @@ test_files:
|
|
244
246
|
- spec/mangopay/payment_method_metadata_spec.rb
|
245
247
|
- spec/mangopay/payout_bankwire_spec.rb
|
246
248
|
- spec/mangopay/preauthorization_spec.rb
|
249
|
+
- spec/mangopay/recipient_spec.rb
|
247
250
|
- spec/mangopay/recurring_payin_spec.rb
|
248
251
|
- spec/mangopay/refund_spec.rb
|
249
252
|
- spec/mangopay/regulatory_spec.rb
|