mangopay 3.11.0 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1fdfc923ff995412c8aaf53d8bb4684f35dbae82937532bb5c5682e54888462
4
- data.tar.gz: 2c7930a03a8e10a5ed13e35bb9bd3834fa1a738ca45232546b81935b5ec29dcb
3
+ metadata.gz: 913f73df1d1821cd5a933ee4a5c0bc7c776f1eeb512588b7488aa110706bf0b6
4
+ data.tar.gz: bda53a132d7e5b3a44739277405a9f79200dcb6bdab4e120ede7f6cae0e71a04
5
5
  SHA512:
6
- metadata.gz: 76ec1a6e0bbeca5e530f1e994501eed2471a4e2af1f6761e538ce9639873172b8a4a0d6278ecd45e146ae7e2b0a459828cb4a2958374e36b369fa756422bf210
7
- data.tar.gz: bfac13d78271a3dc3466f4f8bba3f3287baef8786528b7794a5af204f5bf7e6d4154a960f3b1dac41ebe4f60a735b4398d91ecdd1f67f22d0cb72b2d97de14f0
6
+ metadata.gz: d29406640c31ef0d20e5c060582cb5860946ce8ff4b0f249412e7edc368d355efbaf94cd595885afa863607264a9facfb6af3912e814743969e424ac559ebfe8
7
+ data.tar.gz: 7f31702439cff0df222e723c363e5b6c6f242fa582f82986f5a26809db63291eb17f46c2a2a476ecf15a9caadbd9c807766b5f8707b41abb58658cffd571f878
@@ -21,11 +21,11 @@ jobs:
21
21
  packages: write
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v2
24
+ - uses: actions/checkout@v3
25
25
  - name: Set up Ruby 2.6
26
- uses: actions/setup-ruby@v1
26
+ uses: ruby/setup-ruby@v1
27
27
  with:
28
- ruby-version: 2.6.x
28
+ ruby-version: 2.6.10
29
29
  - name: Install Rspec
30
30
  run: |
31
31
  gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [3.12.0] - 2022-11-16
2
+ ### New 30-day preauthorization feature
3
+
4
+ Preauthorizations can now hold funds for up to 30 days, therefore ensuring the solvency of a registered card for the same amount of time.
5
+
6
+ - The **Deposit** service has been added with methods for creating, fetching and canceling a deposit
7
+ - The **create_pre_authorized_deposit_pay_in** method has been added to the PayIn service
8
+
9
+ Thanks to 30-day preauthorizations, MANGOPAY can provide a simpler and more flexible payment experience for a wide range of use cases, especially for rentals.
10
+
11
+ ## [3.11.1] - 2022-10-18
12
+ ### Fixed
13
+
14
+ Tests has been fixed due to API evolution.
15
+
1
16
  ## [3.11.0] - 2022-09-08
2
17
  ##Added
3
18
  **New country authorizations endpoints**
@@ -0,0 +1,20 @@
1
+ module MangoPay
2
+
3
+ # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
4
+ class Deposit < Resource
5
+ def self.create(params, idempotency_key = nil)
6
+ MangoPay.request(:post, "#{MangoPay.api_path}/deposit-preauthorizations/card/direct", params, {}, idempotency_key)
7
+ end
8
+
9
+ def self.get(deposit_id, filters = {})
10
+ MangoPay.request(:get, "#{MangoPay.api_path}/deposit-preauthorizations/#{deposit_id}", {}, filters)
11
+ end
12
+
13
+ def self.cancel(deposit_id)
14
+ params = {
15
+ PaymentStatus: 'CANCELED'
16
+ }
17
+ MangoPay.request(:put, "#{MangoPay.api_path}/deposit-preauthorizations/#{deposit_id}", params)
18
+ end
19
+ end
20
+ end
@@ -55,6 +55,10 @@ module MangoPay
55
55
  def self.url(*)
56
56
  "#{MangoPay.api_path}/payins/preauthorized/direct"
57
57
  end
58
+
59
+ def self.create_pre_authorized_deposit_pay_in(params, idempotency_key = nil)
60
+ MangoPay.request(:post, "#{MangoPay.api_path}/payins/deposit-preauthorized/direct/full-capture", params, {}, idempotency_key)
61
+ end
58
62
  end
59
63
 
60
64
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.11.0'
2
+ VERSION = '3.12.0'
3
3
  end
data/lib/mangopay.rb CHANGED
@@ -43,6 +43,7 @@ module MangoPay
43
43
  autoload :UboDeclaration, 'mangopay/ubo_declaration'
44
44
  autoload :Ubo, 'mangopay/ubo'
45
45
  autoload :Regulatory, 'mangopay/regulatory'
46
+ autoload :Deposit, 'mangopay/deposit'
46
47
 
47
48
  # temporary
48
49
  autoload :Temp, 'mangopay/temp'
@@ -0,0 +1,76 @@
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_for_deposit
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_for_deposit
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
+ end
28
+
29
+ # the Cancel flow will be teste manually for now
30
+ =begin
31
+ describe 'CANCEL' do
32
+ it 'cancel an existing deposit' do
33
+ author = new_natural_user
34
+ card_registration = new_card_registration_completed
35
+ deposit = create_new_deposit(card_registration['CardId'], author['Id'])
36
+
37
+ assert_deposit(deposit, card_registration['CardId'], author["Id"])
38
+ expect(deposit['Status']).to eq('CREATED')
39
+ expect(deposit['PaymentStatus']).to eq('WAITING')
40
+
41
+ MangoPay::Deposit.cancel(deposit['Id'])
42
+
43
+ updated_deposit = MangoPay::Deposit.get(deposit['Id'])
44
+
45
+ assert_deposit(updated_deposit, card_registration['CardId'], author["Id"])
46
+ expect(updated_deposit['Status']).to eq('SUCCEEDED')
47
+ expect(updated_deposit['PaymentStatus']).to eq('CANCELED')
48
+ end
49
+ end
50
+ =end
51
+ end
52
+
53
+
54
+ def assert_deposit(deposit, card_reg_id, author_id)
55
+ expect(deposit['Id']).not_to be_nil
56
+ expect(deposit['CreationDate']).not_to be_nil
57
+ expect(deposit['ExpirationDate']).not_to be_nil
58
+ expect(deposit['AuthorId']).not_to be_nil
59
+ expect(deposit['DebitedFunds']).not_to be_nil
60
+ expect(deposit['Status']).not_to be_nil
61
+ expect(deposit['PaymentStatus']).not_to be_nil
62
+ expect(deposit['PayinsLinked']).not_to be_nil
63
+ expect(deposit['CardId']).not_to be_nil
64
+ expect(deposit['CardId']).to eq(card_reg_id)
65
+ expect(deposit['AuthorId']).to eq(author_id)
66
+ expect(deposit['SecureModeReturnURL']).not_to be_nil
67
+ expect(deposit['SecureModeRedirectURL']).not_to be_nil
68
+ expect(deposit['PaymentType']).not_to be_nil
69
+ expect(deposit['ExecutionType']).not_to be_nil
70
+ expect(deposit['StatementDescriptor']).not_to be_nil
71
+ expect(deposit['Culture']).not_to be_nil
72
+ expect(deposit['BrowserInfo']).not_to be_nil
73
+ expect(deposit['IpAddress']).not_to be_nil
74
+ expect(deposit['Billing']).not_to be_nil
75
+ expect(deposit['Shipping']).not_to be_nil
76
+ end
@@ -1,7 +1,8 @@
1
1
  describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
2
2
  include_context 'wallets'
3
3
  include_context 'payins'
4
-
4
+ include_context 'users'
5
+
5
6
  def check_type_and_status(payin)
6
7
  expect(payin['Type']).to eq('PAYIN')
7
8
  expect(payin['Nature']).to eq('REGULAR')
@@ -67,4 +68,21 @@ describe MangoPay::PayIn::PreAuthorized::Direct, type: :feature do
67
68
  end
68
69
  end
69
70
 
71
+ # this flow is tested manually for the moment
72
+ =begin
73
+ describe 'CREATE AND VIEW PRE AUTHORIZED DEPOSIT' do
74
+ it 'creates a card direct pre authorized deposit payin' do
75
+ wallet = new_wallet
76
+ author = new_natural_user
77
+ card_registration = new_card_registration_completed
78
+ deposit = create_new_deposit(card_registration['CardId'], author['Id'])
79
+
80
+ created = create_new_payin_pre_authorized_deposit_direct(deposit['Id'], author['Id'], wallet['Id'])
81
+
82
+ expect(created['Id']).not_to be_nil
83
+ check_type_and_status(created)
84
+ expect(created['DepositId']).to eq(deposit['Id'])
85
+ end
86
+ end
87
+ =end
70
88
  end
@@ -15,7 +15,7 @@ describe MangoPay::PreAuthorization do
15
15
  expect(created['PaymentStatus']).to eq('WAITING')
16
16
  expect(created['PaymentType']).to eq('CARD')
17
17
  expect(created['ExecutionType']).to eq('DIRECT')
18
- expect(created['Requested3DSVersion']).to eq('V1')
18
+ expect(created['Requested3DSVersion']).to eq('V2_1')
19
19
  end
20
20
  end
21
21
 
@@ -221,13 +221,13 @@ shared_context 'payins' do
221
221
 
222
222
  let(:new_payin_payconiq_web) do
223
223
  MangoPay::PayIn::Payconiq::Web.create(
224
- AuthorId: new_natural_user['Id'],
225
- CreditedWalletId: new_wallet['Id'],
226
- DebitedFunds: {Currency: 'EUR', Amount: 100},
227
- Fees: {Currency: 'EUR', Amount: 0},
228
- ReturnURL: MangoPay.configuration.root_url,
229
- Country: "BE",
230
- Tag: 'Custom Meta'
224
+ AuthorId: new_natural_user['Id'],
225
+ CreditedWalletId: new_wallet['Id'],
226
+ DebitedFunds: {Currency: 'EUR', Amount: 100},
227
+ Fees: {Currency: 'EUR', Amount: 0},
228
+ ReturnURL: MangoPay.configuration.root_url,
229
+ Country: "BE",
230
+ Tag: 'Custom Meta'
231
231
  )
232
232
  end
233
233
 
@@ -357,7 +357,7 @@ shared_context 'payins' do
357
357
  data = {
358
358
  data: cardreg['PreregistrationData'],
359
359
  accessKeyRef: cardreg['AccessKey'],
360
- cardNumber: 4970100000000154,
360
+ cardNumber: 4970105191923460,
361
361
  cardExpirationDate: 1226,
362
362
  cardCvx: 123}
363
363
 
@@ -377,11 +377,33 @@ shared_context 'payins' do
377
377
 
378
378
  # 2nd step: tokenize by payline (fills-in RegistrationData)
379
379
  data = {
380
- data: cardreg['PreregistrationData'],
381
- accessKeyRef: cardreg['AccessKey'],
382
- cardNumber: 4970105191923460,
383
- cardExpirationDate: 1224,
384
- cardCvx: 123}
380
+ data: cardreg['PreregistrationData'],
381
+ accessKeyRef: cardreg['AccessKey'],
382
+ cardNumber: 4970105191923460,
383
+ cardExpirationDate: 1224,
384
+ cardCvx: 123}
385
+
386
+ res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
387
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
388
+
389
+ cardreg['RegistrationData'] = res.body
390
+
391
+ # 3rd step: update (fills-in CardId) and return it
392
+ MangoPay::CardRegistration.update(cardreg['Id'],
393
+ RegistrationData: cardreg['RegistrationData'])
394
+ end
395
+
396
+ let(:new_card_registration_completed_for_deposit) do
397
+ # 1st step: create
398
+ cardreg = new_card_registration
399
+
400
+ # 2nd step: tokenize by payline (fills-in RegistrationData)
401
+ data = {
402
+ data: cardreg['PreregistrationData'],
403
+ accessKeyRef: cardreg['AccessKey'],
404
+ cardNumber: 4970105181818183,
405
+ cardExpirationDate: 1226,
406
+ cardCvx: 123}
385
407
 
386
408
  res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
387
409
  raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
@@ -407,7 +429,19 @@ shared_context 'payins' do
407
429
  CardId: cardreg['CardId'],
408
430
  SecureModeReturnURL: 'http://test.com',
409
431
  Tag: 'Test PayIn/Card/Direct',
410
- Requested3DSVersion: 'V1'
432
+ Requested3DSVersion: 'V2_1',
433
+ BrowserInfo: {
434
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
435
+ JavaEnabled: true,
436
+ Language: "FR-FR",
437
+ ColorDepth: 4,
438
+ ScreenHeight: 1800,
439
+ ScreenWidth: 400,
440
+ JavascriptEnabled: true,
441
+ TimeZoneOffset: "+60",
442
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
443
+ },
444
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
411
445
  )
412
446
  end
413
447
 
@@ -425,7 +459,19 @@ shared_context 'payins' do
425
459
  SecureMode: 'DEFAULT',
426
460
  SecureModeReturnURL: 'http://test.com',
427
461
  Tag: 'Test Card PreAuthorization',
428
- Requested3DSVersion: 'V1'
462
+ Requested3DSVersion: 'V2_1',
463
+ BrowserInfo: {
464
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
465
+ JavaEnabled: true,
466
+ Language: "FR-FR",
467
+ ColorDepth: 4,
468
+ ScreenHeight: 1800,
469
+ ScreenWidth: 400,
470
+ JavascriptEnabled: true,
471
+ TimeZoneOffset: "+60",
472
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
473
+ },
474
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
429
475
  )
430
476
  end
431
477
 
@@ -440,7 +486,34 @@ shared_context 'payins' do
440
486
  DebitedFunds: {Currency: 'EUR', Amount: amnt},
441
487
  Fees: {Currency: 'EUR', Amount: 0},
442
488
  PreauthorizationId: preauth['Id'],
443
- Tag: 'Test PayIn/PreAuthorized/Direct'
489
+ Tag: 'Test PayIn/PreAuthorized/Direct',
490
+ BrowserInfo: {
491
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
492
+ JavaEnabled: true,
493
+ Language: "FR-FR",
494
+ ColorDepth: 4,
495
+ ScreenHeight: 1800,
496
+ ScreenWidth: 400,
497
+ JavascriptEnabled: true,
498
+ TimeZoneOffset: "+60",
499
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
500
+ },
501
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C"
502
+ )
503
+ end
504
+
505
+ ###############################################
506
+ # pre-authorized direct deposit
507
+ ###############################################
508
+
509
+ def create_new_payin_pre_authorized_deposit_direct(deposit_id, author_id, credited_wallet_id)
510
+ MangoPay::PayIn::PreAuthorized::Direct.create_pre_authorized_deposit_pay_in(
511
+ AuthorId: author_id,
512
+ CreditedWalletId: credited_wallet_id,
513
+ DebitedFunds: {Currency: 'EUR', Amount: 500},
514
+ Fees: {Currency: 'EUR', Amount: 0},
515
+ DepositId: deposit_id,
516
+ Tag: 'lorem ipsum'
444
517
  )
445
518
  end
446
519
 
@@ -542,3 +615,57 @@ shared_context 'bankigaliases' do
542
615
  }, new_wallet['Id'])
543
616
  end
544
617
  end
618
+
619
+
620
+ ###############################################
621
+ # deposits
622
+ ###############################################
623
+
624
+ def create_new_deposit(card_registration_id, author_id)
625
+ MangoPay::Deposit.create(
626
+ {
627
+ AuthorId: author_id,
628
+ DebitedFunds: {Currency: 'EUR', Amount: 1000},
629
+ CardId: card_registration_id,
630
+ SecureModeReturnURL: 'http://mangopay-sandbox-test.com',
631
+ StatementDescriptor: "lorem",
632
+ Culture: 'FR',
633
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
634
+ BrowserInfo: {
635
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
636
+ JavaEnabled: true,
637
+ Language: "FR-FR",
638
+ ColorDepth: 4,
639
+ ScreenHeight: 1800,
640
+ ScreenWidth: 400,
641
+ JavascriptEnabled: true,
642
+ TimeZoneOffset: "+60",
643
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
644
+ },
645
+ Billing: {
646
+ Address: {
647
+ AddressLine1: 'AddressLine1',
648
+ AddressLine2: 'AddressLine2',
649
+ City: 'City',
650
+ Region: 'Region',
651
+ PostalCode: 'PostalCode',
652
+ Country: 'FR'
653
+ },
654
+ FirstName: 'Joe',
655
+ LastName: 'Blogs'
656
+ },
657
+ Shipping: {
658
+ Address: {
659
+ AddressLine1: 'AddressLine1',
660
+ AddressLine2: 'AddressLine2',
661
+ City: 'City',
662
+ Region: 'Region',
663
+ PostalCode: 'PostalCode',
664
+ Country: 'FR'
665
+ },
666
+ FirstName: 'Joe',
667
+ LastName: 'Blogs'
668
+ }
669
+ }
670
+ )
671
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-08 00:00:00.000000000 Z
12
+ date: 2022-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -82,6 +82,7 @@ files:
82
82
  - lib/mangopay/card.rb
83
83
  - lib/mangopay/card_registration.rb
84
84
  - lib/mangopay/client.rb
85
+ - lib/mangopay/deposit.rb
85
86
  - lib/mangopay/dispute.rb
86
87
  - lib/mangopay/errors.rb
87
88
  - lib/mangopay/event.rb
@@ -115,6 +116,7 @@ files:
115
116
  - spec/mangopay/client_spec.png
116
117
  - spec/mangopay/client_spec.rb
117
118
  - spec/mangopay/configuration_spec.rb
119
+ - spec/mangopay/deposit_spec.rb
118
120
  - spec/mangopay/dispute_spec.png
119
121
  - spec/mangopay/dispute_spec.rb
120
122
  - spec/mangopay/event_spec.rb
@@ -182,6 +184,7 @@ test_files:
182
184
  - spec/mangopay/client_spec.png
183
185
  - spec/mangopay/client_spec.rb
184
186
  - spec/mangopay/configuration_spec.rb
187
+ - spec/mangopay/deposit_spec.rb
185
188
  - spec/mangopay/dispute_spec.png
186
189
  - spec/mangopay/dispute_spec.rb
187
190
  - spec/mangopay/event_spec.rb