mangopay4-ruby-sdk 3.44.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.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby_cd.yml +34 -0
  3. data/.github/workflows/ruby_ci.yml +30 -0
  4. data/.gitignore +30 -0
  5. data/.rspec +3 -0
  6. data/CHANGELOG.md +640 -0
  7. data/Gemfile +2 -0
  8. data/LICENSE +20 -0
  9. data/README.md +162 -0
  10. data/Rakefile +5 -0
  11. data/bin/mangopay +9 -0
  12. data/lib/generators/mangopay/install_generator.rb +60 -0
  13. data/lib/generators/templates/mangopay.rb.erb +5 -0
  14. data/lib/mangopay/acquiring.rb +56 -0
  15. data/lib/mangopay/authorization_token.rb +89 -0
  16. data/lib/mangopay/bank_account.rb +49 -0
  17. data/lib/mangopay/bankingaliases.rb +29 -0
  18. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  19. data/lib/mangopay/card.rb +54 -0
  20. data/lib/mangopay/card_registration.rb +9 -0
  21. data/lib/mangopay/client.rb +94 -0
  22. data/lib/mangopay/conversion.rb +49 -0
  23. data/lib/mangopay/deposit.rb +36 -0
  24. data/lib/mangopay/dispute.rb +152 -0
  25. data/lib/mangopay/errors.rb +66 -0
  26. data/lib/mangopay/event.rb +18 -0
  27. data/lib/mangopay/filter_parameters.rb +56 -0
  28. data/lib/mangopay/hook.rb +9 -0
  29. data/lib/mangopay/http_calls.rb +88 -0
  30. data/lib/mangopay/identity_verification.rb +16 -0
  31. data/lib/mangopay/json.rb +14 -0
  32. data/lib/mangopay/kyc_document.rb +83 -0
  33. data/lib/mangopay/legal_user.rb +21 -0
  34. data/lib/mangopay/legal_user_sca.rb +25 -0
  35. data/lib/mangopay/mandate.rb +42 -0
  36. data/lib/mangopay/natural_user.rb +20 -0
  37. data/lib/mangopay/natural_user_sca.rb +25 -0
  38. data/lib/mangopay/pay_in.rb +415 -0
  39. data/lib/mangopay/pay_out.rb +41 -0
  40. data/lib/mangopay/payment_method_metadata.rb +13 -0
  41. data/lib/mangopay/pre_authorization.rb +17 -0
  42. data/lib/mangopay/recipient.rb +35 -0
  43. data/lib/mangopay/refund.rb +19 -0
  44. data/lib/mangopay/regulatory.rb +22 -0
  45. data/lib/mangopay/report.rb +24 -0
  46. data/lib/mangopay/report_v2.rb +21 -0
  47. data/lib/mangopay/resource.rb +21 -0
  48. data/lib/mangopay/settlement.rb +21 -0
  49. data/lib/mangopay/transaction.rb +24 -0
  50. data/lib/mangopay/transfer.rb +20 -0
  51. data/lib/mangopay/ubo.rb +26 -0
  52. data/lib/mangopay/ubo_declaration.rb +32 -0
  53. data/lib/mangopay/user.rb +100 -0
  54. data/lib/mangopay/version.rb +3 -0
  55. data/lib/mangopay/virtual_account.rb +44 -0
  56. data/lib/mangopay/wallet.rb +17 -0
  57. data/lib/mangopay.rb +456 -0
  58. data/mangopay.gemspec +30 -0
  59. data/spec/mangopay/acquiring_spec.rb +176 -0
  60. data/spec/mangopay/authorization_token_spec.rb +70 -0
  61. data/spec/mangopay/bank_account_spec.rb +105 -0
  62. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  63. data/spec/mangopay/card_registration_spec.rb +123 -0
  64. data/spec/mangopay/client_spec.png +0 -0
  65. data/spec/mangopay/client_spec.rb +213 -0
  66. data/spec/mangopay/configuration_spec.rb +249 -0
  67. data/spec/mangopay/conversion_spec.rb +96 -0
  68. data/spec/mangopay/deposit_spec.rb +107 -0
  69. data/spec/mangopay/dispute_spec.png +0 -0
  70. data/spec/mangopay/dispute_spec.rb +294 -0
  71. data/spec/mangopay/event_spec.rb +33 -0
  72. data/spec/mangopay/fetch_filters_spec.rb +63 -0
  73. data/spec/mangopay/hook_spec.rb +37 -0
  74. data/spec/mangopay/idempotency_spec.rb +41 -0
  75. data/spec/mangopay/identity_verification_spec.rb +47 -0
  76. data/spec/mangopay/kyc_document_spec.png +0 -0
  77. data/spec/mangopay/kyc_document_spec.rb +118 -0
  78. data/spec/mangopay/log_requests_filter_spec.rb +26 -0
  79. data/spec/mangopay/mandate_spec.rb +99 -0
  80. data/spec/mangopay/payin_applepay_direct_spec.rb +21 -0
  81. data/spec/mangopay/payin_bancontact_web_spec.rb +30 -0
  82. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -0
  83. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +104 -0
  84. data/spec/mangopay/payin_bizum_web_spec.rb +54 -0
  85. data/spec/mangopay/payin_blik_web_spec.rb +41 -0
  86. data/spec/mangopay/payin_card_direct_spec.rb +69 -0
  87. data/spec/mangopay/payin_card_web_spec.rb +64 -0
  88. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -0
  89. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -0
  90. data/spec/mangopay/payin_giropay_web_spec.rb +30 -0
  91. data/spec/mangopay/payin_googlepay_direct_spec.rb +21 -0
  92. data/spec/mangopay/payin_ideal_web_spec.rb +30 -0
  93. data/spec/mangopay/payin_intent_spec.rb +151 -0
  94. data/spec/mangopay/payin_klarna_web_spec.rb +32 -0
  95. data/spec/mangopay/payin_mbway_web_spec.rb +32 -0
  96. data/spec/mangopay/payin_multibanco_web_spec.rb +31 -0
  97. data/spec/mangopay/payin_paybybank_web_spec.rb +56 -0
  98. data/spec/mangopay/payin_payconiq_web_spec.rb +31 -0
  99. data/spec/mangopay/payin_paypal_web_spec.rb +113 -0
  100. data/spec/mangopay/payin_preauthorized_direct_spec.rb +118 -0
  101. data/spec/mangopay/payin_satispay_web_spec.rb +32 -0
  102. data/spec/mangopay/payin_swish_web_spec.rb +30 -0
  103. data/spec/mangopay/payin_twint_web_spec.rb +30 -0
  104. data/spec/mangopay/payment_method_metadata_spec.rb +15 -0
  105. data/spec/mangopay/payout_bankwire_spec.rb +93 -0
  106. data/spec/mangopay/preauthorization_spec.rb +51 -0
  107. data/spec/mangopay/recipient_spec.rb +134 -0
  108. data/spec/mangopay/recurring_payin_spec.rb +222 -0
  109. data/spec/mangopay/refund_spec.rb +34 -0
  110. data/spec/mangopay/regulatory_spec.rb +26 -0
  111. data/spec/mangopay/report_spec.rb +40 -0
  112. data/spec/mangopay/report_v2_spec.rb +117 -0
  113. data/spec/mangopay/report_wallets_spec.rb +40 -0
  114. data/spec/mangopay/settlement_sample.csv +8 -0
  115. data/spec/mangopay/settlement_spec.rb +38 -0
  116. data/spec/mangopay/shared_resources.rb +1380 -0
  117. data/spec/mangopay/transaction_spec.rb +59 -0
  118. data/spec/mangopay/transfer_spec.rb +77 -0
  119. data/spec/mangopay/ubo_declaration_spec.rb +44 -0
  120. data/spec/mangopay/ubo_spec.rb +39 -0
  121. data/spec/mangopay/user_spec.rb +444 -0
  122. data/spec/mangopay/virtual_account_spec.rb +52 -0
  123. data/spec/mangopay/wallet_spec.rb +100 -0
  124. data/spec/spec_helper.rb +31 -0
  125. data/spec/tmp/.keep +0 -0
  126. metadata +280 -0
@@ -0,0 +1,70 @@
1
+ describe MangoPay::AuthorizationToken do
2
+
3
+ _default_static_storage = MangoPay::AuthorizationToken::Manager.storage
4
+ _new_file_storage = MangoPay::AuthorizationToken::FileStorage.new
5
+
6
+ it 'uses StaticStorage strategy by default' do
7
+ storage = _default_static_storage
8
+ expect(storage).to be_kind_of MangoPay::AuthorizationToken::StaticStorage
9
+ end
10
+
11
+ it 'allows set different storage strategies' do
12
+
13
+ # set to FileStorage
14
+ file_storage = _new_file_storage
15
+ MangoPay::AuthorizationToken::Manager.storage = file_storage
16
+ storage = MangoPay::AuthorizationToken::Manager.storage
17
+ expect(storage).to be file_storage
18
+
19
+ # reset to StaticStorage
20
+ static_storage = _default_static_storage
21
+ MangoPay::AuthorizationToken::Manager.storage = static_storage
22
+ storage = MangoPay::AuthorizationToken::Manager.storage
23
+ expect(storage).to be static_storage
24
+ end
25
+
26
+ describe MangoPay::AuthorizationToken::StaticStorage do
27
+ it 'shares tokens between calls' do
28
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage
29
+ users1 = MangoPay::User.fetch
30
+ token1 = MangoPay::AuthorizationToken::Manager.get_token
31
+ users2 = MangoPay::User.fetch
32
+ token2 = MangoPay::AuthorizationToken::Manager.get_token
33
+ expect(token1).to eq token2
34
+ expect(token1).to be token2 # moreover, it's the same instance
35
+ end
36
+ end
37
+
38
+ describe MangoPay::AuthorizationToken::FileStorage do
39
+ it 'shares tokens between calls' do
40
+ MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
41
+
42
+ users1 = MangoPay::User.fetch
43
+ token1 = MangoPay::AuthorizationToken::Manager.get_token
44
+ users2 = MangoPay::User.fetch
45
+ token2 = MangoPay::AuthorizationToken::Manager.get_token
46
+ expect(token1).to eq token2
47
+ expect(token1).not_to be token2 # it's NOT the same instance
48
+
49
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
50
+ end
51
+
52
+ it 'uses temp file with serialized token' do
53
+ MangoPay::AuthorizationToken::Manager.storage = _new_file_storage
54
+
55
+ file_path = _new_file_storage.file_path
56
+ dir_path = MangoPay.configuration.temp_dir
57
+ expect(file_path.start_with? dir_path).to be(true)
58
+
59
+ token = MangoPay::AuthorizationToken::Manager.get_token
60
+ expect(File.exists? file_path).to be(true)
61
+
62
+ f = File.open(file_path, File::RDONLY)
63
+ txt = f.read
64
+ f.close
65
+ expect(txt.include? token['access_token']).to be(true)
66
+
67
+ MangoPay::AuthorizationToken::Manager.storage = _default_static_storage # cleanup
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,105 @@
1
+ describe MangoPay::BankAccount do
2
+ include_context 'bank_accounts'
3
+
4
+ def create(params)
5
+ user = new_natural_user
6
+ params_fixed = { OwnerName: 'John', OwnerAddress: user['Address'] }.merge(params)
7
+ MangoPay::BankAccount.create(user['Id'], params_fixed)
8
+ end
9
+
10
+ describe 'CREATE' do
11
+
12
+ it 'creates a new IBAN bank detail' do
13
+ expect(new_bank_account['Id']).not_to be_nil
14
+ end
15
+
16
+ it 'creates a new GB bank detail' do
17
+ created = create({
18
+ Type: 'GB',
19
+ AccountNumber: '63956474',
20
+ SortCode: '200000',
21
+ })
22
+ expect(created['Id']).not_to be_nil
23
+ expect(created['Type']).to eq('GB')
24
+ expect(created['AccountNumber']).to eq('63956474')
25
+ expect(created['SortCode']).to eq('200000')
26
+ end
27
+
28
+ it 'creates a new US bank detail' do
29
+ created = create({
30
+ Type: 'US',
31
+ AccountNumber: '234234234234',
32
+ ABA: '234334789',
33
+ })
34
+ expect(created['Id']).not_to be_nil
35
+ expect(created['Type']).to eq('US')
36
+ expect(created['AccountNumber']).to eq('234234234234')
37
+ expect(created['ABA']).to eq('234334789')
38
+ end
39
+
40
+ it 'creates a new CA bank detail' do
41
+ created = create({
42
+ Type: 'CA',
43
+ BankName: 'TestBankName',
44
+ BranchCode: '12345',
45
+ AccountNumber: '234234234234',
46
+ InstitutionNumber: '123',
47
+ })
48
+ expect(created['Id']).not_to be_nil
49
+ expect(created['Type']).to eq('CA')
50
+ expect(created['BankName']).to eq('TestBankName')
51
+ expect(created['BranchCode']).to eq('12345')
52
+ expect(created['AccountNumber']).to eq('234234234234')
53
+ expect(created['InstitutionNumber']).to eq('123')
54
+ end
55
+
56
+ it 'creates a new OTHER bank detail' do
57
+ created = create({
58
+ Type: 'OTHER',
59
+ Country: 'FR',
60
+ AccountNumber: '234234234234',
61
+ BIC: 'BINAADADXXX',
62
+ })
63
+ expect(created['Id']).not_to be_nil
64
+ expect(created['Type']).to eq('OTHER')
65
+ expect(created['Country']).to eq('FR')
66
+ expect(created['AccountNumber']).to eq('234234234234')
67
+ expect(created['BIC']).to eq('BINAADADXXX')
68
+ end
69
+
70
+ end
71
+
72
+ describe 'FETCH' do
73
+
74
+ it 'fetches all the bank details' do
75
+ list = MangoPay::BankAccount.fetch(new_bank_account['UserId'])
76
+ expect(list).to be_kind_of(Array)
77
+ expect(list[0]['Id']).to eq(new_bank_account['Id'])
78
+ end
79
+
80
+ it 'fetches single bank detail' do
81
+ single = MangoPay::BankAccount.fetch(new_bank_account['UserId'], new_bank_account['Id'])
82
+ expect(single['Id']).to eq(new_bank_account['Id'])
83
+ end
84
+ end
85
+
86
+ describe 'UPDATE' do
87
+ it 'disactivates a bank account' do
88
+ usr_id = new_bank_account['UserId']
89
+ acc_id = new_bank_account['Id']
90
+
91
+ changed = MangoPay::BankAccount.update(usr_id, acc_id, {Active: false})
92
+ fetched = MangoPay::BankAccount.fetch(usr_id, acc_id)
93
+ expect(changed['Active']).to eq(false)
94
+ expect(fetched['Active']).to eq(false)
95
+ end
96
+ end
97
+
98
+ describe 'FETCH Transaction' do
99
+ it "fetches a bank account's transactions" do
100
+ bank_account = new_bank_account
101
+ transactions = MangoPay::BankAccount.transactions(bank_account['Id'])
102
+ expect(transactions).to be_an(Array)
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,29 @@
1
+ describe MangoPay::BankingAliases do
2
+ include_context 'users'
3
+ include_context 'wallets'
4
+ include_context 'bankingaliases'
5
+
6
+ describe 'CREATE' do
7
+ it 'creates a new banking alias' do
8
+ expect(new_banking_alias['CreditedUserId']).to eq(new_natural_user['Id'])
9
+ end
10
+ end
11
+
12
+ describe 'UPDATE' do
13
+ it 'updates a banking alias' do
14
+ updated_banking_alias = MangoPay::BankingAliases.update(new_banking_alias['Id'] ,{
15
+ Active: false
16
+ })
17
+ expect(updated_banking_alias['Active']).to eq(false)
18
+ end
19
+ end
20
+
21
+ describe 'FETCH' do
22
+ it 'fetches all the banking aliases for a wallet' do
23
+ bankingaliases = MangoPay::BankingAliases.fetch_for_wallet(new_banking_alias['WalletId'])
24
+ expect(bankingaliases).to be_kind_of(Array)
25
+ expect(bankingaliases).not_to be_empty
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,123 @@
1
+ describe MangoPay::CardRegistration do
2
+ include_context 'users'
3
+ include_context 'payins'
4
+
5
+ describe 'CREATE' do
6
+ it 'creates a new card registration' do
7
+ created = new_card_registration
8
+ expect(created['Id']).not_to be_nil
9
+ expect(created['AccessKey']).not_to be_nil
10
+ expect(created['PreregistrationData']).not_to be_nil
11
+ expect(created['CardRegistrationURL']).not_to be_nil
12
+ expect(created['RegistrationData']).to be_nil
13
+ expect(created['CardId']).to be_nil
14
+ expect(created['UserId']).to eq(new_natural_user["Id"])
15
+ expect(created['Currency']).to eq('EUR')
16
+ expect(created['Status']).to eq('CREATED')
17
+ end
18
+ end
19
+
20
+ describe 'UPDATE' do
21
+ it 'updates a card registration' do
22
+ created = new_card_registration
23
+ updated = MangoPay::CardRegistration.update(created['Id'] ,{
24
+ RegistrationData: 'test RegistrationData'
25
+ })
26
+ expect(updated['RegistrationData']).to eq('test RegistrationData')
27
+ end
28
+ end
29
+
30
+ describe 'FETCH' do
31
+ it 'fetches a card registration' do
32
+ created = new_card_registration
33
+ fetched = MangoPay::CardRegistration.fetch(created['Id'])
34
+ expect(fetched['Id']).to eq(created['Id'])
35
+ expect(fetched['UserId']).to eq(created['UserId'])
36
+ expect(fetched['Tag']).to eq(created['Tag'])
37
+ end
38
+ end
39
+
40
+ describe 'TOKENIZATION PROCESS' do
41
+ it 'fills-in registration data and links it to a newly created card' do
42
+ completed = new_card_registration_completed
43
+ reg_data = completed['RegistrationData']
44
+ card_id = completed['CardId']
45
+
46
+ # reg data filled-in
47
+ expect(reg_data).not_to be_nil
48
+ expect(reg_data).to be_kind_of String
49
+ expect(reg_data).not_to be_empty
50
+
51
+ # card id filled-in...
52
+ expect(card_id).not_to be_nil
53
+
54
+ # ...and points to existing (newly created) card
55
+ card = MangoPay::Card.fetch(card_id)
56
+ expect(card['Id']).to eq card_id
57
+
58
+ ################################################################################
59
+ # cannot test updating: one can only put a CARD from "VALID" to "INVALID"
60
+ # # let's test updating the card too
61
+ # expect(card['Validity']).to eq 'UNKNOWN'
62
+ # card_updated = MangoPay::Card.update(card_id ,{
63
+ # Validity: 'INVALID'
64
+ # })
65
+ # expect(card_updated['Validity']).to eq 'INVALID'
66
+ # expect(MangoPay::Card.fetch(card_id)['Validity']).to eq 'INVALID'
67
+ ################################################################################
68
+ end
69
+
70
+ describe '.get_by_fingerprint' do
71
+ it 'retrieves list of cards having same fingerprint' do
72
+ completed = new_card_registration_completed
73
+ card_id = completed['CardId']
74
+ card = MangoPay::Card.fetch(card_id)
75
+ fingerprint = card['Fingerprint']
76
+ result = MangoPay::Card.get_by_fingerprint(fingerprint)
77
+
78
+ expect(result).to be_kind_of(Array)
79
+ result.each do |card|
80
+ expect(card['Fingerprint']).to eq fingerprint
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ describe 'FETCH Transactions' do
87
+ it "retrieves list of card's transactions" do
88
+ card_id = new_card_registration_completed['CardId']
89
+ transactions = MangoPay::Card.transactions(card_id)
90
+ expect(transactions).to be_an(Array)
91
+ end
92
+ end
93
+
94
+ describe 'VALIDATE CARD' do
95
+ it "validates a card" do
96
+ created = new_card_registration_completed
97
+ validated = create_card_validation(created['UserId'], created['CardId'])
98
+
99
+ expect(validated).to_not be_nil
100
+ end
101
+
102
+ it "fetches card validation" do
103
+ created = new_card_registration_completed
104
+ card_validation = create_card_validation(created['UserId'], created['CardId'])
105
+ fetched_card_validation = MangoPay::Card.get_card_validation(created['CardId'], card_validation['Id'])
106
+
107
+ expect(card_validation['Id']).equal? fetched_card_validation['Id']
108
+ end
109
+ end
110
+
111
+ describe 'Get transactions by card fingerprint' do
112
+ it 'retrieves list of transactions for a fingerprint' do
113
+ completed = new_card_registration_completed
114
+ card_id = completed['CardId']
115
+ card = MangoPay::Card.fetch(card_id)
116
+ fingerprint = card['Fingerprint']
117
+ result = MangoPay::Card.get_transactions_by_fingerprint(fingerprint)
118
+
119
+ expect(result).to be_kind_of(Array)
120
+ expect(result.count).to be > 0
121
+ end
122
+ end
123
+ end
Binary file
@@ -0,0 +1,213 @@
1
+ describe MangoPay::Client do
2
+ include_context 'users'
3
+ include_context 'payins'
4
+
5
+ describe 'FETCH' do
6
+ it 'fetches the current client details' do
7
+ clnt = MangoPay::Client.fetch
8
+ expect(clnt['ClientId']).to eq(MangoPay.configuration.client_id)
9
+ end
10
+ end
11
+
12
+ describe 'FETCH' do
13
+ it "fetches the client headquarter's phone number" do
14
+ client = MangoPay::Client.fetch
15
+ expect(client['HeadquartersPhoneNumber']).to_not be_nil
16
+ end
17
+ end
18
+
19
+ describe 'UPDATE' do
20
+ it 'updates the current client details' do
21
+ clnt = MangoPay::Client.fetch
22
+ before = clnt['PrimaryThemeColour']
23
+ after = before == '#aaaaaa' ? '#bbbbbb' : '#aaaaaa' # change the color
24
+ clnt['PrimaryThemeColour'] = after
25
+ clnt['HeadquartersAddress'] = {
26
+ AddressLine1: 'Rue Dandelion, n. 17',
27
+ City: 'Lyon',
28
+ Country: 'FR',
29
+ PostalCode: '150770'
30
+ }
31
+ clnt['TechEmails'] = ['support@mangopay.com']
32
+ phoneNumber = rand(99999999).to_s
33
+ clnt['HeadquartersPhoneNumber'] = phoneNumber
34
+
35
+ updated = MangoPay::Client.update(clnt)
36
+ expect(updated['ClientId']).to eq(MangoPay.configuration.client_id)
37
+ expect(updated['PrimaryThemeColour']).to eq(after)
38
+ expect(updated['HeadquartersPhoneNumber']).to eq(phoneNumber)
39
+ end
40
+ end
41
+
42
+ describe 'UPLOAD LOGO' do
43
+ xit 'accepts Base64 encoded file content' do
44
+ fnm = __FILE__.sub('.rb', '.png')
45
+ bts = File.open(fnm, 'rb') { |f| f.read }
46
+ b64 = Base64.encode64(bts)
47
+ ret = MangoPay::Client.upload_logo(b64)
48
+ expect(ret).to_not be_nil
49
+ end
50
+
51
+ xit 'accepts file path' do
52
+ fnm = __FILE__.sub('.rb', '.png')
53
+ ret = MangoPay::Client.upload_logo(nil, fnm)
54
+ expect(ret).to_not be_nil
55
+ end
56
+
57
+ it 'fails when input string is not base64-encoded' do
58
+ file = 'any file content...'
59
+ expect { MangoPay::Client.upload_logo(file) }.to raise_error { |err|
60
+ expect(err).to be_a MangoPay::ResponseError
61
+ expect(err.code).to eq '400'
62
+ expect(err.type).to eq 'param_error'
63
+ }
64
+ end
65
+ end
66
+
67
+ describe 'fetch_wallets' do
68
+ it 'fetches all client wallets' do
69
+ wlts = MangoPay::Client.fetch_wallets
70
+ expect(wlts).to be_kind_of(Array)
71
+ expect(wlts).not_to be_empty
72
+ end
73
+
74
+ it 'fetches all client fees wallets' do
75
+ wlts = MangoPay::Client.fetch_wallets('fees')
76
+ expect(wlts).to be_kind_of(Array)
77
+ expect(wlts).not_to be_empty
78
+ expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['FEES'])
79
+ end
80
+
81
+ it 'fetches all client credit wallets' do
82
+ wlts = MangoPay::Client.fetch_wallets('credit')
83
+ expect(wlts).to be_kind_of(Array)
84
+ expect(wlts).not_to be_empty
85
+ expect((wlts.map { |m| m['FundsType'] }).uniq).to eq(['CREDIT'])
86
+ end
87
+ end
88
+
89
+ describe 'fetch_wallet' do
90
+ it 'fetches one of client wallets by funds type (fees) and currency' do
91
+ wlt = MangoPay::Client.fetch_wallet('fees', 'EUR')
92
+ expect(wlt).to be_kind_of(Hash)
93
+ expect(wlt['FundsType']).to eq('FEES')
94
+ expect(wlt['Currency']).to eq('EUR')
95
+ end
96
+
97
+ it 'fetches one of client wallets by funds type (credit) and currency' do
98
+ wlt = MangoPay::Client.fetch_wallet('credit', 'EUR')
99
+ expect(wlt).to be_kind_of(Hash)
100
+ expect(wlt['FundsType']).to eq('CREDIT')
101
+ expect(wlt['Currency']).to eq('EUR')
102
+ end
103
+ end
104
+
105
+ describe 'fetch_wallets_transactions' do
106
+ it 'fetches transactions for all client wallets' do
107
+ pending("Endpoint removed")
108
+ trns = MangoPay::Client.fetch_wallets_transactions
109
+ expect(trns).to be_kind_of(Array)
110
+ expect(trns).not_to be_empty
111
+ end
112
+ end
113
+
114
+ describe 'fetch_wallets_transactions' do
115
+ it 'fetches transactions of one of client wallets by funds type (fees) and currency' do
116
+ trns = MangoPay::Client.fetch_wallet_transactions('fees', 'EUR')
117
+ expect(trns).to be_kind_of(Array)
118
+ expect(trns).not_to be_empty
119
+ #expect((trns.map {|m| m['DebitedWalletId']}).uniq).to eq(['FEES_EUR'])
120
+ end
121
+
122
+ it 'fetches transactions of one of client wallets by funds type (credit) and currency' do
123
+ trns = MangoPay::Client.fetch_wallet_transactions('credit', 'EUR')
124
+ expect(trns).to be_kind_of(Array)
125
+ expect(trns).not_to be_empty
126
+ #expect((trns.map {|m| m['CreditedWalletId']}).uniq).to eq(['CREDIT_EUR'])
127
+ end
128
+ end
129
+
130
+ # describe 'validate' do
131
+ # it 'validates card' do
132
+ # client = MangoPay::Client.fetch
133
+ # completed = new_card_registration_completed
134
+ # card_id = completed['CardId']
135
+ # client_id = client['ClientId']
136
+ #
137
+ # card = MangoPay::Client.validate(client_id, card_id)
138
+ # expect(client).not_to be_nil
139
+ # expect(card).not_to be_nil
140
+ # end
141
+ # end
142
+
143
+ describe 'create_bank_account' do
144
+ it 'creates a new bank account' do
145
+ bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
146
+ OwnerName: 'John',
147
+ OwnerAddress: {
148
+ AddressLine1: 'Le Palais Royal',
149
+ AddressLine2: '8 Rue de Montpensier',
150
+ City: 'Paris',
151
+ Region: '',
152
+ PostalCode: '75001',
153
+ Country: 'FR'
154
+ },
155
+ IBAN: 'FR7630004000031234567890143',
156
+ BIC: 'BNPAFRPP',
157
+ Tag: 'Test bank account')
158
+ expect(bank_account).not_to be_nil
159
+ expect(bank_account['Id']).not_to be_nil
160
+ end
161
+ end
162
+
163
+ describe 'create_payout' do
164
+ it 'creates a new payout' do
165
+ wallets = MangoPay::Client.fetch_wallets('FEES')
166
+ bank_account = MangoPay::Client.create_bank_account(Type: 'IBAN',
167
+ OwnerName: 'John',
168
+ OwnerAddress: {
169
+ AddressLine1: 'Le Palais Royal',
170
+ AddressLine2: '8 Rue de Montpensier',
171
+ City: 'Paris',
172
+ Region: '',
173
+ PostalCode: '75001',
174
+ Country: 'FR'
175
+ },
176
+ IBAN: 'FR7630004000031234567890143',
177
+ BIC: 'BNPAFRPP',
178
+ Tag: 'Test bank account')
179
+ pay_out = MangoPay::Client.create_payout(BankAccountId: bank_account['Id'],
180
+
181
+ DebitedFunds: {
182
+ Currency: 'EUR',
183
+ Amount: 12
184
+ },
185
+ DebitedWalletId: wallets[0]['Id'],
186
+ BankWireRef: 'invoice 7282',
187
+ PayoutModeRequested: 'STANDARD',
188
+ Tag: 'bla')
189
+
190
+ expect(pay_out).not_to be_nil
191
+ expect(pay_out['Id']).not_to be_nil
192
+ end
193
+ end
194
+
195
+ describe 'create payin bankwire direct' do
196
+ it 'creates the payin' do
197
+ dto = {
198
+ "CreditedWalletId": "CREDIT_EUR",
199
+ "DeclaredDebitedFunds": {
200
+ "Currency": "EUR",
201
+ "Amount": 1000
202
+ }
203
+ }
204
+ created = MangoPay::Client.create_bank_wire_direct_pay_in(dto)
205
+ expect(created).not_to be_nil
206
+ expect(created['Id']).not_to be_nil
207
+ expect(created['Type']).to eq('PAYIN')
208
+ expect(created['Status']).to eq('CREATED')
209
+ expect(created['PaymentType']).to eq('BANK_WIRE')
210
+ expect(created['ExecutionType']).to eq('DIRECT')
211
+ end
212
+ end
213
+ end