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
@@ -3,6 +3,10 @@ shared_context 'users' do
|
|
3
3
|
###############################################
|
4
4
|
|
5
5
|
let(:new_natural_user) { create_new_natural_user }
|
6
|
+
let(:new_natural_user_sca_payer) { create_new_natural_user_sca_payer }
|
7
|
+
let(:new_natural_user_sca_owner) { create_new_natural_user_sca_owner }
|
8
|
+
let(:new_legal_user_sca_payer) { create_new_legal_user_sca_payer }
|
9
|
+
let(:new_legal_user_sca_owner) { create_new_legal_user_sca_owner }
|
6
10
|
|
7
11
|
def define_new_natural_user
|
8
12
|
{
|
@@ -27,10 +31,138 @@ shared_context 'users' do
|
|
27
31
|
}
|
28
32
|
end
|
29
33
|
|
34
|
+
def define_new_natural_user_sca_payer
|
35
|
+
{
|
36
|
+
"UserCategory": "PAYER",
|
37
|
+
"TermsAndConditionsAccepted": false,
|
38
|
+
"FirstName": "Alex",
|
39
|
+
"LastName": "Smith",
|
40
|
+
"Email": "alex.smith@example.com",
|
41
|
+
"Address": {
|
42
|
+
"AddressLine1": "3 rue de la Cité",
|
43
|
+
"AddressLine2": "Appartement 7",
|
44
|
+
"City": "Paris",
|
45
|
+
"Region": "Île-de-France",
|
46
|
+
"PostalCode": "75004",
|
47
|
+
"Country": "FR"
|
48
|
+
},
|
49
|
+
"Tag": "Created using the Mangopay API Postman collection",
|
50
|
+
"PhoneNumber": "0611111111",
|
51
|
+
"PhoneNumberCountry": "FR"
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def define_new_natural_user_sca_owner
|
56
|
+
{
|
57
|
+
"UserCategory": "OWNER",
|
58
|
+
"TermsAndConditionsAccepted": true,
|
59
|
+
"FirstName": "Alex",
|
60
|
+
"LastName": "Smith",
|
61
|
+
"Email": "alex.smith@example.com",
|
62
|
+
"Address": {
|
63
|
+
"AddressLine1": "3 rue de la Cité",
|
64
|
+
"AddressLine2": "Appartement 7",
|
65
|
+
"City": "Paris",
|
66
|
+
"Region": "Île-de-France",
|
67
|
+
"PostalCode": "75004",
|
68
|
+
"Country": "FR"
|
69
|
+
},
|
70
|
+
"Birthday": 652117514,
|
71
|
+
"CountryOfResidence": "FR",
|
72
|
+
"Nationality": "FR",
|
73
|
+
"Tag": "Created using the Mangopay API Postman collection",
|
74
|
+
"PhoneNumber": "0611111111",
|
75
|
+
"PhoneNumberCountry": "FR"
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def define_new_legal_user_sca_payer
|
80
|
+
{
|
81
|
+
"UserCategory": "PAYER",
|
82
|
+
"TermsAndConditionsAccepted": false,
|
83
|
+
"LegalPersonType": "SOLETRADER",
|
84
|
+
"Name": "Alex Smith",
|
85
|
+
"Email": "alex.smith.services@example.com",
|
86
|
+
"LegalRepresentative": {
|
87
|
+
"FirstName": "Alex",
|
88
|
+
"LastName": "Smith",
|
89
|
+
"Birthday": 652117514,
|
90
|
+
"Nationality": "FR",
|
91
|
+
"CountryOfResidence": "FR",
|
92
|
+
"Email": "alex.smith@example.com",
|
93
|
+
"PhoneNumber": "0611111111",
|
94
|
+
"PhoneNumberCountry": "FR"
|
95
|
+
},
|
96
|
+
"LegalRepresentativeAddress": {
|
97
|
+
"AddressLine1": "3 rue de la Cité",
|
98
|
+
"AddressLine2": "Appartement 7",
|
99
|
+
"City": "Paris",
|
100
|
+
"Region": "Île-de-France",
|
101
|
+
"PostalCode": "75004",
|
102
|
+
"Country": "FR"
|
103
|
+
},
|
104
|
+
"Tag": "Created using the Mangopay API Postman collection"
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
def define_new_legal_user_sca_owner
|
109
|
+
{
|
110
|
+
"UserCategory": "OWNER",
|
111
|
+
"TermsAndConditionsAccepted": true,
|
112
|
+
"LegalPersonType": "SOLETRADER",
|
113
|
+
"Name": "Alex Smith",
|
114
|
+
"Email": "alex.smith.services@example.com",
|
115
|
+
"LegalRepresentative": {
|
116
|
+
"FirstName": "Alex",
|
117
|
+
"LastName": "Smith",
|
118
|
+
"Birthday": 652117514,
|
119
|
+
"Nationality": "FR",
|
120
|
+
"CountryOfResidence": "FR",
|
121
|
+
"Email": "alex.smith@example.com",
|
122
|
+
"PhoneNumber": "0611111111",
|
123
|
+
"PhoneNumberCountry": "FR"
|
124
|
+
},
|
125
|
+
"CompanyNumber": "123456789",
|
126
|
+
"HeadquartersAddress": {
|
127
|
+
"AddressLine1": "3 rue de la Cité",
|
128
|
+
"AddressLine2": "Appartement 7",
|
129
|
+
"City": "Paris",
|
130
|
+
"Region": "Île-de-France",
|
131
|
+
"PostalCode": "75004",
|
132
|
+
"Country": "FR"
|
133
|
+
},
|
134
|
+
"LegalRepresentativeAddress": {
|
135
|
+
"AddressLine1": "3 rue de la Cité",
|
136
|
+
"AddressLine2": "Appartement 7",
|
137
|
+
"City": "Paris",
|
138
|
+
"Region": "Île-de-France",
|
139
|
+
"PostalCode": "75004",
|
140
|
+
"Country": "FR"
|
141
|
+
},
|
142
|
+
"Tag": "Created using the Mangopay API Postman collection"
|
143
|
+
}
|
144
|
+
end
|
145
|
+
|
30
146
|
def create_new_natural_user
|
31
147
|
MangoPay::NaturalUser.create(define_new_natural_user)
|
32
148
|
end
|
33
149
|
|
150
|
+
def create_new_natural_user_sca_payer
|
151
|
+
MangoPay::NaturalUserSca.create(define_new_natural_user_sca_payer)
|
152
|
+
end
|
153
|
+
|
154
|
+
def create_new_natural_user_sca_owner
|
155
|
+
MangoPay::NaturalUserSca.create(define_new_natural_user_sca_owner)
|
156
|
+
end
|
157
|
+
|
158
|
+
def create_new_legal_user_sca_payer
|
159
|
+
MangoPay::LegalUserSca.create(define_new_legal_user_sca_payer)
|
160
|
+
end
|
161
|
+
|
162
|
+
def create_new_legal_user_sca_owner
|
163
|
+
MangoPay::LegalUserSca.create(define_new_legal_user_sca_owner)
|
164
|
+
end
|
165
|
+
|
34
166
|
let(:new_legal_user) do
|
35
167
|
MangoPay::LegalUser.create(
|
36
168
|
Name: 'Super',
|
@@ -83,6 +215,15 @@ shared_context 'wallets' do
|
|
83
215
|
)
|
84
216
|
end
|
85
217
|
|
218
|
+
def create_new_custom_wallet(user, currency)
|
219
|
+
MangoPay::Wallet.create(
|
220
|
+
Owners: [user['Id']],
|
221
|
+
Description: 'A test wallet',
|
222
|
+
Currency: currency,
|
223
|
+
Tag: 'Test wallet'
|
224
|
+
)
|
225
|
+
end
|
226
|
+
|
86
227
|
def wallets_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
|
87
228
|
expect(wlt1['Balance']['Amount']).to eq amnt1
|
88
229
|
expect(wlt2['Balance']['Amount']).to eq amnt2 if wlt2
|
@@ -380,7 +521,7 @@ shared_context 'payins' do
|
|
380
521
|
data: cardreg['PreregistrationData'],
|
381
522
|
accessKeyRef: cardreg['AccessKey'],
|
382
523
|
cardNumber: 4970107111111119,
|
383
|
-
cardExpirationDate:
|
524
|
+
cardExpirationDate: 1229,
|
384
525
|
cardCvx: 123 }
|
385
526
|
|
386
527
|
res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
|
@@ -436,7 +577,36 @@ shared_context 'payins' do
|
|
436
577
|
Currency: 'PLN',
|
437
578
|
Tag: 'Test wallet'
|
438
579
|
)
|
439
|
-
MangoPay::PayIn::Blik::Web.create(
|
580
|
+
MangoPay::PayIn::Blik::Web.create(define_new_blik(user, wallet))
|
581
|
+
end
|
582
|
+
|
583
|
+
let(:new_payin_blik_web_with_code) do
|
584
|
+
user = new_natural_user
|
585
|
+
wallet = MangoPay::Wallet.create(
|
586
|
+
Owners: [user['Id']],
|
587
|
+
Description: 'A test wallet',
|
588
|
+
Currency: 'PLN',
|
589
|
+
Tag: 'Test wallet'
|
590
|
+
)
|
591
|
+
blik = define_new_blik(user, wallet)
|
592
|
+
blik['Code'] = '777365'
|
593
|
+
blik['IpAddress'] = '159.180.248.187'
|
594
|
+
blik['BrowserInfo'] = {
|
595
|
+
AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
|
596
|
+
JavaEnabled: true,
|
597
|
+
Language: "FR-FR",
|
598
|
+
ColorDepth: 4,
|
599
|
+
ScreenHeight: 1800,
|
600
|
+
ScreenWidth: 400,
|
601
|
+
JavascriptEnabled: true,
|
602
|
+
TimeZoneOffset: "+60",
|
603
|
+
UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
604
|
+
}
|
605
|
+
MangoPay::PayIn::Blik::Web.create(blik)
|
606
|
+
end
|
607
|
+
|
608
|
+
def define_new_blik(user, wallet)
|
609
|
+
{
|
440
610
|
AuthorId: user['Id'],
|
441
611
|
CreditedWalletId: wallet['Id'],
|
442
612
|
DebitedFunds: { Currency: 'PLN', Amount: 199 },
|
@@ -444,7 +614,7 @@ shared_context 'payins' do
|
|
444
614
|
StatementDescriptor: "ruby",
|
445
615
|
Tag: 'Test PayIn/Blik/Web',
|
446
616
|
ReturnURL: 'https://example.com'
|
447
|
-
|
617
|
+
}
|
448
618
|
end
|
449
619
|
|
450
620
|
###############################################
|
@@ -554,6 +724,52 @@ shared_context 'payins' do
|
|
554
724
|
)
|
555
725
|
end
|
556
726
|
|
727
|
+
###############################################
|
728
|
+
# Bancontact/web
|
729
|
+
###############################################
|
730
|
+
let(:new_payin_bancontact_web) do
|
731
|
+
MangoPay::PayIn::Bancontact::Web.create(
|
732
|
+
AuthorId: new_natural_user['Id'],
|
733
|
+
CreditedWalletId: new_wallet['Id'],
|
734
|
+
DebitedFunds: { Currency: 'EUR', Amount: 400 },
|
735
|
+
Fees: { Currency: 'EUR', Amount: 10 },
|
736
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
737
|
+
StatementDescriptor: "test",
|
738
|
+
Tag: 'Test PayIn/Bancontact/Web',
|
739
|
+
Culture: 'FR'
|
740
|
+
)
|
741
|
+
end
|
742
|
+
|
743
|
+
###############################################
|
744
|
+
# Twint/web
|
745
|
+
###############################################
|
746
|
+
let(:new_payin_twint_web) do
|
747
|
+
MangoPay::PayIn::Twint::Web.create(
|
748
|
+
AuthorId: new_natural_user['Id'],
|
749
|
+
CreditedWalletId: create_new_custom_wallet(new_natural_user, 'CHF')['Id'],
|
750
|
+
DebitedFunds: { Currency: 'CHF', Amount: 50 },
|
751
|
+
Fees: { Currency: 'CHF', Amount: 10 },
|
752
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
753
|
+
StatementDescriptor: "test",
|
754
|
+
Tag: 'Test PayIn/Twint/Web'
|
755
|
+
)
|
756
|
+
end
|
757
|
+
|
758
|
+
###############################################
|
759
|
+
# Swish/web
|
760
|
+
###############################################
|
761
|
+
let(:new_payin_swish_web) do
|
762
|
+
MangoPay::PayIn::Swish::Web.create(
|
763
|
+
AuthorId: new_natural_user['Id'],
|
764
|
+
CreditedWalletId: create_new_custom_wallet(new_natural_user, 'SEK')['Id'],
|
765
|
+
DebitedFunds: { Currency: 'SEK', Amount: 400 },
|
766
|
+
Fees: { Currency: 'SEK', Amount: 10 },
|
767
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
768
|
+
StatementDescriptor: "test",
|
769
|
+
Tag: 'Test PayIn/Swish/Web'
|
770
|
+
)
|
771
|
+
end
|
772
|
+
|
557
773
|
###############################################
|
558
774
|
# PAYPAL/web V2
|
559
775
|
###############################################
|
@@ -755,6 +971,25 @@ shared_context 'payins' do
|
|
755
971
|
MangoPay::Wallet.fetch(pay_in['CreditedWalletId'])
|
756
972
|
end
|
757
973
|
|
974
|
+
let(:new_payin_paybybank_web) do
|
975
|
+
MangoPay::PayIn::PayByBank::Web.create(
|
976
|
+
AuthorId: new_natural_user['Id'],
|
977
|
+
CreditedWalletId: create_new_custom_wallet(new_natural_user, 'EUR')['Id'],
|
978
|
+
DebitedFunds: { Currency: 'EUR', Amount: 400 },
|
979
|
+
Fees: { Currency: 'EUR', Amount: 0 },
|
980
|
+
ReturnURL: 'http://www.my-site.com/returnURL',
|
981
|
+
StatementDescriptor: "test",
|
982
|
+
Tag: 'Test PayIn/PayByBank/Web',
|
983
|
+
Country: 'DE',
|
984
|
+
IBAN: 'DE03500105177564668331',
|
985
|
+
BIC: 'AACSDE33',
|
986
|
+
Scheme: 'SEPA_INSTANT_CREDIT_TRANSFER',
|
987
|
+
BankName: 'de-demobank-open-banking-embedded-templates',
|
988
|
+
Culture: 'EN',
|
989
|
+
PaymentFlow: 'WEB'
|
990
|
+
)
|
991
|
+
end
|
992
|
+
|
758
993
|
end
|
759
994
|
|
760
995
|
###############################################
|
@@ -952,7 +1187,7 @@ shared_context 'instant_conversion' do
|
|
952
1187
|
MangoPay::Conversion.create_quote(
|
953
1188
|
CreditedFunds: { Currency: 'GBP' },
|
954
1189
|
DebitedFunds: { Currency: 'EUR', Amount: 50 },
|
955
|
-
Duration:
|
1190
|
+
Duration: 300,
|
956
1191
|
Tag: 'Created using the Mangopay Ruby SDK'
|
957
1192
|
)
|
958
1193
|
end
|
@@ -982,4 +1217,56 @@ shared_context 'payment_method_metadata' do
|
|
982
1217
|
Bin: pay_in['CardInfo']['BIN']
|
983
1218
|
)
|
984
1219
|
end
|
1220
|
+
end
|
1221
|
+
|
1222
|
+
###############################################
|
1223
|
+
shared_context 'virtual_account' do
|
1224
|
+
###############################################
|
1225
|
+
include_context 'users'
|
1226
|
+
include_context 'wallets'
|
1227
|
+
|
1228
|
+
def new_virtual_account(wallet_id)
|
1229
|
+
create_virtual_account = {
|
1230
|
+
Country: 'FR',
|
1231
|
+
VirtualAccountPurpose: 'Collection',
|
1232
|
+
Tag: 'create virtual account tag'
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
MangoPay::VirtualAccount.create(wallet_id, create_virtual_account)
|
1236
|
+
end
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
shared_context 'recipient' do
|
1240
|
+
include_context 'users'
|
1241
|
+
|
1242
|
+
let(:new_recipient) { create_new_recipient(create_new_natural_user_sca_owner['Id']) }
|
1243
|
+
|
1244
|
+
def create_new_recipient(user_id)
|
1245
|
+
MangoPay::Recipient.create(define_new_recipient, user_id)
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
def define_new_recipient
|
1249
|
+
{
|
1250
|
+
"DisplayName": "Alex Smith GBP account",
|
1251
|
+
"PayoutMethodType": "LocalBankTransfer",
|
1252
|
+
"RecipientType": "Individual",
|
1253
|
+
"Currency": "GBP",
|
1254
|
+
"IndividualRecipient": {
|
1255
|
+
"FirstName": "Alex",
|
1256
|
+
"LastName": "Smith",
|
1257
|
+
"Address": {
|
1258
|
+
"AddressLine1": "10 Kingsway",
|
1259
|
+
"City": "London",
|
1260
|
+
"PostalCode": "WC2B 6LH",
|
1261
|
+
"Country": "GB"
|
1262
|
+
}
|
1263
|
+
},
|
1264
|
+
"LocalBankTransfer": {
|
1265
|
+
"GBP": {
|
1266
|
+
"SortCode": "200000",
|
1267
|
+
"AccountNumber": "55779911"
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
end
|
985
1272
|
end
|
data/spec/mangopay/user_spec.rb
CHANGED
@@ -19,6 +19,38 @@ describe MangoPay::User do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
describe 'CREATE SCA' do
|
23
|
+
it 'creates a new SCA natural user payer' do
|
24
|
+
user = new_natural_user_sca_payer
|
25
|
+
expect(user["FirstName"]).to eq('Alex')
|
26
|
+
expect(user["UserCategory"]).to eq('PAYER')
|
27
|
+
expect(user["UserStatus"]).to eq('ACTIVE')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'creates a new SCA natural user owner' do
|
31
|
+
user = new_natural_user_sca_owner
|
32
|
+
expect(user["FirstName"]).to eq('Alex')
|
33
|
+
expect(user["UserCategory"]).to eq('OWNER')
|
34
|
+
expect(user["UserStatus"]).to eq('PENDING_USER_ACTION')
|
35
|
+
expect(user["PendingUserAction"]["RedirectUrl"]).not_to be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'creates a new SCA legal user payer' do
|
39
|
+
user = new_legal_user_sca_payer
|
40
|
+
expect(user["Name"]).to eq('Alex Smith')
|
41
|
+
expect(user["UserCategory"]).to eq('PAYER')
|
42
|
+
expect(user["UserStatus"]).to eq('ACTIVE')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'creates a new SCA legal user owner' do
|
46
|
+
user = new_legal_user_sca_owner
|
47
|
+
expect(user["Name"]).to eq('Alex Smith')
|
48
|
+
expect(user["UserCategory"]).to eq('OWNER')
|
49
|
+
expect(user["UserStatus"]).to eq('PENDING_USER_ACTION')
|
50
|
+
expect(user["PendingUserAction"]["RedirectUrl"]).not_to be_nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
22
54
|
describe 'UPDATE' do
|
23
55
|
it 'updates a natural user' do
|
24
56
|
updated_user = MangoPay::NaturalUser.update(new_natural_user['Id'] ,{
|
@@ -49,6 +81,82 @@ describe MangoPay::User do
|
|
49
81
|
end
|
50
82
|
end
|
51
83
|
|
84
|
+
describe 'UPDATE SCA' do
|
85
|
+
it 'updates a SCA natural user' do
|
86
|
+
user = new_natural_user_sca_owner
|
87
|
+
updated_user = MangoPay::NaturalUserSca.update(user['Id'] ,{
|
88
|
+
FirstName: 'Jack'
|
89
|
+
})
|
90
|
+
fetched = MangoPay::NaturalUserSca.fetch(user['Id'])
|
91
|
+
expect(updated_user['FirstName']).to eq('Jack')
|
92
|
+
expect(updated_user['FirstName']).to eq(fetched['FirstName'])
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'updates a SCA legal user' do
|
96
|
+
user = new_legal_user_sca_owner
|
97
|
+
legal_representative = user['LegalRepresentative']
|
98
|
+
legal_representative['FirstName'] = 'Jack'
|
99
|
+
updated_user = MangoPay::LegalUserSca.update(user['Id'] ,{
|
100
|
+
LegalRepresentative: legal_representative
|
101
|
+
})
|
102
|
+
fetched = MangoPay::LegalUserSca.fetch(user['Id'])
|
103
|
+
expect(updated_user['LegalRepresentative']['FirstName']).to eq('Jack')
|
104
|
+
expect(updated_user['LegalRepresentative']['FirstName']).to eq(fetched['LegalRepresentative']['FirstName'])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'CATEGORIZE SCA' do
|
109
|
+
it 'transitions SCA natural user Payer to Owner' do
|
110
|
+
user = new_natural_user_sca_payer
|
111
|
+
categorized = MangoPay::NaturalUserSca.categorize(user['Id'] ,{
|
112
|
+
"UserCategory": "OWNER",
|
113
|
+
"TermsAndConditionsAccepted": true,
|
114
|
+
"Birthday": 652117514,
|
115
|
+
"Nationality": "FR",
|
116
|
+
"CountryOfResidence": "FR"
|
117
|
+
})
|
118
|
+
fetched = MangoPay::NaturalUserSca.fetch(user['Id'])
|
119
|
+
expect(user['UserCategory']).to eq('PAYER')
|
120
|
+
expect(categorized['UserCategory']).to eq('OWNER')
|
121
|
+
expect(fetched['UserCategory']).to eq('OWNER')
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'transitions SCA legal user Payer to Owner' do
|
125
|
+
user = new_legal_user_sca_payer
|
126
|
+
categorized = MangoPay::LegalUserSca.categorize(user['Id'] ,{
|
127
|
+
"UserCategory": "OWNER",
|
128
|
+
"TermsAndConditionsAccepted": true,
|
129
|
+
"LegalRepresentative": {
|
130
|
+
"Birthday": 652117514,
|
131
|
+
"Nationality": "FR",
|
132
|
+
"CountryOfResidence": "FR",
|
133
|
+
"Email": "alex.smith@example.com"
|
134
|
+
},
|
135
|
+
"HeadquartersAddress": {
|
136
|
+
"AddressLine1": "3 rue de la Cité",
|
137
|
+
"AddressLine2": "Appartement 7",
|
138
|
+
"City": "Paris",
|
139
|
+
"Region": "Île-de-France",
|
140
|
+
"PostalCode": "75004",
|
141
|
+
"Country": "FR"
|
142
|
+
},
|
143
|
+
"CompanyNumber": "123456789"
|
144
|
+
})
|
145
|
+
fetched = MangoPay::LegalUserSca.fetch(user['Id'])
|
146
|
+
expect(user['UserCategory']).to eq('PAYER')
|
147
|
+
expect(categorized['UserCategory']).to eq('OWNER')
|
148
|
+
expect(fetched['UserCategory']).to eq('OWNER')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe 'ENROLL SCA' do
|
153
|
+
it 'enrolls user' do
|
154
|
+
user = new_natural_user
|
155
|
+
enrollment_result = MangoPay::User.enroll_sca(user['Id'])
|
156
|
+
expect(enrollment_result["PendingUserAction"]["RedirectUrl"]).not_to be_nil
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
52
160
|
describe 'FETCH' do
|
53
161
|
it 'fetches all the users' do
|
54
162
|
users = MangoPay::User.fetch()
|
@@ -77,6 +185,32 @@ describe MangoPay::User do
|
|
77
185
|
end
|
78
186
|
end
|
79
187
|
|
188
|
+
describe 'FETCH SCA' do
|
189
|
+
it 'fetches a SCA legal user using the User module' do
|
190
|
+
user = new_legal_user_sca_owner
|
191
|
+
fetched = MangoPay::User.fetch_sca(new_legal_user_sca_owner['Id'])
|
192
|
+
expect(fetched['Id']).to eq(user['Id'])
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'fetches a SCA natural user using the User module' do
|
196
|
+
user = new_natural_user_sca_owner
|
197
|
+
fetched = MangoPay::User.fetch_sca(user['Id'])
|
198
|
+
expect(fetched['Id']).to eq(user['Id'])
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'fetches a SCA legal user' do
|
202
|
+
user = new_legal_user_sca_owner
|
203
|
+
fetched = MangoPay::LegalUserSca.fetch(user['Id'])
|
204
|
+
expect(fetched['Id']).to eq(user['Id'])
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'fetches a SCA natural user' do
|
208
|
+
user = new_natural_user_sca_owner
|
209
|
+
fetched = MangoPay::NaturalUserSca.fetch(user['Id'])
|
210
|
+
expect(fetched['Id']).to eq(user['Id'])
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
80
214
|
describe 'FETCH TRANSACTIONS' do
|
81
215
|
it 'fetches empty list of transactions if no transactions done' do
|
82
216
|
transactions = MangoPay::User.transactions(new_natural_user['Id'])
|
@@ -106,6 +240,14 @@ describe MangoPay::User do
|
|
106
240
|
expect(transactions_ids).to include payin['Id']
|
107
241
|
expect(transactions_ids).to include payout['Id']
|
108
242
|
end
|
243
|
+
|
244
|
+
it 'fetches transactions sca' do
|
245
|
+
begin
|
246
|
+
MangoPay::User.transactions(new_natural_user['Id'], {'ScaContext': 'USER_PRESENT'})
|
247
|
+
rescue MangoPay::ResponseError => ex
|
248
|
+
expect(ex.details['RedirectUrl']).not_to be_nil
|
249
|
+
end
|
250
|
+
end
|
109
251
|
end
|
110
252
|
|
111
253
|
describe 'FETCH WALLETS' do
|
@@ -122,6 +264,14 @@ describe MangoPay::User do
|
|
122
264
|
expect(wallets.count).to eq 1
|
123
265
|
expect(wallets.first['Id']).to eq wallet['Id']
|
124
266
|
end
|
267
|
+
|
268
|
+
it 'fetches wallets sca' do
|
269
|
+
begin
|
270
|
+
MangoPay::User.wallets(new_natural_user['Id'], {'ScaContext': 'USER_PRESENT'})
|
271
|
+
rescue MangoPay::ResponseError => ex
|
272
|
+
expect(ex.details['RedirectUrl']).not_to be_nil
|
273
|
+
end
|
274
|
+
end
|
125
275
|
end
|
126
276
|
|
127
277
|
describe 'FETCH CARDS' do
|
@@ -233,4 +383,20 @@ describe MangoPay::User do
|
|
233
383
|
end
|
234
384
|
end
|
235
385
|
=end
|
386
|
+
|
387
|
+
describe 'CLOSE' do
|
388
|
+
it 'closes a natural user' do
|
389
|
+
new_user = create_new_natural_user
|
390
|
+
MangoPay::NaturalUser.close(new_user['Id'])
|
391
|
+
closed = MangoPay::User.fetch(new_user['Id'])
|
392
|
+
expect(closed['UserStatus']).to eq('CLOSED')
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'closes a legal user' do
|
396
|
+
new_user = new_legal_user
|
397
|
+
MangoPay::LegalUser.close(new_user['Id'])
|
398
|
+
closed = MangoPay::User.fetch(new_user['Id'])
|
399
|
+
expect(closed['UserStatus']).to eq('CLOSED')
|
400
|
+
end
|
401
|
+
end
|
236
402
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe MangoPay::VirtualAccount do
|
2
|
+
include_context 'virtual_account'
|
3
|
+
include_context 'wallets'
|
4
|
+
|
5
|
+
describe 'CREATE' do
|
6
|
+
it 'can create a Virtual Account' do
|
7
|
+
wallet = new_wallet
|
8
|
+
virtual_account = new_virtual_account(wallet['Id'])
|
9
|
+
expect(virtual_account).not_to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'DEACTIVATE' do
|
14
|
+
it 'deactivates a Virtual Account' do
|
15
|
+
wallet = new_wallet
|
16
|
+
virtual_account = new_virtual_account(wallet['Id'])
|
17
|
+
deactivated = MangoPay::VirtualAccount.deactivate(wallet['Id'], virtual_account['Id'])
|
18
|
+
expect(deactivated).not_to be_nil
|
19
|
+
expect(deactivated['Status']).to eq 'CLOSED'
|
20
|
+
expect(deactivated['Id']).to eq(virtual_account['Id'])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'FETCH' do
|
25
|
+
it 'can get a Virtual Account' do
|
26
|
+
wallet = new_wallet
|
27
|
+
virtual_account = new_virtual_account(wallet['Id'])
|
28
|
+
fetched = MangoPay::VirtualAccount.fetch(wallet['Id'], virtual_account['Id'])
|
29
|
+
expect(fetched).not_to be_nil
|
30
|
+
expect(fetched['Id']).to eq(virtual_account['Id'])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'FETCH ALL' do
|
35
|
+
it 'can get all Virtual Accounts for a wallet' do
|
36
|
+
wallet = new_wallet
|
37
|
+
virtual_account = new_virtual_account(wallet['Id'])
|
38
|
+
fetched_list = MangoPay::VirtualAccount.fetch_all(wallet['Id'])
|
39
|
+
expect(fetched_list).not_to be_nil
|
40
|
+
expect(fetched_list[0]['Id']).to eq(virtual_account['Id'])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'FETCH AVAILABILITIES' do
|
45
|
+
it 'get availabilities' do
|
46
|
+
availabilities = MangoPay::VirtualAccount.fetch_availabilities
|
47
|
+
expect(availabilities).not_to be_nil
|
48
|
+
expect(availabilities['Collection']).not_to be_nil
|
49
|
+
expect(availabilities['UserOwned']).not_to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -27,6 +27,14 @@ describe MangoPay::Wallet do
|
|
27
27
|
wallet = MangoPay::Wallet.fetch(new_wallet['Id'])
|
28
28
|
expect(wallet['Id']).to eq(new_wallet['Id'])
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'fetches a wallet sca' do
|
32
|
+
begin
|
33
|
+
MangoPay::Wallet.fetch(new_wallet['Id'], nil, {'ScaContext': 'USER_PRESENT'})
|
34
|
+
rescue MangoPay::ResponseError => ex
|
35
|
+
expect(ex.details['RedirectUrl']).not_to be_nil
|
36
|
+
end
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
describe 'FETCH TRANSACTIONS' do
|
@@ -81,5 +89,12 @@ describe MangoPay::Wallet do
|
|
81
89
|
expect(by_type_pyout.first['Id']).to eq payout['Id']
|
82
90
|
end
|
83
91
|
|
92
|
+
it 'fetches transactions sca' do
|
93
|
+
begin
|
94
|
+
MangoPay::Wallet.transactions(new_wallet['Id'], {'ScaContext': 'USER_PRESENT'})
|
95
|
+
rescue MangoPay::ResponseError => ex
|
96
|
+
expect(ex.details['RedirectUrl']).not_to be_nil
|
97
|
+
end
|
98
|
+
end
|
84
99
|
end
|
85
100
|
end
|