mangopay 3.11.1 → 3.12.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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby_ci.yml +3 -3
- data/CHANGELOG.md +10 -0
- data/lib/mangopay/deposit.rb +20 -0
- data/lib/mangopay/pay_in.rb +4 -0
- data/lib/mangopay/version.rb +1 -1
- data/lib/mangopay.rb +1 -0
- data/spec/mangopay/deposit_spec.rb +76 -0
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +19 -1
- data/spec/mangopay/shared_resources.rb +91 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913f73df1d1821cd5a933ee4a5c0bc7c776f1eeb512588b7488aa110706bf0b6
|
4
|
+
data.tar.gz: bda53a132d7e5b3a44739277405a9f79200dcb6bdab4e120ede7f6cae0e71a04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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@
|
24
|
+
- uses: actions/checkout@v3
|
25
25
|
- name: Set up Ruby 2.6
|
26
|
-
uses:
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
27
|
with:
|
28
|
-
ruby-version: 2.6.
|
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,13 @@
|
|
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
|
+
|
1
11
|
## [3.11.1] - 2022-10-18
|
2
12
|
### Fixed
|
3
13
|
|
@@ -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
|
data/lib/mangopay/pay_in.rb
CHANGED
@@ -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
|
data/lib/mangopay/version.rb
CHANGED
data/lib/mangopay.rb
CHANGED
@@ -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
|
@@ -393,6 +393,28 @@ shared_context 'payins' do
|
|
393
393
|
RegistrationData: cardreg['RegistrationData'])
|
394
394
|
end
|
395
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}
|
407
|
+
|
408
|
+
res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
|
409
|
+
raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
|
410
|
+
|
411
|
+
cardreg['RegistrationData'] = res.body
|
412
|
+
|
413
|
+
# 3rd step: update (fills-in CardId) and return it
|
414
|
+
MangoPay::CardRegistration.update(cardreg['Id'],
|
415
|
+
RegistrationData: cardreg['RegistrationData'])
|
416
|
+
end
|
417
|
+
|
396
418
|
let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
|
397
419
|
|
398
420
|
def create_new_payin_card_direct(to_wallet, amnt = 1000)
|
@@ -480,6 +502,21 @@ shared_context 'payins' do
|
|
480
502
|
)
|
481
503
|
end
|
482
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'
|
517
|
+
)
|
518
|
+
end
|
519
|
+
|
483
520
|
###############################################
|
484
521
|
# bankwire/direct
|
485
522
|
###############################################
|
@@ -578,3 +615,57 @@ shared_context 'bankigaliases' do
|
|
578
615
|
}, new_wallet['Id'])
|
579
616
|
end
|
580
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.
|
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-
|
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
|