mangopay 3.11.1 → 3.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby_cd.yml +3 -3
- data/.github/workflows/ruby_ci.yml +3 -3
- data/CHANGELOG.md +27 -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 +14 -2
- data/spec/mangopay/bankingaliases_spec.rb +1 -1
- data/spec/mangopay/deposit_spec.rb +76 -0
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +19 -1
- data/spec/mangopay/shared_resources.rb +92 -1
- 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: 33c2d6553dc8885b0fe21e619033297cf0b7101a34075ad1bc71ec9a17117707
|
4
|
+
data.tar.gz: ec0af8fa883f54639840ff7fd47b26f3ac491509122ecb83a755919263d4e811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2be5f515afb4652ec2b18d8411dfcaff56ccde9e7c7a121dc6ce575392165ae1a86a0d245f4553e0a9b94e7d8cefe4acb00284c9946b47d1a3a05ce3a38ad030
|
7
|
+
data.tar.gz: a67eab6dbb229a8a9d53f4839faa11650de723dda61bf208e8a10c44b7c7fcf47605a7af2620330d501b5a278b891cb57b15f6b58b21275b67de677f812d0d69
|
@@ -16,11 +16,11 @@ jobs:
|
|
16
16
|
packages: write
|
17
17
|
|
18
18
|
steps:
|
19
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v3
|
20
20
|
- name: Set up Ruby 2.6
|
21
|
-
uses:
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
22
|
with:
|
23
|
-
ruby-version: 2.6.
|
23
|
+
ruby-version: 2.6.10
|
24
24
|
|
25
25
|
- name: Publish to RubyGems
|
26
26
|
run: |
|
@@ -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,30 @@
|
|
1
|
+
## [3.13.2] - 2023-05-18
|
2
|
+
### Fixes
|
3
|
+
|
4
|
+
- fixed GitHub Actions CD pipeline
|
5
|
+
|
6
|
+
## [3.13.1] - 2023-05-18
|
7
|
+
### Fixes
|
8
|
+
|
9
|
+
- typo fixed in test context name (@batistadasilva)
|
10
|
+
|
11
|
+
## [3.13.0] - 2023-05-17
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Possibility to configure HTTP `max_retries (http_max_retries)` (default value = 1) and `open_timeout (http_open_timeout)` (default value = 60 seconds)
|
15
|
+
- Increased default `read_timeout` to 30 seconds
|
16
|
+
|
17
|
+
|
18
|
+
## [3.12.0] - 2022-11-16
|
19
|
+
### New 30-day preauthorization feature
|
20
|
+
|
21
|
+
Preauthorizations can now hold funds for up to 30 days, therefore ensuring the solvency of a registered card for the same amount of time.
|
22
|
+
|
23
|
+
- The **Deposit** service has been added with methods for creating, fetching and canceling a deposit
|
24
|
+
- The **create_pre_authorized_deposit_pay_in** method has been added to the PayIn service
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
1
28
|
## [3.11.1] - 2022-10-18
|
2
29
|
### Fixed
|
3
30
|
|
@@ -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
@@ -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'
|
@@ -51,6 +52,7 @@ module MangoPay
|
|
51
52
|
attr_accessor :preproduction, :root_url,
|
52
53
|
:client_id, :client_apiKey,
|
53
54
|
:temp_dir, :log_file, :http_timeout,
|
55
|
+
:http_max_retries, :http_open_timeout,
|
54
56
|
:logger
|
55
57
|
|
56
58
|
def preproduction
|
@@ -62,7 +64,15 @@ module MangoPay
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def http_timeout
|
65
|
-
@http_timeout ||
|
67
|
+
@http_timeout || 30000
|
68
|
+
end
|
69
|
+
|
70
|
+
def http_max_retries
|
71
|
+
@http_max_retries || 1
|
72
|
+
end
|
73
|
+
|
74
|
+
def http_open_timeout
|
75
|
+
@http_open_timeout || 60000
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
@@ -140,7 +150,9 @@ module MangoPay
|
|
140
150
|
headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
|
141
151
|
end
|
142
152
|
|
143
|
-
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout,
|
153
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout,
|
154
|
+
:max_retries => configuration.http_max_retries,
|
155
|
+
:open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
|
144
156
|
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
|
145
157
|
req.body = JSON.dump(params)
|
146
158
|
before_request_proc.call(req) if before_request_proc
|
@@ -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
|
###############################################
|
@@ -564,7 +601,7 @@ shared_context 'hooks' do
|
|
564
601
|
end
|
565
602
|
|
566
603
|
###############################################
|
567
|
-
shared_context '
|
604
|
+
shared_context 'bankingaliases' do
|
568
605
|
###############################################
|
569
606
|
include_context 'users'
|
570
607
|
include_context 'wallets'
|
@@ -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.13.2
|
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:
|
12
|
+
date: 2023-05-18 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
|