mangopay4-ruby-sdk 3.47.0 → 4.1.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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -0
  3. data/lib/mangopay/acquiring.rb +4 -0
  4. data/lib/mangopay/authorization_token.rb +1 -1
  5. data/lib/mangopay/deposit.rb +7 -0
  6. data/lib/mangopay/extended_preauthorization.rb +32 -0
  7. data/lib/mangopay/http_calls.rb +1 -1
  8. data/lib/mangopay/identity_verification.rb +6 -0
  9. data/lib/mangopay/legal_user.rb +3 -0
  10. data/lib/mangopay/natural_user.rb +3 -0
  11. data/lib/mangopay/pay_in.rb +72 -16
  12. data/lib/mangopay/report_v2.rb +2 -2
  13. data/lib/mangopay/version.rb +1 -1
  14. data/lib/mangopay.rb +3 -2
  15. data/mangopay.gemspec +7 -7
  16. metadata +33 -162
  17. data/.github/workflows/ruby_cd.yml +0 -34
  18. data/.github/workflows/ruby_ci.yml +0 -30
  19. data/.gitignore +0 -30
  20. data/.rspec +0 -3
  21. data/Gemfile +0 -2
  22. data/Rakefile +0 -5
  23. data/bin/mangopay +0 -9
  24. data/spec/mangopay/acquiring_spec.rb +0 -202
  25. data/spec/mangopay/authorization_token_spec.rb +0 -70
  26. data/spec/mangopay/bank_account_spec.rb +0 -105
  27. data/spec/mangopay/bankingaliases_spec.rb +0 -29
  28. data/spec/mangopay/card_registration_spec.rb +0 -123
  29. data/spec/mangopay/client_spec.png +0 -0
  30. data/spec/mangopay/client_spec.rb +0 -213
  31. data/spec/mangopay/configuration_spec.rb +0 -249
  32. data/spec/mangopay/conversion_spec.rb +0 -103
  33. data/spec/mangopay/deposit_spec.rb +0 -107
  34. data/spec/mangopay/dispute_spec.png +0 -0
  35. data/spec/mangopay/dispute_spec.rb +0 -294
  36. data/spec/mangopay/event_spec.rb +0 -33
  37. data/spec/mangopay/fetch_filters_spec.rb +0 -63
  38. data/spec/mangopay/hook_spec.rb +0 -37
  39. data/spec/mangopay/idempotency_spec.rb +0 -41
  40. data/spec/mangopay/identity_verification_spec.rb +0 -47
  41. data/spec/mangopay/kyc_document_spec.png +0 -0
  42. data/spec/mangopay/kyc_document_spec.rb +0 -118
  43. data/spec/mangopay/log_requests_filter_spec.rb +0 -26
  44. data/spec/mangopay/mandate_spec.rb +0 -99
  45. data/spec/mangopay/payin_applepay_direct_spec.rb +0 -21
  46. data/spec/mangopay/payin_bancontact_web_spec.rb +0 -30
  47. data/spec/mangopay/payin_bankwire_direct_spec.rb +0 -74
  48. data/spec/mangopay/payin_bankwire_external_instruction_spec.rb +0 -104
  49. data/spec/mangopay/payin_bizum_web_spec.rb +0 -54
  50. data/spec/mangopay/payin_blik_web_spec.rb +0 -41
  51. data/spec/mangopay/payin_card_direct_spec.rb +0 -69
  52. data/spec/mangopay/payin_card_web_spec.rb +0 -64
  53. data/spec/mangopay/payin_directdebit_direct_spec.rb +0 -37
  54. data/spec/mangopay/payin_directdebit_web_spec.rb +0 -38
  55. data/spec/mangopay/payin_giropay_web_spec.rb +0 -30
  56. data/spec/mangopay/payin_googlepay_direct_spec.rb +0 -21
  57. data/spec/mangopay/payin_ideal_web_spec.rb +0 -30
  58. data/spec/mangopay/payin_intent_spec.rb +0 -295
  59. data/spec/mangopay/payin_klarna_web_spec.rb +0 -32
  60. data/spec/mangopay/payin_mbway_web_spec.rb +0 -32
  61. data/spec/mangopay/payin_multibanco_web_spec.rb +0 -31
  62. data/spec/mangopay/payin_paybybank_web_spec.rb +0 -56
  63. data/spec/mangopay/payin_payconiq_web_spec.rb +0 -32
  64. data/spec/mangopay/payin_paypal_web_spec.rb +0 -113
  65. data/spec/mangopay/payin_preauthorized_direct_spec.rb +0 -118
  66. data/spec/mangopay/payin_satispay_web_spec.rb +0 -32
  67. data/spec/mangopay/payin_swish_web_spec.rb +0 -30
  68. data/spec/mangopay/payin_twint_web_spec.rb +0 -30
  69. data/spec/mangopay/payment_method_metadata_spec.rb +0 -15
  70. data/spec/mangopay/payout_bankwire_spec.rb +0 -93
  71. data/spec/mangopay/preauthorization_spec.rb +0 -51
  72. data/spec/mangopay/recipient_spec.rb +0 -134
  73. data/spec/mangopay/recurring_payin_spec.rb +0 -222
  74. data/spec/mangopay/refund_spec.rb +0 -34
  75. data/spec/mangopay/regulatory_spec.rb +0 -26
  76. data/spec/mangopay/report_spec.rb +0 -40
  77. data/spec/mangopay/report_v2_spec.rb +0 -117
  78. data/spec/mangopay/report_wallets_spec.rb +0 -40
  79. data/spec/mangopay/settlement_sample.csv +0 -8
  80. data/spec/mangopay/settlement_sample_bad.csv +0 -8
  81. data/spec/mangopay/settlement_spec.rb +0 -65
  82. data/spec/mangopay/shared_resources.rb +0 -1399
  83. data/spec/mangopay/transaction_spec.rb +0 -59
  84. data/spec/mangopay/transfer_spec.rb +0 -77
  85. data/spec/mangopay/ubo_declaration_spec.rb +0 -44
  86. data/spec/mangopay/ubo_spec.rb +0 -39
  87. data/spec/mangopay/user_spec.rb +0 -455
  88. data/spec/mangopay/virtual_account_spec.rb +0 -52
  89. data/spec/mangopay/wallet_spec.rb +0 -100
  90. data/spec/spec_helper.rb +0 -31
  91. data/spec/tmp/.keep +0 -0
@@ -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,107 +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
- end
14
-
15
- describe 'GET' do
16
- it 'get an existing deposit' do
17
- author = new_natural_user
18
- card_registration = new_card_registration_completed
19
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
20
-
21
- assert_deposit(deposit, card_registration['CardId'], author["Id"])
22
-
23
- fetched_deposit = MangoPay::Deposit.get(deposit['Id'])
24
-
25
- assert_deposit(fetched_deposit, card_registration['CardId'], author["Id"])
26
- end
27
-
28
- it 'gets all deposits for a user' do
29
- author = new_natural_user
30
- card_registration = new_card_registration_completed
31
- create_new_deposit(card_registration['CardId'], author['Id'])
32
-
33
- result = MangoPay::Deposit.get_all_for_user(author['Id'])
34
- expect(result).to be_kind_of(Array)
35
- expect(result.count).to be > 0
36
- end
37
-
38
- it 'gets all deposits for a card' do
39
- author = new_natural_user
40
- card_registration = new_card_registration_completed
41
- create_new_deposit(card_registration['CardId'], author['Id'])
42
-
43
- result = MangoPay::Deposit.get_all_for_card(card_registration['CardId'])
44
- expect(result).to be_kind_of(Array)
45
- expect(result.count).to be > 0
46
- end
47
-
48
- it 'fetches transactions for a deposit' do
49
- author = new_natural_user
50
- wallet = new_wallet
51
- card_registration = new_card_registration_completed
52
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
53
- create_new_payin_pre_authorized_deposit_direct(deposit['Id'], author['Id'], wallet['Id'])
54
-
55
- transactions = MangoPay::Deposit.get_transactions(deposit['Id'])
56
- expect(transactions).to be_kind_of(Array)
57
- expect(transactions.count).to be > 0
58
- end
59
- end
60
-
61
- # the Cancel flow will be teste manually for now
62
- =begin
63
- describe 'CANCEL' do
64
- it 'cancel an existing deposit' do
65
- author = new_natural_user
66
- card_registration = new_card_registration_completed
67
- deposit = create_new_deposit(card_registration['CardId'], author['Id'])
68
-
69
- assert_deposit(deposit, card_registration['CardId'], author["Id"])
70
- expect(deposit['Status']).to eq('CREATED')
71
- expect(deposit['PaymentStatus']).to eq('WAITING')
72
-
73
- MangoPay::Deposit.cancel(deposit['Id'])
74
-
75
- updated_deposit = MangoPay::Deposit.get(deposit['Id'])
76
-
77
- assert_deposit(updated_deposit, card_registration['CardId'], author["Id"])
78
- expect(updated_deposit['Status']).to eq('SUCCEEDED')
79
- expect(updated_deposit['PaymentStatus']).to eq('CANCELED')
80
- end
81
- end
82
- =end
83
- end
84
-
85
-
86
- def assert_deposit(deposit, card_reg_id, author_id)
87
- expect(deposit['Id']).not_to be_nil
88
- expect(deposit['CreationDate']).not_to be_nil
89
- expect(deposit['ExpirationDate']).not_to be_nil
90
- expect(deposit['AuthorId']).not_to be_nil
91
- expect(deposit['DebitedFunds']).not_to be_nil
92
- expect(deposit['Status']).not_to be_nil
93
- expect(deposit['PaymentStatus']).not_to be_nil
94
- expect(deposit['PayinsLinked']).not_to be_nil
95
- expect(deposit['CardId']).not_to be_nil
96
- expect(deposit['CardId']).to eq(card_reg_id)
97
- expect(deposit['AuthorId']).to eq(author_id)
98
- expect(deposit['SecureModeReturnURL']).not_to be_nil
99
- expect(deposit['PaymentType']).not_to be_nil
100
- expect(deposit['ExecutionType']).not_to be_nil
101
- expect(deposit['StatementDescriptor']).not_to be_nil
102
- expect(deposit['Culture']).not_to be_nil
103
- expect(deposit['BrowserInfo']).not_to be_nil
104
- expect(deposit['IpAddress']).not_to be_nil
105
- expect(deposit['Billing']).not_to be_nil
106
- expect(deposit['Shipping']).not_to be_nil
107
- end
Binary file