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,1380 @@
1
+ ###############################################
2
+ shared_context 'users' do
3
+ ###############################################
4
+
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 }
10
+
11
+ def define_new_natural_user
12
+ {
13
+ Tag: 'Test natural user',
14
+ Email: 'my@email.com',
15
+ FirstName: 'John',
16
+ LastName: 'Doe',
17
+ Address: {
18
+ AddressLine1: 'Le Palais Royal',
19
+ AddressLine2: '8 Rue de Montpensier',
20
+ City: 'Paris',
21
+ Region: '',
22
+ PostalCode: '75001',
23
+ Country: 'FR'
24
+ },
25
+ Birthday: 1_300_186_358,
26
+ Birthplace: 'Paris',
27
+ Nationality: 'FR',
28
+ CountryOfResidence: 'FR',
29
+ Occupation: 'Worker',
30
+ IncomeRange: 1,
31
+ TermsAndConditionsAccepted: true
32
+ }
33
+ end
34
+
35
+ def define_new_natural_user_sca_payer
36
+ {
37
+ "UserCategory": "PAYER",
38
+ "TermsAndConditionsAccepted": true,
39
+ "FirstName": "Alex",
40
+ "LastName": "Smith",
41
+ "Email": "alex.smith@example.com",
42
+ "Address": {
43
+ "AddressLine1": "3 rue de la Cité",
44
+ "AddressLine2": "Appartement 7",
45
+ "City": "Paris",
46
+ "Region": "Île-de-France",
47
+ "PostalCode": "75004",
48
+ "Country": "FR"
49
+ },
50
+ "Tag": "Created using the Mangopay API Postman collection",
51
+ "PhoneNumber": "0611111111",
52
+ "PhoneNumberCountry": "FR"
53
+ }
54
+ end
55
+
56
+ def define_new_natural_user_sca_owner
57
+ {
58
+ "UserCategory": "OWNER",
59
+ "TermsAndConditionsAccepted": true,
60
+ "FirstName": "Alex",
61
+ "LastName": "Smith",
62
+ "Email": "alex.smith@example.com",
63
+ "Address": {
64
+ "AddressLine1": "3 rue de la Cité",
65
+ "AddressLine2": "Appartement 7",
66
+ "City": "Paris",
67
+ "Region": "Île-de-France",
68
+ "PostalCode": "75004",
69
+ "Country": "FR"
70
+ },
71
+ "Birthday": 652117514,
72
+ "CountryOfResidence": "FR",
73
+ "Nationality": "FR",
74
+ "Tag": "Created using the Mangopay API Postman collection",
75
+ "PhoneNumber": "0611111111",
76
+ "PhoneNumberCountry": "FR"
77
+ }
78
+ end
79
+
80
+ def define_new_legal_user_sca_payer
81
+ {
82
+ "UserCategory": "PAYER",
83
+ "TermsAndConditionsAccepted": true,
84
+ "LegalPersonType": "SOLETRADER",
85
+ "Name": "Alex Smith",
86
+ "Email": "alex.smith.services@example.com",
87
+ "LegalRepresentative": {
88
+ "FirstName": "Alex",
89
+ "LastName": "Smith",
90
+ "Birthday": 652117514,
91
+ "Nationality": "FR",
92
+ "CountryOfResidence": "FR",
93
+ "Email": "alex.smith@example.com",
94
+ "PhoneNumber": "0611111111",
95
+ "PhoneNumberCountry": "FR"
96
+ },
97
+ "LegalRepresentativeAddress": {
98
+ "AddressLine1": "3 rue de la Cité",
99
+ "AddressLine2": "Appartement 7",
100
+ "City": "Paris",
101
+ "Region": "Île-de-France",
102
+ "PostalCode": "75004",
103
+ "Country": "FR"
104
+ },
105
+ "Tag": "Created using the Mangopay API Postman collection"
106
+ }
107
+ end
108
+
109
+ def define_new_legal_user_sca_owner
110
+ {
111
+ "UserCategory": "OWNER",
112
+ "TermsAndConditionsAccepted": true,
113
+ "LegalPersonType": "SOLETRADER",
114
+ "Name": "Alex Smith",
115
+ "Email": "alex.smith.services@example.com",
116
+ "LegalRepresentative": {
117
+ "FirstName": "Alex",
118
+ "LastName": "Smith",
119
+ "Birthday": 652117514,
120
+ "Nationality": "FR",
121
+ "CountryOfResidence": "FR",
122
+ "Email": "alex.smith@example.com",
123
+ "PhoneNumber": "0611111111",
124
+ "PhoneNumberCountry": "FR"
125
+ },
126
+ "CompanyNumber": "123456789",
127
+ "HeadquartersAddress": {
128
+ "AddressLine1": "3 rue de la Cité",
129
+ "AddressLine2": "Appartement 7",
130
+ "City": "Paris",
131
+ "Region": "Île-de-France",
132
+ "PostalCode": "75004",
133
+ "Country": "FR"
134
+ },
135
+ "LegalRepresentativeAddress": {
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
+ "Tag": "Created using the Mangopay API Postman collection"
144
+ }
145
+ end
146
+
147
+ def create_new_natural_user
148
+ MangoPay::NaturalUser.create(define_new_natural_user)
149
+ end
150
+
151
+ def create_new_natural_user_sca_payer
152
+ MangoPay::NaturalUserSca.create(define_new_natural_user_sca_payer)
153
+ end
154
+
155
+ def create_new_natural_user_sca_owner
156
+ MangoPay::NaturalUserSca.create(define_new_natural_user_sca_owner)
157
+ end
158
+
159
+ def create_new_legal_user_sca_payer
160
+ MangoPay::LegalUserSca.create(define_new_legal_user_sca_payer)
161
+ end
162
+
163
+ def create_new_legal_user_sca_owner
164
+ MangoPay::LegalUserSca.create(define_new_legal_user_sca_owner)
165
+ end
166
+
167
+ let(:new_legal_user) do
168
+ MangoPay::LegalUser.create(
169
+ Name: 'Super',
170
+ Email: 'super@email.com',
171
+ LegalPersonType: 'BUSINESS',
172
+ HeadquartersAddress: {
173
+ AddressLine1: '6 Parvis Notre-Dame',
174
+ AddressLine2: 'Pl. Jean-Paul II',
175
+ City: 'Paris',
176
+ Region: 'FR',
177
+ PostalCode: '75004',
178
+ Country: 'FR'
179
+ },
180
+ LegalRepresentativeFirstName: 'John',
181
+ LegalRepresentativeLastName: 'Doe',
182
+ LegalRepresentativeAdress: {
183
+ AddressLine1: '38 Rue de Montpensier',
184
+ AddressLine2: '',
185
+ City: 'Paris',
186
+ Region: '',
187
+ PostalCode: '75001',
188
+ Country: 'FR'
189
+ },
190
+ LegalRepresentativeEmail: 'john@doe.com',
191
+ LegalRepresentativeBirthday: 1_300_186_358,
192
+ LegalRepresentativeNationality: 'FR',
193
+ LegalRepresentativeCountryOfResidence: 'FR',
194
+ CompanyNumber: 'LU123456789',
195
+ Statute: '',
196
+ ProofOfRegistration: '',
197
+ ShareholderDeclaration: '',
198
+ TermsAndConditionsAccepted: true
199
+ )
200
+ end
201
+ end
202
+
203
+ ###############################################
204
+ shared_context 'wallets' do
205
+ ###############################################
206
+ include_context 'users'
207
+
208
+ let(:new_wallet) { create_new_wallet(new_natural_user) }
209
+ let(:new_wallet_legal) { create_new_wallet(new_legal_user) }
210
+
211
+ def create_new_wallet(user)
212
+ MangoPay::Wallet.create(
213
+ Owners: [user['Id']],
214
+ Description: 'A test wallet',
215
+ Currency: 'EUR',
216
+ Tag: 'Test wallet'
217
+ )
218
+ end
219
+
220
+ def create_new_custom_wallet(user, currency)
221
+ MangoPay::Wallet.create(
222
+ Owners: [user['Id']],
223
+ Description: 'A test wallet',
224
+ Currency: currency,
225
+ Tag: 'Test wallet'
226
+ )
227
+ end
228
+
229
+ def wallets_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
230
+ expect(wlt1['Balance']['Amount']).to eq amnt1
231
+ expect(wlt2['Balance']['Amount']).to eq amnt2 if wlt2
232
+ end
233
+
234
+ def wallets_reload_and_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
235
+ wlt1 = MangoPay::Wallet.fetch(wlt1['Id'])
236
+ wlt2 = MangoPay::Wallet.fetch(wlt2['Id']) if wlt2
237
+ wallets_check_amounts(wlt1, amnt1, wlt2, amnt2)
238
+ end
239
+ end
240
+
241
+ shared_context 'ubo' do
242
+ def new_ubo(user, ubo_declaration)
243
+ ubo = {
244
+ FirstName: 'John',
245
+ LastName: 'Doe',
246
+ Address: {
247
+ AddressLine1: '6 Parvis Notre-Dame',
248
+ AddressLine2: 'Pl. Jean-Paul II',
249
+ City: 'Paris',
250
+ Region: '',
251
+ PostalCode: '75004',
252
+ Country: 'FR'
253
+ },
254
+ Nationality: 'FR',
255
+ Birthday: 1_300_186_358,
256
+ Birthplace: {
257
+ City: 'Paris',
258
+ Country: 'FR'
259
+ }
260
+ }
261
+ MangoPay::Ubo.create(user['Id'], ubo_declaration['Id'], ubo)
262
+ end
263
+ end
264
+
265
+ ###############################################
266
+ shared_context 'bank_accounts' do
267
+ ###############################################
268
+ include_context 'users'
269
+
270
+ let(:new_bank_account) do
271
+ MangoPay::BankAccount.create(new_natural_user['Id'],
272
+ Type: 'IBAN',
273
+ OwnerName: 'John',
274
+ OwnerAddress: {
275
+ AddressLine1: 'Le Palais Royal',
276
+ AddressLine2: '8 Rue de Montpensier',
277
+ City: 'Paris',
278
+ Region: '',
279
+ PostalCode: '75001',
280
+ Country: 'FR'
281
+ },
282
+ IBAN: 'FR7630004000031234567890143',
283
+ BIC: 'BNPAFRPP',
284
+ Tag: 'Test bank account')
285
+ end
286
+ end
287
+
288
+ ###############################################
289
+ shared_context 'mandates' do
290
+ ###############################################
291
+ include_context 'bank_accounts'
292
+
293
+ let(:new_mandate) { create_new_mandate }
294
+
295
+ def create_new_mandate
296
+ MangoPay::Mandate.create(
297
+ BankAccountId: new_bank_account['Id'],
298
+ Culture: 'FR',
299
+ ReturnURL: MangoPay.configuration.root_url,
300
+ Tag: 'Test mandate'
301
+ )
302
+ end
303
+ end
304
+
305
+ ###############################################
306
+ shared_context 'kyc_documents' do
307
+ ###############################################
308
+ include_context 'users'
309
+
310
+ let(:new_document) { create_new_document(new_natural_user) }
311
+
312
+ def create_new_document(user)
313
+ MangoPay::KycDocument.create(user['Id'],
314
+ Type: 'IDENTITY_PROOF',
315
+ Tag: 'Test document')
316
+ end
317
+ end
318
+
319
+ ###############################################
320
+ shared_context 'payins' do
321
+ ###############################################
322
+ include_context 'users'
323
+ include_context 'wallets'
324
+ include_context 'mandates'
325
+
326
+ ###############################################
327
+ # directdebit/web
328
+ ###############################################
329
+
330
+ let(:new_payin_directdebit_web) do
331
+ MangoPay::PayIn::DirectDebit::Web.create(
332
+ AuthorId: new_natural_user['Id'],
333
+ CreditedUserId: new_wallet['Owners'][0],
334
+ CreditedWalletId: new_wallet['Id'],
335
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
336
+ Fees: { Currency: 'EUR', Amount: 0 },
337
+ DirectDebitType: 'GIROPAY',
338
+ ReturnURL: MangoPay.configuration.root_url,
339
+ Culture: 'FR',
340
+ Tag: 'Test PayIn/DirectDebit/Web'
341
+ )
342
+ end
343
+
344
+ ###############################################
345
+ # paypal/web
346
+ ###############################################
347
+
348
+ let(:new_payin_paypal_web) do
349
+ MangoPay::PayIn::PayPal::Web.create(
350
+ AuthorId: new_natural_user['Id'],
351
+ CreditedUserId: new_wallet['Owners'][0],
352
+ CreditedWalletId: new_wallet['Id'],
353
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
354
+ Fees: { Currency: 'EUR', Amount: 0 },
355
+ ReturnURL: MangoPay.configuration.root_url,
356
+ Culture: "FR",
357
+ Tag: 'Test PayIn/PayPal/Web'
358
+ )
359
+ end
360
+
361
+ ###############################################
362
+ # payconiq/web
363
+ ###############################################
364
+
365
+ let(:new_payin_payconiq_web) do
366
+ MangoPay::PayIn::Payconiq::Web.create(
367
+ AuthorId: new_natural_user['Id'],
368
+ CreditedWalletId: new_wallet['Id'],
369
+ DebitedFunds: { Currency: 'EUR', Amount: 100 },
370
+ Fees: { Currency: 'EUR', Amount: 0 },
371
+ ReturnURL: MangoPay.configuration.root_url,
372
+ Country: "BE",
373
+ Tag: 'Custom Meta'
374
+ )
375
+ end
376
+
377
+ let(:new_payin_payconiq_web_legacy) do
378
+ MangoPay::PayIn::Payconiq::Web.create_legacy(
379
+ AuthorId: new_natural_user['Id'],
380
+ CreditedWalletId: new_wallet['Id'],
381
+ DebitedFunds: { Currency: 'EUR', Amount: 100 },
382
+ Fees: { Currency: 'EUR', Amount: 0 },
383
+ ReturnURL: MangoPay.configuration.root_url,
384
+ Country: "BE",
385
+ Tag: 'Custom Meta'
386
+ )
387
+ end
388
+
389
+ ###############################################
390
+ # applepay/direct
391
+ ###############################################
392
+
393
+ let(:new_payin_applepay_direct) do
394
+ MangoPay::PayIn::ApplePay::Direct.create(
395
+ AuthorId: new_natural_user['Id'],
396
+ CreditedUserId: new_wallet['Owners'][0],
397
+ CreditedWalletId: new_wallet['Id'],
398
+ DebitedFunds: { Currency: 'EUR', Amount: 199 },
399
+ Fees: { Currency: 'EUR', Amount: 1 },
400
+ PaymentType: 'APPLEPAY',
401
+ PaymentData: {
402
+ TransactionId: '061EB32181A2D9CA42AD16031B476EEBAA62A9A095AD660E2759FBA52B51A61',
403
+ Network: 'VISA',
404
+ TokenData: "{\"version\":\"EC_v1\",\"data\":\"w4HMBVqNC9ghPP4zncTA\\/0oQAsduERfsx78oxgniynNjZLANTL6+0koEtkQnW\\/K38Zew8qV1GLp+fLHo+qCBpiKCIwlz3eoFBTbZU+8pYcjaeIYBX9SOxcwxXsNGrGLk+kBUqnpiSIPaAG1E+WPT8R1kjOCnGvtdombvricwRTQkGjtovPfzZo8LzD3ZQJnHMsWJ8QYDLyr\\/ZN9gtLAtsBAMvwManwiaG3pOIWpyeOQOb01YcEVO16EZBjaY4x4C\\/oyFLWDuKGvhbJwZqWh1d1o9JT29QVmvy3Oq2JEjq3c3NutYut4rwDEP4owqI40Nb7mP2ebmdNgnYyWfPmkRfDCRHIWtbMC35IPg5313B1dgXZ2BmyZRXD5p+mr67vAk7iFfjEpu3GieFqwZrTl3\\/pI5V8Sxe3SIYKgT5Hr7ow==\",\"signature\":\"MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCAMIID5jCCA4ugAwIBAgIIaGD2mdnMpw8wCgYIKoZIzj0EAwIwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMB4XDTE2MDYwMzE4MTY0MFoXDTIxMDYwMjE4MTY0MFowYjEoMCYGA1UEAwwfZWNjLXNtcC1icm9rZXItc2lnbl9VQzQtU0FOREJPWDEUMBIGA1UECwwLaU9TIFN5c3RlbXMxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgjD9q8Oc914gLFDZm0US5jfiqQHdbLPgsc1LUmeY+M9OvegaJajCHkwz3c6OKpbC9q+hkwNFxOh6RCbOlRsSlaOCAhEwggINMEUGCCsGAQUFBwEBBDkwNzA1BggrBgEFBQcwAYYpaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZWFpY2EzMDIwHQYDVR0OBBYEFAIkMAua7u1GMZekplopnkJxghxFMAwGA1UdEwEB\\/wQCMAAwHwYDVR0jBBgwFoAUI\\/JJxE+T5O8n5sT2KGw\\/orv9LkswggEdBgNVHSAEggEUMIIBEDCCAQwGCSqGSIb3Y2QFATCB\\/jCBwwYIKwYBBQUHAgIwgbYMgbNSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRlIHBvbGljeSBhbmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1lbnRzLjA2BggrBgEFBQcCARYqaHR0cDovL3d3dy5hcHBsZS5jb20vY2VydGlmaWNhdGVhdXRob3JpdHkvMDQGA1UdHwQtMCswKaAnoCWGI2h0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlYWljYTMuY3JsMA4GA1UdDwEB\\/wQEAwIHgDAPBgkqhkiG92NkBh0EAgUAMAoGCCqGSM49BAMCA0kAMEYCIQDaHGOui+X2T44R6GVpN7m2nEcr6T6sMjOhZ5NuSo1egwIhAL1a+\\/hp88DKJ0sv3eT3FxWcs71xmbLKD\\/QJ3mWagrJNMIIC7jCCAnWgAwIBAgIISW0vvzqY2pcwCgYIKoZIzj0EAwIwZzEbMBkGA1UEAwwSQXBwbGUgUm9vdCBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwHhcNMTQwNTA2MjM0NjMwWhcNMjkwNTA2MjM0NjMwWjB6MS4wLAYDVQQDDCVBcHBsZSBBcHBsaWNhdGlvbiBJbnRlZ3JhdGlvbiBDQSAtIEczMSYwJAYDVQQLDB1BcHBsZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTETMBEGA1UECgwKQXBwbGUgSW5jLjELMAkGA1UEBhMCVVMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATwFxGEGddkhdUaXiWBB3bogKLv3nuuTeCN\\/EuT4TNW1WZbNa4i0Jd2DSJOe7oI\\/XYXzojLdrtmcL7I6CmE\\/1RFo4H3MIH0MEYGCCsGAQUFBwEBBDowODA2BggrBgEFBQcwAYYqaHR0cDovL29jc3AuYXBwbGUuY29tL29jc3AwNC1hcHBsZXJvb3RjYWczMB0GA1UdDgQWBBQj8knET5Pk7yfmxPYobD+iu\\/0uSzAPBgNVHRMBAf8EBTADAQH\\/MB8GA1UdIwQYMBaAFLuw3qFYM4iapIqZ3r6966\\/ayySrMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly9jcmwuYXBwbGUuY29tL2FwcGxlcm9vdGNhZzMuY3JsMA4GA1UdDwEB\\/wQEAwIBBjAQBgoqhkiG92NkBgIOBAIFADAKBggqhkjOPQQDAgNnADBkAjA6z3KDURaZsYb7NcNWymK\\/9Bft2Q91TaKOvvGcgV5Ct4n4mPebWZ+Y1UENj53pwv4CMDIt1UQhsKMFd2xd8zg7kGf9F3wsIW2WT8ZyaYISb1T4en0bmcubCYkhYQaZDwmSHQAAMYIBizCCAYcCAQEwgYYwejEuMCwGA1UEAwwlQXBwbGUgQXBwbGljYXRpb24gSW50ZWdyYXRpb24gQ0EgLSBHMzEmMCQGA1UECwwdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxEzARBgNVBAoMCkFwcGxlIEluYy4xCzAJBgNVBAYTAlVTAghoYPaZ2cynDzANBglghkgBZQMEAgEFAKCBlTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xOTA1MjMxMTA1MDdaMCoGCSqGSIb3DQEJNDEdMBswDQYJYIZIAWUDBAIBBQChCgYIKoZIzj0EAwIwLwYJKoZIhvcNAQkEMSIEIIvfGVQYBeOilcB7GNI8m8+FBVZ28QfA6BIXaggBja2PMAoGCCqGSM49BAMCBEYwRAIgU01yYfjlx9bvGeC5CU2RS5KBEG+15HH9tz\\/sg3qmQ14CID4F4ZJwAz+tXAUcAIzoMpYSnM8YBlnGJSTSp+LhspenAAAAAAAA\",\"header\":{\"ephemeralPublicKey\":\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0rs3wRpirXjPbFDQfPRdfEzRIZDWm0qn7Y0HB0PNzV1DDKfpYrnhRb4GEhBF\\/oEXBOe452PxbCnN1qAlqcSUWw==\",\"publicKeyHash\":\"saPRAqS7TZ4bAYwzBj8ezDDC55ZolyH1FL+Xc8fd93o=\",\"transactionId\":\"b061eb32181a2d9ca42ad16031b476eebaa62a9a095ad660e2759fba52b51a61\"}}"
405
+ },
406
+ StatementDescriptor: "php",
407
+ ReturnURL: MangoPay.configuration.root_url,
408
+ Tag: 'Test PayIn/ApplePay/Direct'
409
+ )
410
+ end
411
+
412
+ ###############################################
413
+ # CANNOT BE TESTED AS WE CAN'T MOCK TOKEN GENERATION
414
+ # googlepay/direct
415
+ ###############################################
416
+ let(:new_payin_googlepay_direct) do
417
+ MangoPay::PayIn::GooglePay::Direct.create(
418
+ AuthorId: new_natural_user['Id'],
419
+ CreditedWalletId: new_wallet['Id'],
420
+ DebitedFunds: { Currency: 'EUR', Amount: 199 },
421
+ Fees: { Currency: 'EUR', Amount: 1 },
422
+ StatementDescriptor: "ruby",
423
+ Tag: 'Test PayIn/GooglePay/Direct',
424
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
425
+ SecureModeReturnURL: 'http://test.com',
426
+ SecureMode: 'DEFAULT',
427
+ ReturnURL: 'https://mangopay.com/docs/please-ignore',
428
+ BrowserInfo: {
429
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
430
+ JavaEnabled: true,
431
+ Language: "fr-FR",
432
+ ColorDepth: 4,
433
+ ScreenHeight: 1800,
434
+ ScreenWidth: 400,
435
+ JavascriptEnabled: true,
436
+ TimeZoneOffset: "+60",
437
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
438
+ },
439
+ PaymentData: "{\"signature\":\"MEUCIQCLXOan2Y9DobLVSOeD5V64Peayvz0ZAWisdz/1iTdthAIgVFb4Hve4EhtW81k46SiMlnXLIiCn1h2+vVQGjHe+sSo\\u003d\",\"intermediateSigningKey\":{\"signedKey\":\"{\\\"keyValue\\\":\\\"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEDGRER6R6PH6K39YTIYX+CpDNej6gQgvi/Wx19SOPtiDnkjAl4/LF9pXlvZYe+aJH0Dy095I6BlfY8bNBB5gjPg\\\\u003d\\\\u003d\\\",\\\"keyExpiration\\\":\\\"1688521049102\\\"}\",\"signatures\":[\"MEYCIQDup1B+rkiPAWmpg7RmqY0NfgdGhmdyL8wvAX+6C1aOU2QIhAIZACSDQ/ZexIyEia5KrRlG2B+y3AnKNlhRzumRcnNOR\"]},\"protocolVersion\":\"ECv2\",\"signedMessage\":\"{\\\"encryptedMessage\\\":\\\"YSSGK9yFdKP+mJB5+wAjnOujnThPM1E/KbbJxd3MDzPVI66ip1DBESldvQXYjjeLq6Rf1tKE9oLwwaj6u0/gU7Z9t3g1MoW+9YoEE1bs1IxImif7IQGAosfYjjbBBfDkOaqEs2JJC5qt6xjKO9lQ/E6JPkPFGqF7+OJ1vzmD83Pi3sHWkVge5MhxXQ3yBNhrjus3kV7zUoYA+uqNrciWcWypc1NndF/tiwSkvUTzM6n4dS8X84fkJiSO7PZ65C0yw0mdybRRnyL2fFdWGssve1zZFAvYfzcpNamyuZGGlu/SCoayitojmMsqe5Cu0efD9+WvvDr9PA+Vo1gzuz7LmiZe81SGvdFhRoq62FBAUiwSsi2A3pWinZxM2XbYNph+HJ5FCNspWhz4ur9JG4ZMLemCXuaybvL++W6PWywAtoiE0mQcBIX3vhOq5itv0RkaKVe6nbcAS2UryRz2u/nDCJLKpIv2Wi11NtCUT2mgD8F6qfcXhvVZHyeLqZ1OLgCudTTSdKirzezbgPTg4tQpW++KufeD7bgG+01XhCWt+7/ftqcSf8n//gSRINne8j2G6w+2\\\",\\\"ephemeralPublicKey\\\":\\\"BLY2+R8C0T+BSf/W3HEq305qH63IGmJxMVmbfJ6+x1V7GQg9W9v7eHc3j+8TeypVn+nRlPu98tivuMXECg+rWZs\\\\u003d\\\",\\\"tag\\\":\\\"MmEjNdLfsDNfYd/FRUjoJ4/IfLypNRqx8zgHfa6Ftmo\\\\u003d\\\"}\"}",
440
+ Billing: {
441
+ FirstName: 'FName',
442
+ LastName: 'LName',
443
+ Address: {
444
+ AddressLine1: 'AddressLine1',
445
+ AddressLine2: 'AddressLine2',
446
+ City: 'City',
447
+ Region: 'Region',
448
+ PostalCode: 'PostalCode',
449
+ Country: 'FR'
450
+ }
451
+ },
452
+ Shipping: {
453
+ FirstName: 'FName',
454
+ LastName: 'LName',
455
+ Address: {
456
+ AddressLine1: 'AddressLine1',
457
+ AddressLine2: 'AddressLine2',
458
+ City: 'City',
459
+ Region: 'Region',
460
+ PostalCode: 'PostalCode',
461
+ Country: 'FR'
462
+ }
463
+ }
464
+ )
465
+ end
466
+
467
+ ###############################################
468
+ # directdebit/direct
469
+ ###############################################
470
+
471
+ let(:new_payin_directdebit_direct) do
472
+ MangoPay::PayIn::DirectDebit::Direct.create(
473
+ AuthorId: new_natural_user['Id'],
474
+ CreditedUserId: new_wallet['Owners'][0],
475
+ CreditedWalletId: new_wallet['Id'],
476
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
477
+ Fees: { Currency: 'EUR', Amount: 0 },
478
+ MandateId: new_mandate['Id'],
479
+ ReturnURL: MangoPay.configuration.root_url,
480
+ Tag: 'Test PayIn/DirectDebit/Direct'
481
+ )
482
+ end
483
+
484
+ ###############################################
485
+ # card/web
486
+ ###############################################
487
+
488
+ let(:new_payin_card_web) do
489
+ MangoPay::PayIn::Card::Web.create(
490
+ AuthorId: new_natural_user['Id'],
491
+ CreditedUserId: new_wallet['Owners'][0],
492
+ CreditedWalletId: new_wallet['Id'],
493
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
494
+ Fees: { Currency: 'EUR', Amount: 0 },
495
+ CardType: 'CB_VISA_MASTERCARD',
496
+ ReturnURL: MangoPay.configuration.root_url,
497
+ Culture: 'FR',
498
+ Tag: 'Test PayIn/Card/Web'
499
+ )
500
+ end
501
+
502
+ let(:new_payin_card_web_payline) do
503
+ MangoPay::PayIn::Card::Web.create(
504
+ AuthorId: new_natural_user['Id'],
505
+ CreditedUserId: new_wallet['Owners'][0],
506
+ CreditedWalletId: new_wallet['Id'],
507
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
508
+ Fees: { Currency: 'EUR', Amount: 0 },
509
+ CardType: 'CB_VISA_MASTERCARD',
510
+ ReturnURL: MangoPay.configuration.root_url,
511
+ Culture: 'FR',
512
+ Tag: 'Test PayIn/Card/Web',
513
+ TemplateURLOptions: { PAYLINEV2: "https://www.maysite.com/payline_template/" }
514
+ )
515
+ end
516
+
517
+ ###############################################
518
+ # card/direct
519
+ ###############################################
520
+
521
+ let(:new_card_registration) do
522
+ MangoPay::CardRegistration.create(
523
+ UserId: new_natural_user['Id'],
524
+ Currency: 'EUR',
525
+ Tag: 'Test Card Registration'
526
+ )
527
+ end
528
+
529
+ let(:new_card_registration_completed) do
530
+ # 1st step: create
531
+ cardreg = new_card_registration
532
+
533
+ # 2nd step: tokenize by payline (fills-in RegistrationData)
534
+ data = {
535
+ data: cardreg['PreregistrationData'],
536
+ accessKeyRef: cardreg['AccessKey'],
537
+ cardNumber: 4970107111111119,
538
+ cardExpirationDate: 1229,
539
+ cardCvx: 123 }
540
+
541
+ res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
542
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
543
+
544
+ cardreg['RegistrationData'] = res.body
545
+
546
+ # 3rd step: update (fills-in CardId) and return it
547
+ MangoPay::CardRegistration.update(cardreg['Id'],
548
+ RegistrationData: cardreg['RegistrationData'])
549
+ end
550
+
551
+ let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
552
+
553
+ ###############################################
554
+ # MBWAY/web
555
+ ###############################################
556
+ let(:new_payin_mbway_web) do
557
+ MangoPay::PayIn::Mbway::Web.create(
558
+ AuthorId: new_natural_user['Id'],
559
+ CreditedWalletId: new_wallet['Id'],
560
+ DebitedFunds: { Currency: 'EUR', Amount: 199 },
561
+ Fees: { Currency: 'EUR', Amount: 1 },
562
+ StatementDescriptor: "ruby",
563
+ Tag: 'Test PayIn/Mbway/Web',
564
+ Phone: '351#269458236'
565
+ )
566
+ end
567
+
568
+ ###############################################
569
+ # MULTIBANCO/web
570
+ ###############################################
571
+ let(:new_payin_multibanco_web) do
572
+ MangoPay::PayIn::Multibanco::Web.create(
573
+ AuthorId: new_natural_user['Id'],
574
+ DebitedFunds: { Currency: 'EUR', Amount: 199 },
575
+ Fees: { Currency: 'EUR', Amount: 1 },
576
+ CreditedWalletId: new_wallet['Id'],
577
+ StatementDescriptor: "ruby",
578
+ Tag: 'Test PayIn/Multibanco/Web',
579
+ ReturnURL: 'http://www.my-site.com/returnURL'
580
+ )
581
+ end
582
+
583
+ ###############################################
584
+ # BLIK/web
585
+ ###############################################
586
+ let(:new_payin_blik_web) do
587
+ user = new_natural_user
588
+ wallet = MangoPay::Wallet.create(
589
+ Owners: [user['Id']],
590
+ Description: 'A test wallet',
591
+ Currency: 'PLN',
592
+ Tag: 'Test wallet'
593
+ )
594
+ MangoPay::PayIn::Blik::Web.create(define_new_blik(user, wallet))
595
+ end
596
+
597
+ let(:new_payin_blik_web_with_code) do
598
+ user = new_natural_user
599
+ wallet = MangoPay::Wallet.create(
600
+ Owners: [user['Id']],
601
+ Description: 'A test wallet',
602
+ Currency: 'PLN',
603
+ Tag: 'Test wallet'
604
+ )
605
+ blik = define_new_blik(user, wallet)
606
+ blik['Code'] = '777365'
607
+ blik['IpAddress'] = '159.180.248.187'
608
+ blik['BrowserInfo'] = {
609
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
610
+ JavaEnabled: true,
611
+ Language: "FR-FR",
612
+ ColorDepth: 4,
613
+ ScreenHeight: 1800,
614
+ ScreenWidth: 400,
615
+ JavascriptEnabled: true,
616
+ TimeZoneOffset: "+60",
617
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
618
+ }
619
+ MangoPay::PayIn::Blik::Web.create(blik)
620
+ end
621
+
622
+ def define_new_blik(user, wallet)
623
+ {
624
+ AuthorId: user['Id'],
625
+ CreditedWalletId: wallet['Id'],
626
+ DebitedFunds: { Currency: 'PLN', Amount: 199 },
627
+ Fees: { Currency: 'PLN', Amount: 1 },
628
+ StatementDescriptor: "ruby",
629
+ Tag: 'Test PayIn/Blik/Web',
630
+ ReturnURL: 'https://example.com'
631
+ }
632
+ end
633
+
634
+ ###############################################
635
+ # SATISPAY/web
636
+ ###############################################
637
+ let(:new_payin_satispay_web) do
638
+ MangoPay::PayIn::Satispay::Web.create(
639
+ AuthorId: new_natural_user['Id'],
640
+ CreditedWalletId: new_wallet['Id'],
641
+ DebitedFunds: { Currency: 'EUR', Amount: 199 },
642
+ Fees: { Currency: 'EUR', Amount: 1 },
643
+ StatementDescriptor: "ruby",
644
+ Tag: 'Test PayIn/Mbway/Web',
645
+ Country: 'IT',
646
+ ReturnURL: 'http://www.my-site.com/returnURL'
647
+ )
648
+ end
649
+
650
+ ###############################################
651
+ # KLARNA/web
652
+ ###############################################
653
+ let(:new_payin_klarna_web) do
654
+ MangoPay::PayIn::Klarna::Web.create(
655
+ AuthorId: new_natural_user['Id'],
656
+ CreditedWalletId: new_wallet['Id'],
657
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
658
+ Fees: { Currency: 'EUR', Amount: 10 },
659
+ ReturnURL: 'http://www.my-site.com/returnURL',
660
+ LineItems: [
661
+ {
662
+ Name: "running shoes",
663
+ Quantity: 1,
664
+ UnitAmount: 200,
665
+ TaxAmount: 0,
666
+ Description: "seller1 ID"
667
+ },
668
+ {
669
+ Name: "running shoes",
670
+ Quantity: 1,
671
+ UnitAmount: 200,
672
+ TaxAmount: 0,
673
+ Description: "seller2 ID"
674
+ }
675
+ ],
676
+ Country: 'FR',
677
+ Culture: 'FR',
678
+ Phone: '33#607080900',
679
+ Email: 'mango@mangopay.com',
680
+ AdditionalData: '{}',
681
+ Billing: {
682
+ Address: {
683
+ AddressLine1: 'AddressLine1',
684
+ AddressLine2: 'AddressLine2',
685
+ City: 'City',
686
+ Region: 'Region',
687
+ PostalCode: 'PostalCode',
688
+ Country: 'FR'
689
+ },
690
+ FirstName: 'Joe',
691
+ LastName: 'Blogs'
692
+ },
693
+ Shipping: {
694
+ Address: {
695
+ AddressLine1: 'AddressLine1',
696
+ AddressLine2: 'AddressLine2',
697
+ City: 'City',
698
+ Region: 'Region',
699
+ PostalCode: 'PostalCode',
700
+ Country: 'FR'
701
+ },
702
+ FirstName: 'Joe',
703
+ LastName: 'Blogs'
704
+ },
705
+ Reference: 'afd48-879d-48fg',
706
+ Tag: 'Test PayIn/Klarna/Web'
707
+ )
708
+ end
709
+
710
+ ###############################################
711
+ # IDEAL/web
712
+ ###############################################
713
+ let(:new_payin_ideal_web) do
714
+ MangoPay::PayIn::Ideal::Web.create(
715
+ AuthorId: new_natural_user['Id'],
716
+ CreditedWalletId: new_wallet['Id'],
717
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
718
+ Fees: { Currency: 'EUR', Amount: 10 },
719
+ ReturnURL: 'http://www.my-site.com/returnURL',
720
+ Bic: 'REVOLT21',
721
+ StatementDescriptor: "test",
722
+ Tag: 'Test PayIn/Ideal/Web'
723
+ )
724
+ end
725
+
726
+ ###############################################
727
+ # Giropay/web
728
+ ###############################################
729
+ let(:new_payin_giropay_web) do
730
+ MangoPay::PayIn::Giropay::Web.create(
731
+ AuthorId: new_natural_user['Id'],
732
+ CreditedWalletId: new_wallet['Id'],
733
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
734
+ Fees: { Currency: 'EUR', Amount: 10 },
735
+ ReturnURL: 'http://www.my-site.com/returnURL',
736
+ StatementDescriptor: "test",
737
+ Tag: 'Test PayIn/Giropay/Web'
738
+ )
739
+ end
740
+
741
+ ###############################################
742
+ # Bancontact/web
743
+ ###############################################
744
+ let(:new_payin_bancontact_web) do
745
+ MangoPay::PayIn::Bancontact::Web.create(
746
+ AuthorId: new_natural_user['Id'],
747
+ CreditedWalletId: new_wallet['Id'],
748
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
749
+ Fees: { Currency: 'EUR', Amount: 10 },
750
+ ReturnURL: 'http://www.my-site.com/returnURL',
751
+ StatementDescriptor: "test",
752
+ Tag: 'Test PayIn/Bancontact/Web',
753
+ Culture: 'FR'
754
+ )
755
+ end
756
+
757
+ ###############################################
758
+ # Bizum/web
759
+ ###############################################
760
+ let(:new_payin_bizum_web_with_phone) do
761
+ user = new_natural_user
762
+ wallet = new_wallet
763
+ bizum = define_new_bizum(user, wallet, '+34700000000', nil)
764
+ MangoPay::PayIn::Bizum::Web.create(bizum)
765
+ end
766
+
767
+ let(:new_payin_bizum_web_with_return_url) do
768
+ user = new_natural_user
769
+ wallet = new_wallet
770
+ bizum = define_new_bizum(user, wallet, nil, 'https://docs.mangopay.com/please-ignore')
771
+ MangoPay::PayIn::Bizum::Web.create(bizum)
772
+ end
773
+
774
+ def define_new_bizum(user, wallet, phone, return_url)
775
+ {
776
+ AuthorId: user['Id'],
777
+ CreditedWalletId: wallet['Id'],
778
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
779
+ Fees: { Currency: 'EUR', Amount: 1 },
780
+ StatementDescriptor: "test bizum",
781
+ Phone: phone,
782
+ ReturnUrl: return_url,
783
+ Tag: 'Test PayIn/Bizum/Web',
784
+ ProfilingAttemptReference: nil
785
+ }
786
+ end
787
+
788
+ ###############################################
789
+ # Twint/web
790
+ ###############################################
791
+ let(:new_payin_twint_web) do
792
+ MangoPay::PayIn::Twint::Web.create(
793
+ AuthorId: new_natural_user['Id'],
794
+ CreditedWalletId: create_new_custom_wallet(new_natural_user, 'CHF')['Id'],
795
+ DebitedFunds: { Currency: 'CHF', Amount: 50 },
796
+ Fees: { Currency: 'CHF', Amount: 10 },
797
+ ReturnURL: 'http://www.my-site.com/returnURL',
798
+ StatementDescriptor: "test",
799
+ Tag: 'Test PayIn/Twint/Web'
800
+ )
801
+ end
802
+
803
+ ###############################################
804
+ # Swish/web
805
+ ###############################################
806
+ let(:new_payin_swish_web) do
807
+ MangoPay::PayIn::Swish::Web.create(
808
+ AuthorId: new_natural_user['Id'],
809
+ CreditedWalletId: create_new_custom_wallet(new_natural_user, 'SEK')['Id'],
810
+ DebitedFunds: { Currency: 'SEK', Amount: 400 },
811
+ Fees: { Currency: 'SEK', Amount: 10 },
812
+ ReturnURL: 'http://www.my-site.com/returnURL',
813
+ StatementDescriptor: "test",
814
+ Tag: 'Test PayIn/Swish/Web'
815
+ )
816
+ end
817
+
818
+ ###############################################
819
+ # PAYPAL/web V2
820
+ ###############################################
821
+ let(:new_payin_paypal_web_v2) do
822
+ MangoPay::PayIn::PayPal::Web.create_v2(
823
+ AuthorId: new_natural_user['Id'],
824
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
825
+ Fees: { Currency: 'EUR', Amount: 0 },
826
+ CreditedWalletId: new_wallet['Id'],
827
+ ReturnUrl: "http://example.com",
828
+ LineItems: [
829
+ {
830
+ Name: "running shoes",
831
+ Quantity: 1,
832
+ UnitAmount: 200,
833
+ TaxAmount: 0,
834
+ Description: "seller1 ID"
835
+ },
836
+ {
837
+ Name: "running shoes",
838
+ Quantity: 1,
839
+ UnitAmount: 200,
840
+ TaxAmount: 0,
841
+ Description: "seller2 ID"
842
+ }
843
+ ],
844
+ Shipping: {
845
+ Address: {
846
+ AddressLine1: 'AddressLine1',
847
+ AddressLine2: 'AddressLine2',
848
+ City: 'City',
849
+ Region: 'Region',
850
+ PostalCode: 'PostalCode',
851
+ Country: 'FR'
852
+ },
853
+ FirstName: 'Joe',
854
+ LastName: 'Blogs'
855
+ },
856
+ ShippingPreference: "GET_FROM_FILE",
857
+ StatementDescriptor: "ruby",
858
+ Tag: 'Test',
859
+ # Culture: 'FR'
860
+ )
861
+ end
862
+
863
+ def create_new_payin_card_direct(to_wallet, amnt = 1000)
864
+ cardreg = new_card_registration_completed
865
+ MangoPay::PayIn::Card::Direct.create(
866
+ AuthorId: new_natural_user['Id'],
867
+ CreditedUserId: to_wallet['Owners'][0],
868
+ CreditedWalletId: to_wallet['Id'],
869
+ DebitedFunds: { Currency: 'EUR', Amount: amnt },
870
+ Fees: { Currency: 'EUR', Amount: 0 },
871
+ CardType: 'CB_VISA_MASTERCARD',
872
+ CardId: cardreg['CardId'],
873
+ SecureModeReturnURL: 'http://test.com',
874
+ Tag: 'Test PayIn/Card/Direct',
875
+ Requested3DSVersion: 'V2_1',
876
+ BrowserInfo: {
877
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
878
+ JavaEnabled: true,
879
+ Language: "FR-FR",
880
+ ColorDepth: 4,
881
+ ScreenHeight: 1800,
882
+ ScreenWidth: 400,
883
+ JavascriptEnabled: true,
884
+ TimeZoneOffset: "+60",
885
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
886
+ },
887
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
888
+ )
889
+ end
890
+
891
+ ###############################################
892
+ # card/direct with pre-authorization
893
+ ###############################################
894
+
895
+ let(:new_card_preauthorization) { create_new_card_preauthorization(new_card_registration_completed) }
896
+
897
+ def create_new_card_preauthorization(cardreg, amnt = 1000)
898
+ MangoPay::PreAuthorization.create(
899
+ AuthorId: new_natural_user['Id'],
900
+ DebitedFunds: { Currency: 'EUR', Amount: amnt },
901
+ CardId: cardreg['CardId'],
902
+ SecureMode: 'DEFAULT',
903
+ SecureModeReturnURL: 'http://test.com',
904
+ Tag: 'Test Card PreAuthorization',
905
+ Requested3DSVersion: 'V2_1',
906
+ BrowserInfo: {
907
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
908
+ JavaEnabled: true,
909
+ Language: "FR-FR",
910
+ ColorDepth: 4,
911
+ ScreenHeight: 1800,
912
+ ScreenWidth: 400,
913
+ JavascriptEnabled: true,
914
+ TimeZoneOffset: "+60",
915
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
916
+ },
917
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
918
+ )
919
+ end
920
+
921
+ let(:new_payin_preauthorized_direct) { create_new_payin_preauthorized_direct(new_wallet) }
922
+
923
+ def create_new_payin_preauthorized_direct(to_wallet, amnt = 1000)
924
+ preauth = new_card_preauthorization
925
+ MangoPay::PayIn::PreAuthorized::Direct.create(
926
+ AuthorId: new_natural_user['Id'],
927
+ CreditedUserId: to_wallet['Owners'][0],
928
+ CreditedWalletId: to_wallet['Id'],
929
+ DebitedFunds: { Currency: 'EUR', Amount: amnt },
930
+ Fees: { Currency: 'EUR', Amount: 0 },
931
+ PreauthorizationId: preauth['Id'],
932
+ Tag: 'Test PayIn/PreAuthorized/Direct',
933
+ BrowserInfo: {
934
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
935
+ JavaEnabled: true,
936
+ Language: "FR-FR",
937
+ ColorDepth: 4,
938
+ ScreenHeight: 1800,
939
+ ScreenWidth: 400,
940
+ JavascriptEnabled: true,
941
+ TimeZoneOffset: "+60",
942
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
943
+ },
944
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
945
+ )
946
+ end
947
+
948
+ def create_card_validation(author_id, card_id)
949
+ params = {
950
+ AuthorId: author_id,
951
+ SecureModeReturnURL: "https://mangopay.com",
952
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
953
+ Tag: "custom meta",
954
+ BrowserInfo: {
955
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
956
+ JavaEnabled: true,
957
+ Language: "FR-FR",
958
+ ColorDepth: 4,
959
+ ScreenHeight: 1800,
960
+ ScreenWidth: 400,
961
+ JavascriptEnabled: true,
962
+ TimeZoneOffset: "+60",
963
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
964
+ }
965
+ }
966
+ MangoPay::Card.validate(card_id, params)
967
+ end
968
+
969
+ ###############################################
970
+ # pre-authorized direct deposit
971
+ ###############################################
972
+
973
+ def create_new_payin_pre_authorized_deposit_direct(deposit_id, author_id, credited_wallet_id)
974
+ MangoPay::PayIn::PreAuthorized::Direct.create_pre_authorized_deposit_pay_in(
975
+ AuthorId: author_id,
976
+ CreditedWalletId: credited_wallet_id,
977
+ DebitedFunds: { Currency: 'EUR', Amount: 500 },
978
+ Fees: { Currency: 'EUR', Amount: 0 },
979
+ DepositId: deposit_id,
980
+ Tag: 'lorem ipsum'
981
+ )
982
+ end
983
+
984
+ def create_new_deposit_pre_authorized_pay_in_prior_to_complement(deposit_id, author_id, credited_wallet_id)
985
+ MangoPay::PayIn::PreAuthorized::Direct.create_deposit_preauthorized_pay_in_prior_to_complement(
986
+ AuthorId: author_id,
987
+ CreditedWalletId: credited_wallet_id,
988
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
989
+ Fees: { Currency: 'EUR', Amount: 0 },
990
+ DepositId: deposit_id,
991
+ Tag: 'lorem ipsum'
992
+ )
993
+ end
994
+
995
+ def create_new_deposit_pre_authorized_pay_in_complement(deposit_id, author_id, credited_wallet_id)
996
+ MangoPay::PayIn::PreAuthorized::Direct.create_deposit_preauthorized_pay_in_complement(
997
+ AuthorId: author_id,
998
+ CreditedWalletId: credited_wallet_id,
999
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
1000
+ Fees: { Currency: 'EUR', Amount: 0 },
1001
+ DepositId: deposit_id,
1002
+ Tag: 'lorem ipsum'
1003
+ )
1004
+ end
1005
+
1006
+ ###############################################
1007
+ # bankwire/direct
1008
+ ###############################################
1009
+
1010
+ let(:new_payin_bankwire_direct) { create_new_payin_bankwire_direct(new_wallet) }
1011
+
1012
+ def create_new_payin_bankwire_direct(to_wallet, amnt = 1000)
1013
+ MangoPay::PayIn::BankWire::Direct.create(
1014
+ AuthorId: new_natural_user['Id'],
1015
+ CreditedUserId: to_wallet['Owners'][0],
1016
+ CreditedWalletId: to_wallet['Id'],
1017
+ DeclaredDebitedFunds: { Currency: 'EUR', Amount: amnt },
1018
+ DeclaredFees: { Currency: 'EUR', Amount: 0 },
1019
+ Tag: 'Test PayIn/BankWire/Direct'
1020
+ )
1021
+ end
1022
+
1023
+ ###############################################
1024
+ # wallet with money
1025
+ ###############################################
1026
+ #
1027
+ let(:new_wallet_with_money) { create_new_wallet_with_money(new_natural_user) }
1028
+
1029
+ def create_new_wallet_with_money(user)
1030
+ wallet = MangoPay::Wallet.create(
1031
+ Owners: [user['Id']],
1032
+ Description: 'A test wallet',
1033
+ Currency: 'EUR',
1034
+ Tag: 'Test wallet'
1035
+ )
1036
+
1037
+ pay_in = create_new_payin_card_direct(wallet)
1038
+ MangoPay::Wallet.fetch(pay_in['CreditedWalletId'])
1039
+ end
1040
+
1041
+ let(:new_payin_paybybank_web) do
1042
+ MangoPay::PayIn::PayByBank::Web.create(
1043
+ AuthorId: new_natural_user['Id'],
1044
+ CreditedWalletId: create_new_custom_wallet(new_natural_user, 'EUR')['Id'],
1045
+ DebitedFunds: { Currency: 'EUR', Amount: 400 },
1046
+ Fees: { Currency: 'EUR', Amount: 0 },
1047
+ ReturnURL: 'http://www.my-site.com/returnURL',
1048
+ StatementDescriptor: "test",
1049
+ Tag: 'Test PayIn/PayByBank/Web',
1050
+ Country: 'DE',
1051
+ IBAN: 'DE03500105177564668331',
1052
+ BIC: 'AACSDE33',
1053
+ Scheme: 'SEPA_INSTANT_CREDIT_TRANSFER',
1054
+ BankName: 'de-demobank-open-banking-embedded-templates',
1055
+ Culture: 'EN',
1056
+ PaymentFlow: 'WEB'
1057
+ )
1058
+ end
1059
+
1060
+ end
1061
+
1062
+ ###############################################
1063
+ shared_context 'payouts' do
1064
+ ###############################################
1065
+ include_context 'bank_accounts'
1066
+
1067
+ let(:new_payout_bankwire) { create_new_payout_bankwire(new_payin_card_direct) }
1068
+
1069
+ def create_new_payout_bankwire(payin, amnt = 500)
1070
+ MangoPay::PayOut::BankWire.create(
1071
+ AuthorId: payin['CreditedUserId'],
1072
+ DebitedWalletId: payin['CreditedWalletId'],
1073
+ DebitedFunds: { Currency: 'EUR', Amount: amnt },
1074
+ Fees: { Currency: 'EUR', Amount: 0 },
1075
+ BankAccountId: new_bank_account['Id'],
1076
+ Communication: 'This is a test',
1077
+ Tag: 'Test PayOut/Bank/Wire',
1078
+ PayoutModeRequested: 'Standard'
1079
+ )
1080
+ end
1081
+ end
1082
+
1083
+ ###############################################
1084
+ shared_context 'transfers' do
1085
+ ###############################################
1086
+ include_context 'users'
1087
+ include_context 'wallets'
1088
+ include_context 'payins'
1089
+
1090
+ let(:new_transfer) do
1091
+ wlt1 = new_wallet
1092
+ wlt2 = new_wallet_legal
1093
+ create_new_payin_card_direct(wlt1, 1000) # feed wlt1 with money
1094
+ create_new_transfer(wlt1, wlt2, 500) # transfer wlt1 => wlt2
1095
+ end
1096
+
1097
+ def create_new_transfer(from_wallet, to_wallet, amnt = 500)
1098
+ MangoPay::Transfer.create(
1099
+ AuthorId: from_wallet['Owners'][0],
1100
+ DebitedWalletId: from_wallet['Id'],
1101
+ CreditedUserId: to_wallet['Owners'][0],
1102
+ CreditedWalletId: to_wallet['Id'],
1103
+ DebitedFunds: { Currency: 'EUR', Amount: amnt },
1104
+ Fees: { Currency: 'EUR', Amount: 0 },
1105
+ Tag: 'Test transfer'
1106
+ )
1107
+ end
1108
+ end
1109
+
1110
+ ###############################################
1111
+ shared_context 'hooks' do
1112
+ ###############################################
1113
+ let(:new_hook) do
1114
+ hooks = MangoPay::Hook.fetch('page' => 1, 'per_page' => 1)
1115
+ if hooks.empty?
1116
+ MangoPay::Hook.create(
1117
+ EventType: 'PAYIN_NORMAL_CREATED',
1118
+ Url: 'http://test.com',
1119
+ Tag: 'Test hook'
1120
+ )
1121
+ else
1122
+ hooks[0]
1123
+ end
1124
+ end
1125
+ end
1126
+
1127
+ ###############################################
1128
+ shared_context 'bankingaliases' do
1129
+ ###############################################
1130
+ include_context 'users'
1131
+ include_context 'wallets'
1132
+
1133
+ let(:new_banking_alias) do
1134
+ MangoPay::BankingAliasesIBAN.create({
1135
+ CreditedUserId: new_natural_user['Id'],
1136
+ WalletId: new_wallet['Id'],
1137
+ OwnerName: new_natural_user['FirstName'],
1138
+ Country: 'LU'
1139
+ }, new_wallet['Id'])
1140
+ end
1141
+ end
1142
+
1143
+ ###############################################
1144
+ # deposits
1145
+ ###############################################
1146
+
1147
+ def create_new_deposit(card_registration_id, author_id)
1148
+ MangoPay::Deposit.create(
1149
+ {
1150
+ AuthorId: author_id,
1151
+ DebitedFunds: { Currency: 'EUR', Amount: 1000 },
1152
+ CardId: card_registration_id,
1153
+ SecureModeReturnURL: 'http://mangopay-sandbox-test.com',
1154
+ StatementDescriptor: "lorem",
1155
+ Culture: 'FR',
1156
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
1157
+ BrowserInfo: {
1158
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
1159
+ JavaEnabled: true,
1160
+ Language: "FR-FR",
1161
+ ColorDepth: 4,
1162
+ ScreenHeight: 1800,
1163
+ ScreenWidth: 400,
1164
+ JavascriptEnabled: true,
1165
+ TimeZoneOffset: "+60",
1166
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
1167
+ },
1168
+ Billing: {
1169
+ Address: {
1170
+ AddressLine1: 'AddressLine1',
1171
+ AddressLine2: 'AddressLine2',
1172
+ City: 'City',
1173
+ Region: 'Region',
1174
+ PostalCode: 'PostalCode',
1175
+ Country: 'FR'
1176
+ },
1177
+ FirstName: 'Joe',
1178
+ LastName: 'Blogs'
1179
+ },
1180
+ Shipping: {
1181
+ Address: {
1182
+ AddressLine1: 'AddressLine1',
1183
+ AddressLine2: 'AddressLine2',
1184
+ City: 'City',
1185
+ Region: 'Region',
1186
+ PostalCode: 'PostalCode',
1187
+ Country: 'FR'
1188
+ },
1189
+ FirstName: 'Joe',
1190
+ LastName: 'Blogs'
1191
+ }
1192
+ }
1193
+ )
1194
+ end
1195
+
1196
+ ###############################################
1197
+ # instant conversions
1198
+ ###############################################
1199
+ shared_context 'instant_conversion' do
1200
+ include_context 'payins'
1201
+
1202
+ def get_conversion_rate(debited_currency, credited_currency)
1203
+ MangoPay::Conversion.get_rate(debited_currency, credited_currency, params = {})
1204
+ end
1205
+
1206
+ def create_instant_conversion()
1207
+ user = new_natural_user
1208
+ credited_wallet = MangoPay::Wallet.create(
1209
+ Owners: [user['Id']],
1210
+ Description: 'A test wallet',
1211
+ Currency: 'GBP',
1212
+ Tag: 'Test wallet'
1213
+ )
1214
+
1215
+ MangoPay::Conversion.create_instant_conversion(
1216
+ AuthorId: user['Id'],
1217
+ CreditedWalletId: credited_wallet['Id'],
1218
+ DebitedWalletId: new_wallet_with_money['Id'],
1219
+ CreditedFunds: {
1220
+ Currency: 'GBP'
1221
+ },
1222
+ DebitedFunds: {
1223
+ Currency: 'EUR',
1224
+ Amount: 79
1225
+ },
1226
+ Fees: {
1227
+ Currency: 'EUR',
1228
+ Amount: 9
1229
+ },
1230
+ Tag: 'Instant conversion test'
1231
+ )
1232
+ end
1233
+
1234
+ def create_quoted_conversion()
1235
+ user = new_natural_user
1236
+ credited_wallet = MangoPay::Wallet.create(
1237
+ Owners: [user['Id']],
1238
+ Description: 'A test wallet',
1239
+ Currency: 'GBP',
1240
+ Tag: 'Test wallet'
1241
+ )
1242
+ quote = create_conversion_quote
1243
+
1244
+ MangoPay::Conversion.create_quoted_conversion(
1245
+ AuthorId: user['Id'],
1246
+ QuoteId: quote['Id'],
1247
+ CreditedWalletId: credited_wallet['Id'],
1248
+ DebitedWalletId: new_wallet_with_money['Id'],
1249
+ Tag: 'Quoted conversion test'
1250
+ )
1251
+ end
1252
+
1253
+ def create_conversion_quote
1254
+ MangoPay::Conversion.create_quote(
1255
+ CreditedFunds: { Currency: 'GBP' },
1256
+ DebitedFunds: { Currency: 'EUR', Amount: 50 },
1257
+ Duration: 300,
1258
+ Tag: 'Created using the Mangopay Ruby SDK'
1259
+ )
1260
+ end
1261
+
1262
+ def get_conversion(id)
1263
+ MangoPay::Conversion.get(id, params = {})
1264
+ end
1265
+
1266
+ def get_conversion_quote(id)
1267
+ MangoPay::Conversion.get_quote(id, params = {})
1268
+ end
1269
+ end
1270
+
1271
+ ###############################################
1272
+ # payment methods metadata
1273
+ ###############################################
1274
+ shared_context 'payment_method_metadata' do
1275
+ include_context 'payins'
1276
+
1277
+ def get_payment_method_metadata
1278
+
1279
+ wlt = new_wallet
1280
+ pay_in = create_new_payin_card_direct(wlt, 1000)
1281
+
1282
+ MangoPay::PaymentMethodMetadata.get_metadata(
1283
+ Type: 'BIN',
1284
+ Bin: pay_in['CardInfo']['BIN']
1285
+ )
1286
+ end
1287
+ end
1288
+
1289
+ ###############################################
1290
+ shared_context 'virtual_account' do
1291
+ ###############################################
1292
+ include_context 'users'
1293
+ include_context 'wallets'
1294
+
1295
+ def new_virtual_account(wallet_id)
1296
+ create_virtual_account = {
1297
+ Country: 'FR',
1298
+ VirtualAccountPurpose: 'Collection',
1299
+ Tag: 'create virtual account tag'
1300
+ }
1301
+
1302
+ MangoPay::VirtualAccount.create(wallet_id, create_virtual_account)
1303
+ end
1304
+ end
1305
+
1306
+ shared_context 'recipient' do
1307
+ include_context 'users'
1308
+
1309
+ let(:new_recipient) { create_new_recipient(create_new_natural_user_sca_owner['Id']) }
1310
+
1311
+ def create_new_recipient(user_id)
1312
+ MangoPay::Recipient.create(define_new_recipient, user_id)
1313
+ end
1314
+
1315
+ def define_new_recipient
1316
+ {
1317
+ "DisplayName": "Alex Smith GBP account",
1318
+ "PayoutMethodType": "LocalBankTransfer",
1319
+ "RecipientType": "Individual",
1320
+ "Currency": "GBP",
1321
+ "Country": "GB",
1322
+ "IndividualRecipient": {
1323
+ "FirstName": "Alex",
1324
+ "LastName": "Smith",
1325
+ "Address": {
1326
+ "AddressLine1": "10 Kingsway",
1327
+ "City": "London",
1328
+ "PostalCode": "WC2B 6LH",
1329
+ "Country": "GB"
1330
+ }
1331
+ },
1332
+ "LocalBankTransfer": {
1333
+ "GBP": {
1334
+ "SortCode": "200000",
1335
+ "AccountNumber": "55779911"
1336
+ }
1337
+ }
1338
+ }
1339
+ end
1340
+ end
1341
+
1342
+ shared_context 'intents' do
1343
+ include_context 'users'
1344
+
1345
+ let(:new_payin_intent_authorization) { create_new_payin_intent_authorization(create_new_natural_user_sca_payer) }
1346
+
1347
+ def create_new_payin_intent_authorization(user)
1348
+ MangoPay::PayIn::PayInIntent::Authorization.create(define_new_payin_intent_authorization(user))
1349
+ end
1350
+
1351
+ def define_new_payin_intent_authorization(user)
1352
+ wallet = create_new_wallet(user)
1353
+ {
1354
+ "Amount": 1000,
1355
+ "Currency": "EUR",
1356
+ "ExternalData": {
1357
+ "ExternalProcessingDate": 1728133765,
1358
+ "ExternalProviderReference": SecureRandom.uuid,
1359
+ "ExternalMerchantReference": "Order-xyz-35e8490e-2ec9-4c82-978e-c712a3f5ba16",
1360
+ "ExternalProviderName": "Stripe",
1361
+ "ExternalProviderPaymentMethod": "PAYPAL"
1362
+ },
1363
+ "Buyer": {
1364
+ "Id": user['Id']
1365
+ },
1366
+ "LineItems": [
1367
+ {
1368
+ "Seller": {
1369
+ "AuthorId": user['Id'],
1370
+ "WalletId": wallet['Id'],
1371
+ "TransferDate": 1728133765
1372
+ },
1373
+ "Sku": "item-123456",
1374
+ "Quantity": 1,
1375
+ "UnitAmount": 1000,
1376
+ }
1377
+ ]
1378
+ }
1379
+ end
1380
+ end