mangopay 3.26.1 → 3.28.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: cea2df4d903ca0809a7f7ef9bc42b0263ee2df6ff5ba71fdd37a99c081b96ca3
4
- data.tar.gz: 4abceca571bd69f5a47c0597b674ed6869c91f16ddb9408da6b28d23ff24e04e
3
+ metadata.gz: cc9a455fb7af8971bada1a74b9bd9b95e1eeffcb0c564ff8730e545328a176e5
4
+ data.tar.gz: 988e0bcd0efcdf4b606fd5702b14b057e20e074629bb131b6bd0a9ba3bf8e7db
5
5
  SHA512:
6
- metadata.gz: 73bec6513fa3016b23164e62680c12f5a030b2e150b02fbf01fb4a93973b8e5071dd72e17a92e4de188e6492c70404561062235563038d60c077853c02beb83c
7
- data.tar.gz: 807e1c583b1114fa34b750500de47b9ea827a6975d06652bac235ffd1139a161e088e48afda6c1a103788cc6cfb60e1689c7f20d762fa713772f1b266aecb9ac
6
+ metadata.gz: 0a12f03e94a555fec121e7eadc4d594a49d9a0398c78629fee555c8e9361569a33f9eed5998b0872474cf92ffcd617a6f0ac7d5412e4d934208480baf4c17c0d
7
+ data.tar.gz: 6cdbbc86797db65b537fd839015e4c7cfec85e5cea26c42a53bfe8856dbbc3b6857dc78aa0d6a43a47a0010eb587597ca32c7288a529d51a8ef5419df2b624ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [3.28.0] - 2024-11-15
2
+ ### Added
3
+
4
+ New endpoint for [The TWINT PayIn object](https://docs.mangopay.com/api-reference/twint/twint-payin-object#the-twint-payin-object):
5
+ - [Create a TWINT PayIn](https://docs.mangopay.com/api-reference/twint/create-twint-payin)
6
+ - [View a PayIn (TWINT)](https://docs.mangopay.com/api-reference/twint/view-payin-twint)
7
+
8
+ New endpoint for [The Swish PayIn object](https://docs.mangopay.com/api-reference/swish/swish-payin-object):
9
+ - [Create a Swish PayIn](https://docs.mangopay.com/api-reference/swish/create-swish-payin)
10
+ - [View a PayIn (Swish)](https://docs.mangopay.com/api-reference/swish/view-payin-swish)
11
+
12
+ ## [3.27.0] - 2024-10-29
13
+ ### Added
14
+
15
+ New endpoints for The Virtual Account object:
16
+ - [Create a Virtual Account]()
17
+ - [Deactivate a Virtual Account]()
18
+ - [View a Virtual Account]()
19
+ - [List Virtual Accounts for a Wallet]()
20
+ - [View Client Availabilities]()
21
+
1
22
  ## [3.26.1] - 2024-10-03
2
23
  ### Fixed
3
24
 
@@ -243,6 +243,26 @@ module MangoPay
243
243
  end
244
244
  end
245
245
 
246
+ module Twint
247
+ class Web < Resource
248
+ include HTTPCalls::Create
249
+
250
+ def self.url(*)
251
+ "#{MangoPay.api_path}/payins/payment-methods/twint"
252
+ end
253
+ end
254
+ end
255
+
256
+ module Swish
257
+ class Web < Resource
258
+ include HTTPCalls::Create
259
+
260
+ def self.url(*)
261
+ "#{MangoPay.api_path}/payins/payment-methods/swish"
262
+ end
263
+ end
264
+ end
265
+
246
266
  module RecurringPayments
247
267
  class Recurring < Resource
248
268
  include HTTPCalls::Create
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.26.1'
2
+ VERSION = '3.28.0'
3
3
  end
@@ -0,0 +1,44 @@
1
+ module MangoPay
2
+
3
+ class VirtualAccount < Resource
4
+ class << self
5
+ # Creates a new virtual account
6
+ def create(wallet_id, params, idempotency_key = nil)
7
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
8
+ MangoPay.request(:post, url, params, {}, idempotency_key)
9
+ end
10
+
11
+ # Updates:
12
+ # - irreversibly deactivates a virtual account with +virtual_account_id+
13
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/deactivate-virtual-account
14
+ def deactivate(wallet_id, virtual_account_id, idempotency_key = nil)
15
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
16
+ MangoPay.request(:put, url, {}, {}, idempotency_key)
17
+ end
18
+
19
+ # Fetches:
20
+ # - view a virtual account with +virtual_account_id+
21
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account
22
+ def fetch(wallet_id, virtual_account_id)
23
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts/#{virtual_account_id}"
24
+ MangoPay.request(:get, url, {})
25
+ end
26
+
27
+ # Fetches:
28
+ # - view virtual accounts for given +wallet_id+
29
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/list-virtual-accounts-wallet
30
+ def fetch_all(wallet_id, filters = {})
31
+ url = "#{MangoPay.api_path}/wallets/#{wallet_id}/virtual-accounts"
32
+ MangoPay.request(:get, url, {}, filters)
33
+ end
34
+
35
+ # Fetches:
36
+ # Allows to check which account countries and currencies are available
37
+ # see https://docs.mangopay.com/api-reference/virtual-accounts/view-virtual-account-availabilities
38
+ def fetch_availabilities(filters = {})
39
+ url = "#{MangoPay.api_path}/virtual-accounts/availability"
40
+ MangoPay.request(:get, url, {}, filters)
41
+ end
42
+ end
43
+ end
44
+ end
data/lib/mangopay.rb CHANGED
@@ -47,6 +47,7 @@ module MangoPay
47
47
  autoload :Deposit, 'mangopay/deposit'
48
48
  autoload :Conversion, 'mangopay/conversion'
49
49
  autoload :PaymentMethodMetadata, 'mangopay/payment_method_metadata'
50
+ autoload :VirtualAccount, 'mangopay/virtual_account'
50
51
 
51
52
  # temporary
52
53
  autoload :Temp, 'mangopay/temp'
@@ -0,0 +1,30 @@
1
+ describe MangoPay::PayIn::Swish::Web, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
5
+ def check_type_and_status(payin)
6
+ expect(payin['Type']).to eq('PAYIN')
7
+ expect(payin['Nature']).to eq('REGULAR')
8
+ expect(payin['PaymentType']).to eq('SWISH')
9
+ expect(payin['ExecutionType']).to eq('WEB')
10
+ expect(payin['Status']).to eq('CREATED')
11
+ end
12
+
13
+ describe 'CREATE' do
14
+ it 'creates a swish web payin' do
15
+ created = new_payin_swish_web
16
+ expect(created['Id']).not_to be_nil
17
+ check_type_and_status(created)
18
+ end
19
+ end
20
+
21
+ describe 'FETCH' do
22
+ it 'fetches a payin' do
23
+ created = new_payin_swish_web
24
+ fetched = MangoPay::PayIn.fetch(created['Id'])
25
+ expect(fetched['Id']).to eq(created['Id'])
26
+ check_type_and_status(created)
27
+ check_type_and_status(fetched)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ describe MangoPay::PayIn::Twint::Web, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
5
+ def check_type_and_status(payin)
6
+ expect(payin['Type']).to eq('PAYIN')
7
+ expect(payin['Nature']).to eq('REGULAR')
8
+ expect(payin['PaymentType']).to eq('TWINT')
9
+ expect(payin['ExecutionType']).to eq('WEB')
10
+ expect(payin['Status']).to eq('CREATED')
11
+ end
12
+
13
+ describe 'CREATE' do
14
+ it 'creates a twint web payin' do
15
+ created = new_payin_twint_web
16
+ expect(created['Id']).not_to be_nil
17
+ check_type_and_status(created)
18
+ end
19
+ end
20
+
21
+ describe 'FETCH' do
22
+ it 'fetches a payin' do
23
+ created = new_payin_twint_web
24
+ fetched = MangoPay::PayIn.fetch(created['Id'])
25
+ expect(fetched['Id']).to eq(created['Id'])
26
+ check_type_and_status(created)
27
+ check_type_and_status(fetched)
28
+ end
29
+ end
30
+ end
@@ -83,6 +83,15 @@ shared_context 'wallets' do
83
83
  )
84
84
  end
85
85
 
86
+ def create_new_custom_wallet(user, currency)
87
+ MangoPay::Wallet.create(
88
+ Owners: [user['Id']],
89
+ Description: 'A test wallet',
90
+ Currency: currency,
91
+ Tag: 'Test wallet'
92
+ )
93
+ end
94
+
86
95
  def wallets_check_amounts(wlt1, amnt1, wlt2 = nil, amnt2 = nil)
87
96
  expect(wlt1['Balance']['Amount']).to eq amnt1
88
97
  expect(wlt2['Balance']['Amount']).to eq amnt2 if wlt2
@@ -570,6 +579,36 @@ shared_context 'payins' do
570
579
  )
571
580
  end
572
581
 
582
+ ###############################################
583
+ # Twint/web
584
+ ###############################################
585
+ let(:new_payin_twint_web) do
586
+ MangoPay::PayIn::Twint::Web.create(
587
+ AuthorId: new_natural_user['Id'],
588
+ CreditedWalletId: create_new_custom_wallet(new_natural_user, 'CHF')['Id'],
589
+ DebitedFunds: { Currency: 'CHF', Amount: 50 },
590
+ Fees: { Currency: 'CHF', Amount: 10 },
591
+ ReturnURL: 'http://www.my-site.com/returnURL',
592
+ StatementDescriptor: "test",
593
+ Tag: 'Test PayIn/Twint/Web'
594
+ )
595
+ end
596
+
597
+ ###############################################
598
+ # Swish/web
599
+ ###############################################
600
+ let(:new_payin_swish_web) do
601
+ MangoPay::PayIn::Swish::Web.create(
602
+ AuthorId: new_natural_user['Id'],
603
+ CreditedWalletId: create_new_custom_wallet(new_natural_user, 'SEK')['Id'],
604
+ DebitedFunds: { Currency: 'SEK', Amount: 400 },
605
+ Fees: { Currency: 'SEK', Amount: 10 },
606
+ ReturnURL: 'http://www.my-site.com/returnURL',
607
+ StatementDescriptor: "test",
608
+ Tag: 'Test PayIn/Swish/Web'
609
+ )
610
+ end
611
+
573
612
  ###############################################
574
613
  # PAYPAL/web V2
575
614
  ###############################################
@@ -998,4 +1037,21 @@ shared_context 'payment_method_metadata' do
998
1037
  Bin: pay_in['CardInfo']['BIN']
999
1038
  )
1000
1039
  end
1040
+ end
1041
+
1042
+ ###############################################
1043
+ shared_context 'virtual_account' do
1044
+ ###############################################
1045
+ include_context 'users'
1046
+ include_context 'wallets'
1047
+
1048
+ def new_virtual_account(wallet_id)
1049
+ create_virtual_account = {
1050
+ Country: 'FR',
1051
+ VirtualAccountPurpose: 'Collection',
1052
+ Tag: 'create virtual account tag'
1053
+ }
1054
+
1055
+ MangoPay::VirtualAccount.create(wallet_id, create_virtual_account)
1056
+ end
1001
1057
  end
@@ -0,0 +1,52 @@
1
+ describe MangoPay::VirtualAccount do
2
+ include_context 'virtual_account'
3
+ include_context 'wallets'
4
+
5
+ describe 'CREATE' do
6
+ it 'can create a Virtual Account' do
7
+ wallet = new_wallet
8
+ virtual_account = new_virtual_account(wallet['Id'])
9
+ expect(virtual_account).not_to be_nil
10
+ end
11
+ end
12
+
13
+ describe 'DEACTIVATE' do
14
+ it 'deactivates a Virtual Account' do
15
+ wallet = new_wallet
16
+ virtual_account = new_virtual_account(wallet['Id'])
17
+ deactivated = MangoPay::VirtualAccount.deactivate(wallet['Id'], virtual_account['Id'])
18
+ expect(deactivated).not_to be_nil
19
+ expect(deactivated['Status']).to eq 'CLOSED'
20
+ expect(deactivated['Id']).to eq(virtual_account['Id'])
21
+ end
22
+ end
23
+
24
+ describe 'FETCH' do
25
+ it 'can get a Virtual Account' do
26
+ wallet = new_wallet
27
+ virtual_account = new_virtual_account(wallet['Id'])
28
+ fetched = MangoPay::VirtualAccount.fetch(wallet['Id'], virtual_account['Id'])
29
+ expect(fetched).not_to be_nil
30
+ expect(fetched['Id']).to eq(virtual_account['Id'])
31
+ end
32
+ end
33
+
34
+ describe 'FETCH ALL' do
35
+ it 'can get all Virtual Accounts for a wallet' do
36
+ wallet = new_wallet
37
+ virtual_account = new_virtual_account(wallet['Id'])
38
+ fetched_list = MangoPay::VirtualAccount.fetch_all(wallet['Id'])
39
+ expect(fetched_list).not_to be_nil
40
+ expect(fetched_list[0]['Id']).to eq(virtual_account['Id'])
41
+ end
42
+ end
43
+
44
+ describe 'FETCH AVAILABILITIES' do
45
+ it 'get availabilities' do
46
+ availabilities = MangoPay::VirtualAccount.fetch_availabilities
47
+ expect(availabilities).not_to be_nil
48
+ expect(availabilities['Collection']).not_to be_nil
49
+ expect(availabilities['UserOwned']).not_to be_nil
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.26.1
4
+ version: 3.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
8
8
  - Sergiusz Woznicki
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-10-03 00:00:00.000000000 Z
12
+ date: 2024-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -109,6 +109,7 @@ files:
109
109
  - lib/mangopay/ubo_declaration.rb
110
110
  - lib/mangopay/user.rb
111
111
  - lib/mangopay/version.rb
112
+ - lib/mangopay/virtual_account.rb
112
113
  - lib/mangopay/wallet.rb
113
114
  - mangopay.gemspec
114
115
  - spec/mangopay/authorization_token_spec.rb
@@ -149,6 +150,8 @@ files:
149
150
  - spec/mangopay/payin_paypal_web_spec.rb
150
151
  - spec/mangopay/payin_preauthorized_direct_spec.rb
151
152
  - spec/mangopay/payin_satispay_web_spec.rb
153
+ - spec/mangopay/payin_swish_web_spec.rb
154
+ - spec/mangopay/payin_twint_web_spec.rb
152
155
  - spec/mangopay/payment_method_metadata_spec.rb
153
156
  - spec/mangopay/payout_bankwire_spec.rb
154
157
  - spec/mangopay/preauthorization_spec.rb
@@ -163,6 +166,7 @@ files:
163
166
  - spec/mangopay/ubo_declaration_spec.rb
164
167
  - spec/mangopay/ubo_spec.rb
165
168
  - spec/mangopay/user_spec.rb
169
+ - spec/mangopay/virtual_account_spec.rb
166
170
  - spec/mangopay/wallet_spec.rb
167
171
  - spec/spec_helper.rb
168
172
  - spec/tmp/.keep
@@ -170,7 +174,7 @@ homepage: http://docs.mangopay.com/
170
174
  licenses:
171
175
  - MIT
172
176
  metadata: {}
173
- post_install_message:
177
+ post_install_message:
174
178
  rdoc_options: []
175
179
  require_paths:
176
180
  - lib
@@ -186,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
190
  version: '0'
187
191
  requirements: []
188
192
  rubygems_version: 3.0.3.1
189
- signing_key:
193
+ signing_key:
190
194
  specification_version: 4
191
195
  summary: Ruby bindings for the version 2 of the MANGOPAY API
192
196
  test_files:
@@ -228,6 +232,8 @@ test_files:
228
232
  - spec/mangopay/payin_paypal_web_spec.rb
229
233
  - spec/mangopay/payin_preauthorized_direct_spec.rb
230
234
  - spec/mangopay/payin_satispay_web_spec.rb
235
+ - spec/mangopay/payin_swish_web_spec.rb
236
+ - spec/mangopay/payin_twint_web_spec.rb
231
237
  - spec/mangopay/payment_method_metadata_spec.rb
232
238
  - spec/mangopay/payout_bankwire_spec.rb
233
239
  - spec/mangopay/preauthorization_spec.rb
@@ -242,6 +248,7 @@ test_files:
242
248
  - spec/mangopay/ubo_declaration_spec.rb
243
249
  - spec/mangopay/ubo_spec.rb
244
250
  - spec/mangopay/user_spec.rb
251
+ - spec/mangopay/virtual_account_spec.rb
245
252
  - spec/mangopay/wallet_spec.rb
246
253
  - spec/spec_helper.rb
247
254
  - spec/tmp/.keep