mangopay 3.25.1 → 3.33.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/.github/workflows/ruby_cd.yml +1 -1
- data/.github/workflows/ruby_ci.yml +1 -1
- data/CHANGELOG.md +117 -0
- data/lib/mangopay/conversion.rb +6 -6
- data/lib/mangopay/http_calls.rb +4 -1
- data/lib/mangopay/identity_verification.rb +16 -0
- data/lib/mangopay/legal_user.rb +3 -0
- data/lib/mangopay/legal_user_sca.rb +25 -0
- data/lib/mangopay/natural_user.rb +6 -0
- data/lib/mangopay/natural_user_sca.rb +25 -0
- data/lib/mangopay/pay_in.rb +57 -1
- data/lib/mangopay/recipient.rb +35 -0
- data/lib/mangopay/user.rb +13 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay/virtual_account.rb +44 -0
- data/lib/mangopay.rb +13 -2
- data/spec/mangopay/client_spec.rb +3 -2
- data/spec/mangopay/identity_verification_spec.rb +52 -0
- data/spec/mangopay/kyc_document_spec.rb +4 -4
- data/spec/mangopay/payin_bancontact_web_spec.rb +30 -0
- data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +3 -3
- data/spec/mangopay/payin_blik_web_spec.rb +9 -0
- data/spec/mangopay/payin_card_web_spec.rb +1 -1
- data/spec/mangopay/payin_paybybank_web_spec.rb +30 -0
- data/spec/mangopay/payin_paypal_web_spec.rb +1 -0
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +1 -0
- data/spec/mangopay/payin_swish_web_spec.rb +30 -0
- data/spec/mangopay/payin_twint_web_spec.rb +30 -0
- data/spec/mangopay/payout_bankwire_spec.rb +7 -5
- data/spec/mangopay/recipient_spec.rb +113 -0
- data/spec/mangopay/recurring_payin_spec.rb +140 -0
- data/spec/mangopay/shared_resources.rb +291 -4
- data/spec/mangopay/user_spec.rb +166 -0
- data/spec/mangopay/virtual_account_spec.rb +52 -0
- data/spec/mangopay/wallet_spec.rb +15 -0
- metadata +24 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2ea73775e3cbe39be6e8c2ab08353e325e4022c8e880c91ec39a2f7815158a5
|
4
|
+
data.tar.gz: e7a4e7daa408c976653cc7b45bb143e1e7d88b8c8267980bc26a03cd9483e100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a237843330abcee5203d85c86fcfcdf4d4e549b1ff3c0662f502d9d064de94de512dd358a26b930a55ae133852bf8aba5b92b91c3f92391806b1cc47797977e4
|
7
|
+
data.tar.gz: c15777f6e7043c031371dcf1aaca92ed2396402c68fa9a3c2d8ab0e8a8cf6bfdb4f516b55602d5fa32ae543bbb9254e0b3fc0f557630e7e1806601d3b4043a02
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,120 @@
|
|
1
|
+
## [3.33.0] - 2025-04-29
|
2
|
+
### Added
|
3
|
+
|
4
|
+
#### SCA on wallet access endpoints
|
5
|
+
|
6
|
+
`ScaContext` query parameter added on wallet access endpoints for the [introduction of SCA](https://docs.mangopay.com/guides/sca/wallets):
|
7
|
+
|
8
|
+
- [GET View a Wallet](https://docs.mangopay.com/api-reference/wallets/view-wallet)
|
9
|
+
- [GET List Wallets for a User](https://docs.mangopay.com/api-reference/wallets/list-wallets-user)
|
10
|
+
- [GET List Transactions for a User](https://docs.mangopay.com/api-reference/transactions/list-transactions-user)
|
11
|
+
- [GET List Transactions for a Wallet](https://docs.mangopay.com/api-reference/transactions/list-transactions-wallet)
|
12
|
+
|
13
|
+
If SCA is required, Mangopay responds with a 401 response code. The `PendingUserAction` `RedirectUrl` is in the dedicated `WWW-Authenticate` response header.
|
14
|
+
|
15
|
+
See the tests for examples on handling this error.
|
16
|
+
|
17
|
+
#### BLIK with code
|
18
|
+
Support for [BLIK with code endpoint](https://docs.mangopay.com/api-reference/blik/create-blik-payin-with-code)
|
19
|
+
|
20
|
+
## [3.32.0] - 2025-04-16
|
21
|
+
### Added
|
22
|
+
|
23
|
+
#### Recipients
|
24
|
+
- [GET View payout methods](/api-reference/recipients/view-payout-methods)
|
25
|
+
- [GET View the schema for a Recipient](/api-reference/recipients/view-recipient-schema)
|
26
|
+
- [POST Validate data for a Recipient](/api-reference/recipients/validate-recipient-data)
|
27
|
+
- [POST Create a Recipient](/api-reference/recipients/create-recipient)
|
28
|
+
- [GET View a Recipient](/api-reference/recipients/view-recipient)
|
29
|
+
- [GET List Recipients for a user](/api-reference/recipients/list-recipients-user)
|
30
|
+
- [PUT Deactivate a Recipient](/api-reference/recipients/deactivate-recipient)
|
31
|
+
|
32
|
+
#### Endpoints to close a user account
|
33
|
+
- [DELETE Close a Natural User](/api-reference/users/close-natural-user)
|
34
|
+
- [DELETE Close a Legal User](/api-reference/users/close-legal-user)
|
35
|
+
|
36
|
+
## [3.31.0] - 2025-04-16
|
37
|
+
### Added
|
38
|
+
- [POST Create a Pay by Bank PayIn](https://docs.mangopay.com/api-reference/pay-by-bank/create-pay-by-bank-payin)
|
39
|
+
- PayPal recurring payments, thanks to the `PaymentType` value `PAYPAL` on [Recurring PayIn Registrations](https://docs.mangopay.com/api-reference/recurring-payin-registrations/create-recurring-payin-registration-paypal) and new endpoints ([POST Create a Recurring PayPal PayIn (CIT)](https://docs.mangopay.com/api-reference/paypal/create-recurring-paypal-payin-cit) and [POST Create a Recurring PayPal PayIn (MIT)](https://docs.mangopay.com/api-reference/paypal/create-recurring-paypal-payin-mit)
|
40
|
+
|
41
|
+
## [3.30.2] - 2025-04-02
|
42
|
+
### Fixed
|
43
|
+
- Fixed the way User-Agent Header is built
|
44
|
+
|
45
|
+
## [3.30.1] - 2025-04-02
|
46
|
+
### Changed
|
47
|
+
- User-Agent Header value standardized on format: User-Agent: Mangopay-SDK/`SDKVersion` (`Language`/`LanguageVersion`)
|
48
|
+
|
49
|
+
## [3.30.0] - 2025-03-24
|
50
|
+
### Added
|
51
|
+
|
52
|
+
New endpoints for [strong customer authentication (SCA)](https://docs.mangopay.com/guides/users/sca) on Owner users:
|
53
|
+
- [POST Create a Natural User (SCA)](https://docs.mangopay.com/api-reference/users/create-natural-user-sca)
|
54
|
+
- [PUT Update a Natural User (SCA)](https://docs.mangopay.com/api-reference/users/update-natural-user-sca)
|
55
|
+
- [POST Create a Legal User (SCA)](https://docs.mangopay.com/api-reference/users/create-legal-user-sca)
|
56
|
+
- [PUT Update a Legal User (SCA)](https://docs.mangopay.com/api-reference/users/update-legal-user-sca)
|
57
|
+
- [PUT Categorize a Natural User (SCA)](https://docs.mangopay.com/api-reference/users/categorize-natural-user)
|
58
|
+
- [PUT Categorize a Legal User (SCA)](https://docs.mangopay.com/api-reference/users/categorize-legal-user)
|
59
|
+
- [POST Enroll a User in SCA](https://docs.mangopay.com/api-reference/users/enroll-user)
|
60
|
+
|
61
|
+
## [3.29.0] - 2025-02-26
|
62
|
+
### Added
|
63
|
+
|
64
|
+
Endpoints and webhooks for [hosted KYC/B solution](https://docs.mangopay.com/guides/users/verification/hosted) (in beta)
|
65
|
+
|
66
|
+
- Endpoints
|
67
|
+
- [Create an IDV Session](https://docs.mangopay.com/api-reference/idv-sessions/create-idv-session)
|
68
|
+
- [View an IDV Session](https://docs.mangopay.com/api-reference/idv-sessions/view-idv-session)
|
69
|
+
- [View Checks for an IDV Session](https://mangopay-idv.mintlify.app/api-reference/idv-sessions/view-idv-session-checks)
|
70
|
+
|
71
|
+
- Event types
|
72
|
+
- `IDENTITY_VERIFICATION_VALIDATED`
|
73
|
+
- `IDENTITY_VERIFICATION_FAILED`
|
74
|
+
- `IDENTITY_VERIFICATION_INCONCLUSIVE`
|
75
|
+
- `IDENTITY_VERIFICATION_OUTDATED`
|
76
|
+
|
77
|
+
## [3.28.2] - 2025-02-13
|
78
|
+
### Updated
|
79
|
+
|
80
|
+
#259 Added idempotency key to create conversion methods. Thank you for your contribution [@kaderate](https://github.com/kaderate)!
|
81
|
+
|
82
|
+
## [3.28.1] - 2025-02-04
|
83
|
+
### Updated
|
84
|
+
|
85
|
+
Revised tests to improve reliability and address any outdated tests.
|
86
|
+
|
87
|
+
## [3.28.0] - 2024-11-15
|
88
|
+
### Added
|
89
|
+
|
90
|
+
New endpoint for [The TWINT PayIn object](https://docs.mangopay.com/api-reference/twint/twint-payin-object#the-twint-payin-object):
|
91
|
+
- [Create a TWINT PayIn](https://docs.mangopay.com/api-reference/twint/create-twint-payin)
|
92
|
+
- [View a PayIn (TWINT)](https://docs.mangopay.com/api-reference/twint/view-payin-twint)
|
93
|
+
|
94
|
+
New endpoint for [The Swish PayIn object](https://docs.mangopay.com/api-reference/swish/swish-payin-object):
|
95
|
+
- [Create a Swish PayIn](https://docs.mangopay.com/api-reference/swish/create-swish-payin)
|
96
|
+
- [View a PayIn (Swish)](https://docs.mangopay.com/api-reference/swish/view-payin-swish)
|
97
|
+
|
98
|
+
## [3.27.0] - 2024-10-29
|
99
|
+
### Added
|
100
|
+
|
101
|
+
New endpoints for The Virtual Account object:
|
102
|
+
- [Create a Virtual Account]()
|
103
|
+
- [Deactivate a Virtual Account]()
|
104
|
+
- [View a Virtual Account]()
|
105
|
+
- [List Virtual Accounts for a Wallet]()
|
106
|
+
- [View Client Availabilities]()
|
107
|
+
|
108
|
+
## [3.26.1] - 2024-10-03
|
109
|
+
### Fixed
|
110
|
+
|
111
|
+
- Updated `RedirectURL` for the [Payconiq PayIn](https://docs.mangopay.com/api-reference/payconiq/payconiq-payin-object#the-payconiq-payin-object)
|
112
|
+
|
113
|
+
## [3.26.0] - 2024-08-07
|
114
|
+
### Added
|
115
|
+
|
116
|
+
- New endpoint: [Create a Bancontact PayIn](https://mangopay.com/docs/endpoints/bancontact#create-bancontact-payin)
|
117
|
+
|
1
118
|
## [3.25.1] - 2024-04-30
|
2
119
|
### Fixed
|
3
120
|
|
data/lib/mangopay/conversion.rb
CHANGED
@@ -10,14 +10,14 @@ module MangoPay
|
|
10
10
|
MangoPay.request(:get, url, params)
|
11
11
|
end
|
12
12
|
|
13
|
-
def create_instant_conversion(params)
|
13
|
+
def create_instant_conversion(params, idempotency_key = nil)
|
14
14
|
url = "#{MangoPay.api_path}/conversions/instant-conversion"
|
15
|
-
MangoPay.request(:post, url, params)
|
15
|
+
MangoPay.request(:post, url, params, {}, idempotency_key)
|
16
16
|
end
|
17
17
|
|
18
|
-
def create_quoted_conversion(params)
|
18
|
+
def create_quoted_conversion(params, idempotency_key = nil)
|
19
19
|
url = "#{MangoPay.api_path}/conversions/quoted-conversion"
|
20
|
-
MangoPay.request(:post, url, params)
|
20
|
+
MangoPay.request(:post, url, params, {}, idempotency_key)
|
21
21
|
end
|
22
22
|
|
23
23
|
def get(id, params)
|
@@ -25,9 +25,9 @@ module MangoPay
|
|
25
25
|
MangoPay.request(:get, url, params)
|
26
26
|
end
|
27
27
|
|
28
|
-
def create_quote(params)
|
28
|
+
def create_quote(params, idempotency_key = nil)
|
29
29
|
url = "#{MangoPay.api_path}/conversions/quote"
|
30
|
-
MangoPay.request(:post, url, params)
|
30
|
+
MangoPay.request(:post, url, params, {}, idempotency_key)
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_quote(id, params)
|
data/lib/mangopay/http_calls.rb
CHANGED
@@ -52,8 +52,11 @@ module MangoPay
|
|
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
|
#
|
55
|
-
def fetch(id_or_filters = nil, idempotency_key = nil)
|
55
|
+
def fetch(id_or_filters = nil, idempotency_key = nil, query_params_get_by_id = nil)
|
56
56
|
id, filters = HTTPCalls::Fetch.parse_id_or_filters(id_or_filters)
|
57
|
+
if query_params_get_by_id != nil and query_params_get_by_id != {}
|
58
|
+
filters = query_params_get_by_id
|
59
|
+
end
|
57
60
|
response = MangoPay.request(:get, url(id), {}, filters, idempotency_key)
|
58
61
|
end
|
59
62
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
class IdentityVerification < Resource
|
4
|
+
def self.create(params, user_id, idempotency_key = nil)
|
5
|
+
MangoPay.request(:post, "#{MangoPay.api_path}/users/#{user_id}/identity-verifications", params, {}, idempotency_key)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.get(identity_verification_id, filters = {})
|
9
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/identity-verifications/#{identity_verification_id}", {}, filters)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.get_checks(identity_verification_id, filters = {})
|
13
|
+
MangoPay.request(:get, "#{MangoPay.api_path}/identity-verifications/#{identity_verification_id}/checks", {}, filters)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/mangopay/legal_user.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See https://docs.mangopay.com/api-reference/users/legal-user-object-sca
|
4
|
+
class LegalUserSca < User
|
5
|
+
|
6
|
+
def self.url(id = nil)
|
7
|
+
if id
|
8
|
+
"#{MangoPay.api_path}/sca/users/legal/#{CGI.escape(id.to_s)}"
|
9
|
+
else
|
10
|
+
"#{MangoPay.api_path}/sca/users/legal"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def categorize(user_id, params)
|
16
|
+
url = "#{MangoPay.api_path}/sca/users/legal/#{user_id}/category"
|
17
|
+
MangoPay.request(:put, url, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def close(user_id)
|
21
|
+
MangoPay.request(:delete, url(user_id))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See https://docs.mangopay.com/api-reference/users/natural-user-object-sca
|
4
|
+
class NaturalUserSca < User
|
5
|
+
|
6
|
+
def self.url(id = nil)
|
7
|
+
if id
|
8
|
+
"#{MangoPay.api_path}/sca/users/natural/#{CGI.escape(id.to_s)}"
|
9
|
+
else
|
10
|
+
"#{MangoPay.api_path}/sca/users/natural"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def categorize(user_id, params)
|
16
|
+
url = "#{MangoPay.api_path}/sca/users/natural/#{user_id}/category"
|
17
|
+
MangoPay.request(:put, url, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def close(user_id)
|
21
|
+
MangoPay.request(:delete, url(user_id))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/mangopay/pay_in.rb
CHANGED
@@ -137,7 +137,7 @@ module MangoPay
|
|
137
137
|
include HTTPCalls::Create
|
138
138
|
|
139
139
|
def self.url(*)
|
140
|
-
"#{MangoPay.api_path}/payins/payconiq
|
140
|
+
"#{MangoPay.api_path}/payins/payment-methods/payconiq"
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -233,6 +233,46 @@ module MangoPay
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
+
module Bancontact
|
237
|
+
class Web < Resource
|
238
|
+
include HTTPCalls::Create
|
239
|
+
|
240
|
+
def self.url(*)
|
241
|
+
"#{MangoPay.api_path}/payins/payment-methods/bancontact"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
module Twint
|
247
|
+
class Web < Resource
|
248
|
+
include HTTPCalls::Create
|
249
|
+
|
250
|
+
def self.url(*)
|
251
|
+
"#{MangoPay.api_path}/payins/payment-methods/twint"
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
module Swish
|
257
|
+
class Web < Resource
|
258
|
+
include HTTPCalls::Create
|
259
|
+
|
260
|
+
def self.url(*)
|
261
|
+
"#{MangoPay.api_path}/payins/payment-methods/swish"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
module PayByBank
|
267
|
+
class Web < Resource
|
268
|
+
include HTTPCalls::Create
|
269
|
+
|
270
|
+
def self.url(*)
|
271
|
+
"#{MangoPay.api_path}/payins/payment-methods/openbanking"
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
236
276
|
module RecurringPayments
|
237
277
|
class Recurring < Resource
|
238
278
|
include HTTPCalls::Create
|
@@ -263,6 +303,22 @@ module MangoPay
|
|
263
303
|
"#{MangoPay.api_path}/payins/recurring/card/direct"
|
264
304
|
end
|
265
305
|
end
|
306
|
+
|
307
|
+
class PayPalCIT < Resource
|
308
|
+
include HTTPCalls::Create
|
309
|
+
|
310
|
+
def self.url(*)
|
311
|
+
"#{MangoPay.api_path}/payins/payment-methods/paypal/recurring"
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
class PayPalMIT < Resource
|
316
|
+
include HTTPCalls::Create
|
317
|
+
|
318
|
+
def self.url(*)
|
319
|
+
"#{MangoPay.api_path}/payins/payment-methods/paypal/recurring"
|
320
|
+
end
|
321
|
+
end
|
266
322
|
end
|
267
323
|
|
268
324
|
end
|
@@ -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/user.rb
CHANGED
@@ -4,11 +4,19 @@ module MangoPay
|
|
4
4
|
# See also children classes:
|
5
5
|
# - MangoPay::NaturalUser
|
6
6
|
# - MangoPay::LegalUser
|
7
|
+
# - MangoPay::NaturalUserSca
|
8
|
+
# - MangoPay::LegalUserSca
|
7
9
|
class User < Resource
|
8
10
|
include HTTPCalls::Create
|
9
11
|
include HTTPCalls::Update
|
10
12
|
include HTTPCalls::Fetch
|
11
13
|
class << self
|
14
|
+
def enroll_sca(user_id)
|
15
|
+
url = "#{MangoPay.api_path}/sca/users/#{user_id}/enrollment"
|
16
|
+
MangoPay.request(:post, url, {}, {})
|
17
|
+
end
|
18
|
+
|
19
|
+
|
12
20
|
# Fetches list of wallets belonging to the given +user_id+.
|
13
21
|
# Optional +filters+ is a hash accepting following keys:
|
14
22
|
# - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
@@ -74,6 +82,11 @@ module MangoPay
|
|
74
82
|
def regulatory(user_id, filters = {})
|
75
83
|
MangoPay.request(:get, url(user_id) + '/Regulatory', {}, filters)
|
76
84
|
end
|
85
|
+
|
86
|
+
def fetch_sca(user_id)
|
87
|
+
url = "#{MangoPay.api_path}/sca/users/#{user_id}"
|
88
|
+
MangoPay.request(:get, url, {}, {})
|
89
|
+
end
|
77
90
|
end
|
78
91
|
end
|
79
92
|
end
|
data/lib/mangopay/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
class VirtualAccount < Resource
|
4
|
+
class << self
|
5
|
+
# Creates a new virtual account
|
6
|
+
def create(wallet_id, params, idempotency_key = nil)
|
7
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
|
8
|
+
MangoPay.request(:post, url, params, {}, idempotency_key)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Updates:
|
12
|
+
# - irreversibly deactivates a virtual account with +virtual_account_id+
|
13
|
+
# see https://docs.mangopay.com/api-reference/virtual-accounts/deactivate-virtual-account
|
14
|
+
def deactivate(wallet_id, virtual_account_id, idempotency_key = nil)
|
15
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
|
16
|
+
MangoPay.request(:put, url, {}, {}, idempotency_key)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Fetches:
|
20
|
+
# - view a virtual account with +virtual_account_id+
|
21
|
+
# see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account
|
22
|
+
def fetch(wallet_id, virtual_account_id)
|
23
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
|
24
|
+
MangoPay.request(:get, url, {})
|
25
|
+
end
|
26
|
+
|
27
|
+
# Fetches:
|
28
|
+
# - view virtual accounts for given +wallet_id+
|
29
|
+
# see https://docs.mangopay.com/api-reference/virtual-accounts/list-virtual-accounts-wallet
|
30
|
+
def fetch_all(wallet_id, filters = {})
|
31
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
|
32
|
+
MangoPay.request(:get, url, {}, filters)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Fetches:
|
36
|
+
# Allows to check which account countries and currencies are available
|
37
|
+
# see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account-availabilities
|
38
|
+
def fetch_availabilities(filters = {})
|
39
|
+
url = "#{MangoPay.api_path}/virtual-accounts/availability"
|
40
|
+
MangoPay.request(:get, url, {}, filters)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/mangopay.rb
CHANGED
@@ -19,6 +19,8 @@ module MangoPay
|
|
19
19
|
autoload :Client, 'mangopay/client'
|
20
20
|
autoload :User, 'mangopay/user'
|
21
21
|
autoload :NaturalUser, 'mangopay/natural_user'
|
22
|
+
autoload :NaturalUserSca, 'mangopay/natural_user_sca'
|
23
|
+
autoload :LegalUserSca, 'mangopay/legal_user_sca'
|
22
24
|
autoload :LegalUser, 'mangopay/legal_user'
|
23
25
|
autoload :PayIn, 'mangopay/pay_in'
|
24
26
|
autoload :PayOut, 'mangopay/pay_out'
|
@@ -47,6 +49,9 @@ module MangoPay
|
|
47
49
|
autoload :Deposit, 'mangopay/deposit'
|
48
50
|
autoload :Conversion, 'mangopay/conversion'
|
49
51
|
autoload :PaymentMethodMetadata, 'mangopay/payment_method_metadata'
|
52
|
+
autoload :VirtualAccount, 'mangopay/virtual_account'
|
53
|
+
autoload :IdentityVerification, 'mangopay/identity_verification'
|
54
|
+
autoload :Recipient, 'mangopay/recipient'
|
50
55
|
|
51
56
|
# temporary
|
52
57
|
autoload :Temp, 'mangopay/temp'
|
@@ -228,7 +233,13 @@ module MangoPay
|
|
228
233
|
raise MangoPay::ResponseError.new(uri, res.code, details)
|
229
234
|
end
|
230
235
|
|
231
|
-
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)
|
237
|
+
if res.is_a?(Net::HTTPUnauthorized) and res['www-authenticate'] != nil
|
238
|
+
redirect_url = res['www-authenticate'][/RedirectUrl=(.+)/, 1]
|
239
|
+
data['RedirectUrl'] = redirect_url
|
240
|
+
data['message'] = 'SCA required to perform this action.'
|
241
|
+
raise MangoPay::ResponseError.new(uri, res.code, data)
|
242
|
+
end
|
232
243
|
raise MangoPay::ResponseError.new(uri, res.code, data)
|
233
244
|
end
|
234
245
|
|
@@ -276,7 +287,7 @@ module MangoPay
|
|
276
287
|
def request_headers
|
277
288
|
auth_token = AuthorizationToken::Manager.get_token
|
278
289
|
headers = {
|
279
|
-
'User-Agent' => "
|
290
|
+
'User-Agent' => "Mangopay-SDK/#{VERSION} (Ruby/#{RUBY_VERSION})",
|
280
291
|
'Authorization' => "#{auth_token['token_type']} #{auth_token['access_token']}",
|
281
292
|
'Content-Type' => 'application/json'
|
282
293
|
}
|
@@ -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
|
@@ -104,6 +104,7 @@ describe MangoPay::Client do
|
|
104
104
|
|
105
105
|
describe 'fetch_wallets_transactions' do
|
106
106
|
it 'fetches transactions for all client wallets' do
|
107
|
+
pending("Endpoint removed")
|
107
108
|
trns = MangoPay::Client.fetch_wallets_transactions
|
108
109
|
expect(trns).to be_kind_of(Array)
|
109
110
|
expect(trns).not_to be_empty
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe MangoPay::IdentityVerification do
|
2
|
+
include_context 'users'
|
3
|
+
|
4
|
+
describe 'CREATE' do
|
5
|
+
it 'creates a new identity verification' do
|
6
|
+
created = create_new_identity_verification
|
7
|
+
expect(created).not_to be_nil
|
8
|
+
expect(created['HostedUrl']).not_to be_nil
|
9
|
+
expect(created['ReturnUrl']).not_to be_nil
|
10
|
+
expect(created['Status']).to eq('PENDING')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'GET' do
|
15
|
+
it 'fetches existing identity verification' do
|
16
|
+
created = create_new_identity_verification
|
17
|
+
fetched = MangoPay::IdentityVerification.get(created['Id'])
|
18
|
+
|
19
|
+
expect(fetched).not_to be_nil
|
20
|
+
expect(created['HostedUrl']).to eq(fetched['HostedUrl'])
|
21
|
+
expect(created['ReturnUrl']).to eq(fetched['ReturnUrl'])
|
22
|
+
expect(created['Status']).to eq(fetched['Status'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# endpoint returning 404
|
27
|
+
# describe 'GET CHECKS' do
|
28
|
+
# it 'fetches checks for an existing identity verification' do
|
29
|
+
# created = create_new_identity_verification
|
30
|
+
# checks = MangoPay::IdentityVerification.get_checks(created['Id'])
|
31
|
+
#
|
32
|
+
# expect(checks).not_to be_nil
|
33
|
+
# expect(created['Id']).to eq(checks['SessionId'])
|
34
|
+
# expect(checks['Status']).not_to be_nil
|
35
|
+
# expect(checks['CreationDate']).not_to be_nil
|
36
|
+
# expect(checks['LastUpdate']).not_to be_nil
|
37
|
+
# expect(checks['Checks']).not_to be_nil
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
|
41
|
+
def create_new_identity_verification
|
42
|
+
user = new_natural_user
|
43
|
+
return MangoPay::IdentityVerification.create(
|
44
|
+
{
|
45
|
+
ReturnUrl: 'http://example.com',
|
46
|
+
Tag: 'created by the Ruby SDK'
|
47
|
+
},
|
48
|
+
user['Id']
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -59,12 +59,12 @@ describe MangoPay::KycDocument do
|
|
59
59
|
expect(docs[0]['Id']).to eq doc3['Id']
|
60
60
|
|
61
61
|
# fetch all docs ever
|
62
|
-
docs = MangoPay::KycDocument.fetch_all()
|
62
|
+
docs = MangoPay::KycDocument.fetch_all(nil, {'afterdate' => doc1['CreationDate'] - 500, 'beforedate' => doc1['CreationDate'] + 500})
|
63
63
|
expect(docs).to be_kind_of(Array)
|
64
64
|
expect(docs.count).to be >= 3 # at least last 3 docs, but probably many more
|
65
65
|
|
66
66
|
# fetch last 3 docs (sorting by date descending)
|
67
|
-
docs = MangoPay::KycDocument.fetch_all(nil, filter = {'page' => 1, 'per_page' => 3, 'sort' => 'CreationDate:desc'})
|
67
|
+
docs = MangoPay::KycDocument.fetch_all(nil, filter = {'page' => 1, 'per_page' => 3, 'sort' => 'CreationDate:desc', 'afterdate' => doc1['CreationDate'] - 500, 'beforedate' => doc1['CreationDate'] + 500})
|
68
68
|
expect(docs).to be_kind_of(Array)
|
69
69
|
expect(docs.count).to eq 3
|
70
70
|
# all 3 are at top as lastly created
|
@@ -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,30 @@
|
|
1
|
+
describe MangoPay::PayIn::Bancontact::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('BCMC')
|
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 bancontact web payin' do
|
15
|
+
created = new_payin_bancontact_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_bancontact_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
|