mangopay4-ruby-sdk 3.52.0 → 4.0.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/lib/mangopay/authorization_token.rb +1 -1
  4. data/lib/mangopay/version.rb +1 -1
  5. data/mangopay.gemspec +7 -7
  6. metadata +32 -160
  7. data/.github/workflows/ruby_cd.yml +0 -34
  8. data/.github/workflows/ruby_ci.yml +0 -30
  9. data/.gitignore +0 -30
  10. data/.rspec +0 -3
  11. data/Gemfile +0 -2
  12. data/Rakefile +0 -5
  13. data/bin/mangopay +0 -9
  14. data/spec/mangopay/acquiring_spec.rb +0 -207
  15. data/spec/mangopay/authorization_token_spec.rb +0 -70
  16. data/spec/mangopay/bank_account_spec.rb +0 -105
  17. data/spec/mangopay/bankingaliases_spec.rb +0 -29
  18. data/spec/mangopay/card_registration_spec.rb +0 -123
  19. data/spec/mangopay/client_spec.png +0 -0
  20. data/spec/mangopay/client_spec.rb +0 -213
  21. data/spec/mangopay/configuration_spec.rb +0 -249
  22. data/spec/mangopay/conversion_spec.rb +0 -103
  23. data/spec/mangopay/deposit_spec.rb +0 -120
  24. data/spec/mangopay/dispute_spec.png +0 -0
  25. data/spec/mangopay/dispute_spec.rb +0 -294
  26. data/spec/mangopay/event_spec.rb +0 -33
  27. data/spec/mangopay/fetch_filters_spec.rb +0 -63
  28. data/spec/mangopay/hook_spec.rb +0 -37
  29. data/spec/mangopay/idempotency_spec.rb +0 -41
  30. data/spec/mangopay/identity_verification_spec.rb +0 -91
  31. data/spec/mangopay/kyc_document_spec.png +0 -0
  32. data/spec/mangopay/kyc_document_spec.rb +0 -118
  33. data/spec/mangopay/log_requests_filter_spec.rb +0 -26
  34. data/spec/mangopay/mandate_spec.rb +0 -99
  35. data/spec/mangopay/payin_applepay_direct_spec.rb +0 -21
  36. data/spec/mangopay/payin_bancontact_web_spec.rb +0 -30
  37. data/spec/mangopay/payin_bankwire_direct_spec.rb +0 -74
  38. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +0 -104
  39. data/spec/mangopay/payin_bizum_web_spec.rb +0 -54
  40. data/spec/mangopay/payin_blik_web_spec.rb +0 -41
  41. data/spec/mangopay/payin_card_direct_spec.rb +0 -69
  42. data/spec/mangopay/payin_card_web_spec.rb +0 -64
  43. data/spec/mangopay/payin_directdebit_direct_spec.rb +0 -37
  44. data/spec/mangopay/payin_directdebit_web_spec.rb +0 -38
  45. data/spec/mangopay/payin_giropay_web_spec.rb +0 -30
  46. data/spec/mangopay/payin_googlepay_direct_spec.rb +0 -21
  47. data/spec/mangopay/payin_ideal_web_spec.rb +0 -30
  48. data/spec/mangopay/payin_intent_spec.rb +0 -302
  49. data/spec/mangopay/payin_klarna_web_spec.rb +0 -32
  50. data/spec/mangopay/payin_mbway_web_spec.rb +0 -32
  51. data/spec/mangopay/payin_multibanco_web_spec.rb +0 -31
  52. data/spec/mangopay/payin_paybybank_web_spec.rb +0 -56
  53. data/spec/mangopay/payin_paypal_web_spec.rb +0 -114
  54. data/spec/mangopay/payin_preauthorized_direct_spec.rb +0 -135
  55. data/spec/mangopay/payin_satispay_web_spec.rb +0 -32
  56. data/spec/mangopay/payin_swish_web_spec.rb +0 -30
  57. data/spec/mangopay/payin_twint_web_spec.rb +0 -30
  58. data/spec/mangopay/payment_method_metadata_spec.rb +0 -15
  59. data/spec/mangopay/payout_bankwire_spec.rb +0 -90
  60. data/spec/mangopay/preauthorization_spec.rb +0 -51
  61. data/spec/mangopay/recipient_spec.rb +0 -135
  62. data/spec/mangopay/recurring_payin_spec.rb +0 -557
  63. data/spec/mangopay/refund_spec.rb +0 -34
  64. data/spec/mangopay/regulatory_spec.rb +0 -26
  65. data/spec/mangopay/report_spec.rb +0 -40
  66. data/spec/mangopay/report_v2_spec.rb +0 -117
  67. data/spec/mangopay/report_wallets_spec.rb +0 -40
  68. data/spec/mangopay/settlement_sample.csv +0 -8
  69. data/spec/mangopay/settlement_sample_bad.csv +0 -8
  70. data/spec/mangopay/settlement_spec.rb +0 -65
  71. data/spec/mangopay/shared_resources.rb +0 -1415
  72. data/spec/mangopay/transaction_spec.rb +0 -59
  73. data/spec/mangopay/transfer_spec.rb +0 -77
  74. data/spec/mangopay/ubo_declaration_spec.rb +0 -44
  75. data/spec/mangopay/ubo_spec.rb +0 -39
  76. data/spec/mangopay/user_spec.rb +0 -455
  77. data/spec/mangopay/virtual_account_spec.rb +0 -52
  78. data/spec/mangopay/wallet_spec.rb +0 -100
  79. data/spec/spec_helper.rb +0 -31
  80. data/spec/tmp/.keep +0 -0
@@ -1,213 +0,0 @@
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
@@ -1,249 +0,0 @@
1
- describe MangoPay::Configuration do
2
-
3
- it 'fails when calling with wrong client credentials' do
4
- expect {
5
- c = MangoPay.configuration
6
- c.client_id = 'test_asd'
7
- c.client_apiKey = '00000'
8
- MangoPay::User.fetch()
9
- }.to raise_error { |err|
10
- expect(err).to be_a MangoPay::ResponseError
11
- expect(err.code).to eq '401'
12
- expect(err.message).to eq 'invalid_client'
13
- }
14
- end
15
-
16
- it 'fails when calling with wrong client credentials, but succeeds after applying a new (correct) config' do
17
- # create a wrong configuration
18
- wrong_config = MangoPay::Configuration.new
19
- wrong_config.client_id = 'placeholder'
20
- wrong_config.client_apiKey = '0000'
21
- wrong_config.preproduction = true
22
-
23
- # create a valid configuration
24
- valid_config = MangoPay::Configuration.new
25
- valid_config.client_id = 'sdk-unit-tests'
26
- valid_config.client_apiKey = 'cqFfFrWfCcb7UadHNxx2C9Lo6Djw8ZduLi7J9USTmu8bhxxpju'
27
- valid_config.preproduction = true
28
-
29
- # add the 2 configs to the list of MangoPay configs
30
- MangoPay.add_config('wrong', wrong_config)
31
- MangoPay.add_config('valid', valid_config)
32
-
33
- # apply wrong config
34
- MangoPay.get_config('wrong').apply_configuration
35
-
36
- expect {
37
- MangoPay::User.fetch()
38
- }.to raise_error { |err|
39
- expect(err).to be_a MangoPay::ResponseError
40
- expect(err.code).to eq '401'
41
- expect(err.message).to eq 'invalid_client'
42
- }
43
-
44
- # apply valid configuration
45
- MangoPay.get_config('valid').apply_configuration
46
-
47
- # expect success
48
- users = MangoPay::User.fetch()
49
- expect(users).to be_kind_of(Array)
50
- end
51
-
52
- it 'fails when fetching a config that does not exist' do
53
- expect {
54
- MangoPay.get_config('placeholder')
55
- }.to raise_error { |err|
56
- expect(err).to be_a RuntimeError
57
- expect(err.message).to eq "Could not find any configuration with name 'placeholder'"
58
- }
59
- end
60
-
61
- it 'succeeds when removing config' do
62
- wrong_config = MangoPay::Configuration.new
63
- wrong_config.client_id = 'placeholder'
64
- wrong_config.client_apiKey = '0000'
65
- wrong_config.preproduction = true
66
-
67
- MangoPay.add_config('wrong', wrong_config)
68
-
69
- # pass when fetching config before removing it
70
- MangoPay.get_config('wrong')
71
-
72
- # remove config
73
- MangoPay.remove_config('wrong')
74
-
75
- # fail when trying to fetch after removal
76
- expect {
77
- MangoPay.get_config('wrong')
78
- }.to raise_error { |err|
79
- expect(err).to be_a RuntimeError
80
- expect(err.message).to eq "Could not find any configuration with name 'wrong'"
81
- }
82
- end
83
-
84
- it 'goes ok when calling with correct client credentials' do
85
- reset_mangopay_configuration
86
- users = MangoPay::User.fetch()
87
- expect(users).to be_kind_of(Array)
88
- end
89
-
90
- describe '.use_ssl?' do
91
- let(:configuration) { MangoPay::Configuration.new }
92
-
93
- it 'defaults to true' do
94
- expect(configuration.use_ssl?).to eq(true)
95
- end
96
-
97
- context 'when assigned to false in production' do
98
- before do
99
- configuration.use_ssl = false
100
- configuration.preproduction = false
101
- end
102
-
103
- it 'uses true as value' do
104
- expect(configuration.use_ssl?).to eq(true)
105
- end
106
- end
107
-
108
- context 'when assigned to false in preproduction' do
109
- before do
110
- configuration.use_ssl = false
111
- configuration.preproduction = true
112
- end
113
-
114
- it 'uses assigned as value' do
115
- expect(configuration.use_ssl?).to eq(false)
116
- end
117
- end
118
- end
119
-
120
- describe 'logger' do
121
- around(:each) do |example|
122
- c = MangoPay.configuration
123
- c.logger = logger
124
- c.log_file = log_file
125
- example.run
126
- c.logger = nil
127
- c.log_file = nil
128
- MangoPay.instance_variable_set(:@logger, nil)
129
- end
130
-
131
- context 'when the logger is set' do
132
- let(:logger) { Logger.new(STDOUT) }
133
-
134
- context 'when the log_file is set' do
135
- let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
136
-
137
- it 'initializes the logger using the logger option' do
138
- expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
139
- end
140
- end
141
-
142
- context 'when the log_file is not set' do
143
- let(:log_file) { nil }
144
-
145
- it 'initializes the logger using the logger option' do
146
- expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(eq(STDOUT))
147
- end
148
- end
149
- end
150
-
151
- context 'when the logger is not set' do
152
- let(:logger) { nil }
153
-
154
- context 'when the log_file is set' do
155
- let(:log_file) { File.join(MangoPay.configuration.temp_dir, 'mangopay.log.tmp') }
156
-
157
- it 'initializes the logger using the log file' do
158
- expect(MangoPay.send(:logger).instance_variable_get(:@logdev).dev).to(be_an_instance_of(File))
159
- end
160
- end
161
-
162
- context 'when the log_file is not set' do
163
- let(:log_file) { nil }
164
-
165
- it 'raises an error' do
166
- expect{ MangoPay.send(:logger) }.to raise_error NotImplementedError
167
- end
168
- end
169
- end
170
- end
171
-
172
- context 'with multithreading' do
173
- after :all do
174
- reset_mangopay_configuration
175
- end
176
-
177
- before :all do
178
- MangoPay.configuration.client_id = 'default'
179
-
180
- thread_a = Thread.new do
181
- @default_client_id = MangoPay.configuration.client_id
182
-
183
- MangoPay.configuration.client_id = 'a'
184
-
185
- # Test #configuration= & #configuration
186
- config = MangoPay::Configuration.new
187
- config.client_id = 'a'
188
- MangoPay.configuration = config
189
- @before_client_id = MangoPay.configuration.client_id
190
-
191
- # Test multithreading
192
- sleep 1 # Waits for thread B to do its business
193
- @after_client_id = MangoPay.configuration.client_id
194
-
195
- # Test #configure
196
- MangoPay.configure do |c|
197
- c.client_id = 'configured'
198
- end
199
- @configured_client_id = MangoPay.configuration.client_id
200
-
201
- # Test #with_config
202
- @before_with_config_client_id = MangoPay.configuration.client_id
203
- config = MangoPay::Configuration.new
204
- config.client_id = 'with_config'
205
- MangoPay.with_configuration(config) do
206
- @with_config_client_id = MangoPay.configuration.client_id
207
- end
208
- @after_with_config_client_id = MangoPay.configuration.client_id
209
- end
210
-
211
- thread_b = Thread.new do
212
- # Thread A does its business
213
- sleep 0.5
214
- @thread_b_default_client_id = MangoPay.configuration.client_id
215
-
216
- # Will it impact the configuration in thread A ?
217
- MangoPay.configuration.client_id = 'b'
218
- end
219
-
220
- # Wait for both threads to complete
221
- thread_a.join
222
- thread_b.join
223
- end
224
-
225
- it '#configuration & #configuration=' do
226
- expect(@before_client_id).to eq('a')
227
- end
228
-
229
- it '#configure' do
230
- expect(@configured_client_id).to eq('configured')
231
- end
232
-
233
- it '#with_configuration' do
234
- expect(@with_config_client_id).to eq('with_config')
235
- expect(@after_with_config_client_id).to eq(@before_with_config_client_id)
236
- end
237
-
238
- context "since configurations are thread-local," do
239
- it 'threads get the last configuration set as default config.' do
240
- expect(@default_client_id).to eq('default')
241
- expect(@thread_b_default_client_id).to eq('a')
242
- end
243
-
244
- it "configurations are isolated from other threads' activity." do
245
- expect(@after_client_id).to eq('a')
246
- end
247
- end
248
- end
249
- end
@@ -1,103 +0,0 @@
1
- describe MangoPay::Conversion, type: :feature do
2
- include_context 'instant_conversion'
3
-
4
- describe 'GET CONVERSION RATE' do
5
- it 'get a conversion rate' do
6
- conversion_rate = get_conversion_rate('EUR','GBP')
7
-
8
- expect(conversion_rate['ClientRate']).not_to be_nil
9
- expect(conversion_rate['MarketRate']).not_to be_nil
10
- end
11
- end
12
-
13
- describe 'CREATE INSTANT CONVERSION' do
14
- it 'creates a new instant conversion' do
15
- conversion = create_instant_conversion
16
-
17
- expect(conversion['DebitedFunds']['Amount']).not_to be_nil
18
- expect(conversion['CreditedFunds']['Amount']).not_to be_nil
19
- expect(conversion['Fees']['Amount']).not_to be_nil
20
- expect(conversion['RequestedFees']['Value']).not_to be_nil
21
- expect(conversion['Status']).equal? 'SUCCEEDED'
22
- expect(conversion['MarginsResponse']['Mangopay']).not_to be_nil
23
- expect(conversion['MarginsResponse']['User']).to be_nil
24
- end
25
- end
26
-
27
- describe 'CREATE QUOTED CONVERSION' do
28
- it 'creates a new quoted conversion' do
29
- conversion = create_quoted_conversion
30
-
31
- expect(conversion['DebitedFunds']['Amount']).not_to be_nil
32
- expect(conversion['CreditedFunds']['Amount']).not_to be_nil
33
- expect(conversion['Status']).equal? 'SUCCEEDED'
34
- end
35
- end
36
-
37
- describe 'CREATE QUOTED CONVERSION BETWEEN CLIENT WALLETS' do
38
- it 'creates a new quoted conversion' do
39
- quote = create_conversion_quote
40
-
41
- conversion = MangoPay::Conversion.create_client_wallets_quoted_conversion(
42
- QuoteId: quote['Id'],
43
- CreditedWalletType: 'CREDIT',
44
- DebitedWalletType: 'FEES'
45
- )
46
-
47
- expect(conversion['Status']).equal? 'SUCCEEDED'
48
- end
49
- end
50
-
51
- describe 'CREATE INSTANT CONVERSION BETWEEN CLIENT WALLETS' do
52
- it 'creates a new quoted conversion' do
53
- conversion = MangoPay::Conversion.create_client_wallets_instant_conversion(
54
- CreditedWalletType: 'FEES',
55
- DebitedWalletType: 'FEES',
56
- DebitedFunds: {
57
- Currency: 'GBP',
58
- Amount: 79
59
- },
60
- CreditedFunds: {
61
- Currency: 'EUR'
62
- }
63
- )
64
-
65
- expect(conversion['Status']).equal? 'SUCCEEDED'
66
- end
67
- end
68
-
69
- describe 'GET EXISTING CONVERSION' do
70
- it 'get an existing conversion' do
71
- conversion = create_instant_conversion
72
- returned_conversion = get_conversion(conversion['Id'])
73
-
74
- expect(returned_conversion['DebitedFunds']['Amount']).not_to be_nil
75
- expect(returned_conversion['CreditedFunds']['Amount']).not_to be_nil
76
- expect(conversion['Fees']['Amount']).not_to be_nil
77
- expect(returned_conversion['Status']).equal? 'SUCCEEDED'
78
- end
79
- end
80
-
81
- describe 'CREATE CONVERSION QUOTE' do
82
- it 'create a conversion quote' do
83
- conversion_quote = create_conversion_quote_with_fees
84
- expect(conversion_quote['DebitedFunds']).not_to be_nil
85
- expect(conversion_quote['CreditedFunds']).not_to be_nil
86
- expect(conversion_quote['Duration']).equal? 90
87
- expect(conversion_quote['Fees']['Amount']).not_to be_nil
88
- expect(conversion_quote['RequestedFees']['Value']).not_to be_nil
89
- expect(conversion_quote['MarginsResponse']['Mangopay']).not_to be_nil
90
- expect(conversion_quote['MarginsResponse']['User']).not_to be_nil
91
- end
92
- end
93
-
94
- describe 'GET CONVERSION QUOTE' do
95
- it 'get a conversion quote' do
96
- conversion_quote = create_conversion_quote
97
- returned_conversion_quote = get_conversion_quote(conversion_quote['Id'])
98
- expect(returned_conversion_quote['DebitedFunds']).not_to be_nil
99
- expect(returned_conversion_quote['CreditedFunds']).not_to be_nil
100
- expect(returned_conversion_quote['Duration']).equal? 90
101
- end
102
- end
103
- end
@@ -1,120 +0,0 @@
1
- describe MangoPay::Deposit do
2
- include_context 'users'
3
- include_context 'payins'
4
-
5
- describe 'CREATE' do
6
- it 'creates a new deposit' do
7
- author = new_natural_user
8
- card_registration = new_card_registration_completed
9
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
10
-
11
- assert_deposit(deposit, card_registration['CardId'], author["Id"])
12
- end
13
-
14
- it 'creates a new paypal deposit preauthorization' do
15
- author = new_natural_user
16
- preauthorization = create_new_paypal_deposit_preauthorization(author['Id'])
17
-
18
- expect(preauthorization['Id']).not_to be_nil
19
- expect(preauthorization['PaymentType']).to eq('PAYPAL')
20
- expect(preauthorization['Status']).to eq('CREATED')
21
- expect(preauthorization['PaymentStatus']).to eq('WAITING')
22
- expect(preauthorization['Reference']).not_to be_nil
23
- expect(preauthorization['LineItems']).not_to be_nil
24
- expect(preauthorization['ShippingPreference']).not_to be_nil
25
- end
26
- end
27
-
28
- describe 'GET' do
29
- it 'get an existing deposit' do
30
- author = new_natural_user
31
- card_registration = new_card_registration_completed
32
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
33
-
34
- assert_deposit(deposit, card_registration['CardId'], author["Id"])
35
-
36
- fetched_deposit = MangoPay::Deposit.get(deposit['Id'])
37
-
38
- assert_deposit(fetched_deposit, card_registration['CardId'], author["Id"])
39
- end
40
-
41
- it 'gets all deposits for a user' do
42
- author = new_natural_user
43
- card_registration = new_card_registration_completed
44
- create_new_deposit(card_registration['CardId'], author['Id'])
45
-
46
- result = MangoPay::Deposit.get_all_for_user(author['Id'])
47
- expect(result).to be_kind_of(Array)
48
- expect(result.count).to be > 0
49
- end
50
-
51
- it 'gets all deposits for a card' do
52
- author = new_natural_user
53
- card_registration = new_card_registration_completed
54
- create_new_deposit(card_registration['CardId'], author['Id'])
55
-
56
- result = MangoPay::Deposit.get_all_for_card(card_registration['CardId'])
57
- expect(result).to be_kind_of(Array)
58
- expect(result.count).to be > 0
59
- end
60
-
61
- it 'fetches transactions for a deposit' do
62
- author = new_natural_user
63
- wallet = new_wallet
64
- card_registration = new_card_registration_completed
65
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
66
- create_new_payin_pre_authorized_deposit_direct(deposit['Id'], author['Id'], wallet['Id'])
67
-
68
- transactions = MangoPay::Deposit.get_transactions(deposit['Id'])
69
- expect(transactions).to be_kind_of(Array)
70
- expect(transactions.count).to be > 0
71
- end
72
- end
73
-
74
- # the Cancel flow will be teste manually for now
75
- =begin
76
- describe 'CANCEL' do
77
- it 'cancel an existing deposit' do
78
- author = new_natural_user
79
- card_registration = new_card_registration_completed
80
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
81
-
82
- assert_deposit(deposit, card_registration['CardId'], author["Id"])
83
- expect(deposit['Status']).to eq('CREATED')
84
- expect(deposit['PaymentStatus']).to eq('WAITING')
85
-
86
- MangoPay::Deposit.cancel(deposit['Id'])
87
-
88
- updated_deposit = MangoPay::Deposit.get(deposit['Id'])
89
-
90
- assert_deposit(updated_deposit, card_registration['CardId'], author["Id"])
91
- expect(updated_deposit['Status']).to eq('SUCCEEDED')
92
- expect(updated_deposit['PaymentStatus']).to eq('CANCELED')
93
- end
94
- end
95
- =end
96
- end
97
-
98
-
99
- def assert_deposit(deposit, card_reg_id, author_id)
100
- expect(deposit['Id']).not_to be_nil
101
- expect(deposit['CreationDate']).not_to be_nil
102
- expect(deposit['ExpirationDate']).not_to be_nil
103
- expect(deposit['AuthorId']).not_to be_nil
104
- expect(deposit['DebitedFunds']).not_to be_nil
105
- expect(deposit['Status']).not_to be_nil
106
- expect(deposit['PaymentStatus']).not_to be_nil
107
- expect(deposit['PayinsLinked']).not_to be_nil
108
- expect(deposit['CardId']).not_to be_nil
109
- expect(deposit['CardId']).to eq(card_reg_id)
110
- expect(deposit['AuthorId']).to eq(author_id)
111
- expect(deposit['SecureModeReturnURL']).not_to be_nil
112
- expect(deposit['PaymentType']).not_to be_nil
113
- expect(deposit['ExecutionType']).not_to be_nil
114
- expect(deposit['StatementDescriptor']).not_to be_nil
115
- expect(deposit['Culture']).not_to be_nil
116
- expect(deposit['BrowserInfo']).not_to be_nil
117
- expect(deposit['IpAddress']).not_to be_nil
118
- expect(deposit['Billing']).not_to be_nil
119
- expect(deposit['Shipping']).not_to be_nil
120
- end
Binary file