mangopay 3.22.0 → 3.23.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: d92bb15f455816281326eca83963d639590bcb68580848ff6c4589cee926a0a9
4
- data.tar.gz: 4162a17a66cfa34730c0ed90d27fecb375654d3e4175a82431863ec64e25e57c
3
+ metadata.gz: 3fe8c22cc128558db9e859283f7e723af2e7bc54e1b2b98cb82afc23f03de814
4
+ data.tar.gz: 2747bafde96b9a150cdd9505b2348da658d098746ec5fc1d6e5ffd0eafd4637c
5
5
  SHA512:
6
- metadata.gz: 53796ff9758362b4d5e6cf5cf848b14e55928876e15ea78cd4f7105f1731a62344851d786b9103dd4ac1f58976dcfbd8b8b3aac0f16fdec424ccc669c60ffdec
7
- data.tar.gz: 0a17dc77df68459acc86123ba7bd48806fe02fb8c07a5485aeaa8bef323a9998bd77d37e4ed241136774e20eb26054ed2db464fa3f7a678de7f3ea431a63a07e
6
+ metadata.gz: f530fd2a85bdeb7ef143048d9ce12f12d2e51a6ddbec4254c316235248add77f52ddf50e890906ca1ea4b0ac43720a397a37e37df5dc8051d5ecc4f5769e801a
7
+ data.tar.gz: 8044741c0cbb7650780e340321c8e5035f2ed817b355d22fb0f265e81fb1f5afd411c0df0fa2c8b5ca061fa898213cf593f3409a3c7e0fc5dba727804d3fdbc3
@@ -5,10 +5,6 @@ on:
5
5
  branches:
6
6
  # push on master branch
7
7
  - master
8
- # push on a feature branch
9
- - feature/*
10
- # push on a bugfix branch
11
- - bugfix/*
12
8
  pull_request:
13
9
  branches: [ master ]
14
10
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [3.23.0] - 2024-03-08
2
+ ### Fixed
3
+
4
+ - Conversions endpoint spelling
5
+
6
+ ### Added
7
+
8
+ - The optional Fees parameter is now available on instant conversions, allowing platforms to charge users for FX services. More information [here](https://mangopay.com/docs/release-notes/millefeuille).
9
+ - Platforms can now use a quote to secure the rate for a conversion between two currencies for a set amount of time. More information [here](https://mangopay.com/docs/release-notes/millefeuille).
10
+ - Introduced the `uk_header_flag` boolean configuration key. Platforms partnered with Mangopay's UK entity should set this key to true for proper configuration.
11
+
1
12
  ## [3.22.0] - 2024-02-08
2
13
  ### Added
3
14
 
@@ -73,7 +73,7 @@ module MangoPay
73
73
  end
74
74
 
75
75
  def store(token)
76
- File.open(file_path, File::RDWR|File::CREAT, 0644) do |f|
76
+ File.open(file_path, File::RDWR | File::CREAT, 0644) do |f|
77
77
  f.flock(File::LOCK_EX)
78
78
  f.truncate(0)
79
79
  f.rewind
@@ -0,0 +1,39 @@
1
+ module MangoPay
2
+
3
+ class Conversion < Resource
4
+ include HTTPCalls::Fetch
5
+ include HTTPCalls::Update
6
+
7
+ class << self
8
+ def get_rate(debited_currency, credited_currency, params)
9
+ url = "#{MangoPay.api_path}/conversions/rate/#{debited_currency}/#{credited_currency}"
10
+ MangoPay.request(:get, url, params)
11
+ end
12
+
13
+ def create_instant_conversion(params)
14
+ url = "#{MangoPay.api_path}/conversions/instant-conversion"
15
+ MangoPay.request(:post, url, params)
16
+ end
17
+
18
+ def create_quoted_conversion(params)
19
+ url = "#{MangoPay.api_path}/conversions/quoted-conversion"
20
+ MangoPay.request(:post, url, params)
21
+ end
22
+
23
+ def get(id, params)
24
+ url = "#{MangoPay.api_path}/conversions/#{id}"
25
+ MangoPay.request(:get, url, params)
26
+ end
27
+
28
+ def create_quote(params)
29
+ url = "#{MangoPay.api_path}/conversions/quote"
30
+ MangoPay.request(:post, url, params)
31
+ end
32
+
33
+ def get_quote(id, params)
34
+ url = "#{MangoPay.api_path}/conversions/quote/#{id}"
35
+ MangoPay.request(:get, url, params)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.22.0'
2
+ VERSION = '3.23.0'
3
3
  end
data/lib/mangopay.rb CHANGED
@@ -44,7 +44,7 @@ module MangoPay
44
44
  autoload :Ubo, 'mangopay/ubo'
45
45
  autoload :Regulatory, 'mangopay/regulatory'
46
46
  autoload :Deposit, 'mangopay/deposit'
47
- autoload :InstantConversion, 'mangopay/instant_conversion'
47
+ autoload :Conversion, 'mangopay/conversion'
48
48
  autoload :PaymentMethodMetadata, 'mangopay/payment_method_metadata'
49
49
 
50
50
  # temporary
@@ -57,7 +57,7 @@ module MangoPay
57
57
  :client_id, :client_apiKey,
58
58
  :temp_dir, :log_file, :http_timeout,
59
59
  :http_max_retries, :http_open_timeout,
60
- :logger, :use_ssl
60
+ :logger, :use_ssl, :uk_header_flag
61
61
 
62
62
  def apply_configuration
63
63
  MangoPay.configure do |config|
@@ -70,6 +70,7 @@ module MangoPay
70
70
  config.http_open_timeout = @http_open_timeout
71
71
  config.use_ssl = @use_ssl
72
72
  config.logger = @logger
73
+ config.uk_header_flag = @uk_header_flag
73
74
  end
74
75
  end
75
76
 
@@ -100,6 +101,10 @@ module MangoPay
100
101
 
101
102
  true
102
103
  end
104
+
105
+ def uk_header_flag
106
+ @uk_header_flag || false
107
+ end
103
108
  end
104
109
 
105
110
  class << self
@@ -193,6 +198,10 @@ module MangoPay
193
198
  headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
194
199
  end
195
200
 
201
+ if configuration.uk_header_flag
202
+ headers['x-tenant-id'] = 'uk'
203
+ end
204
+
196
205
  res = Net::HTTP.start(uri.host, uri.port, :use_ssl => configuration.use_ssl?, :read_timeout => configuration.http_timeout,
197
206
  :max_retries => configuration.http_max_retries,
198
207
  :open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
@@ -0,0 +1,64 @@
1
+ describe MangoPay::Conversion, type: :feature do
2
+ include_context 'instant_conversion'
3
+
4
+ describe 'GET CONVERSION RATE' do
5
+ it 'get a conversion rate' do
6
+ conversion_rate = get_conversion_rate('EUR','GBP')
7
+
8
+ expect(conversion_rate['ClientRate']).not_to be_nil
9
+ expect(conversion_rate['MarketRate']).not_to be_nil
10
+ end
11
+ end
12
+
13
+ describe 'CREATE INSTANT CONVERSION' do
14
+ it 'creates a new instant conversion' do
15
+ conversion = create_instant_conversion
16
+
17
+ expect(conversion['DebitedFunds']['Amount']).not_to be_nil
18
+ expect(conversion['CreditedFunds']['Amount']).not_to be_nil
19
+ expect(conversion['Fees']['Amount']).not_to be_nil
20
+ expect(conversion['Status']).equal? 'SUCCEEDED'
21
+ end
22
+ end
23
+
24
+ describe 'CREATE QUOTED CONVERSION' do
25
+ it 'creates a new quoted conversion' do
26
+ conversion = create_quoted_conversion
27
+
28
+ expect(conversion['DebitedFunds']['Amount']).not_to be_nil
29
+ expect(conversion['CreditedFunds']['Amount']).not_to be_nil
30
+ expect(conversion['Status']).equal? 'SUCCEEDED'
31
+ end
32
+ end
33
+
34
+ describe 'GET EXISTING CONVERSION' do
35
+ it 'get an existing conversion' do
36
+ conversion = create_instant_conversion
37
+ returned_conversion = get_conversion(conversion['Id'])
38
+
39
+ expect(returned_conversion['DebitedFunds']['Amount']).not_to be_nil
40
+ expect(returned_conversion['CreditedFunds']['Amount']).not_to be_nil
41
+ expect(conversion['Fees']['Amount']).not_to be_nil
42
+ expect(returned_conversion['Status']).equal? 'SUCCEEDED'
43
+ end
44
+ end
45
+
46
+ describe 'CREATE CONVERSION QUOTE' do
47
+ it 'create a conversion quote' do
48
+ conversion_quote = create_conversion_quote
49
+ expect(conversion_quote['DebitedFunds']).not_to be_nil
50
+ expect(conversion_quote['CreditedFunds']).not_to be_nil
51
+ expect(conversion_quote['Duration']).equal? 90
52
+ end
53
+ end
54
+
55
+ describe 'GET CONVERSION QUOTE' do
56
+ it 'get a conversion quote' do
57
+ conversion_quote = create_conversion_quote
58
+ returned_conversion_quote = get_conversion_quote(conversion_quote['Id'])
59
+ expect(returned_conversion_quote['DebitedFunds']).not_to be_nil
60
+ expect(returned_conversion_quote['CreditedFunds']).not_to be_nil
61
+ expect(returned_conversion_quote['Duration']).equal? 90
62
+ end
63
+ end
64
+ end
@@ -898,7 +898,7 @@ shared_context 'instant_conversion' do
898
898
  include_context 'payins'
899
899
 
900
900
  def get_conversion_rate(debited_currency, credited_currency)
901
- MangoPay::InstantConversion.get_rate(debited_currency, credited_currency, params = {})
901
+ MangoPay::Conversion.get_rate(debited_currency, credited_currency, params = {})
902
902
  end
903
903
 
904
904
  def create_instant_conversion()
@@ -910,7 +910,7 @@ shared_context 'instant_conversion' do
910
910
  Tag: 'Test wallet'
911
911
  )
912
912
 
913
- MangoPay::InstantConversion.create(
913
+ MangoPay::Conversion.create_instant_conversion(
914
914
  AuthorId: user['Id'],
915
915
  CreditedWalletId: credited_wallet['Id'],
916
916
  DebitedWalletId: new_wallet_with_money['Id'],
@@ -921,12 +921,48 @@ shared_context 'instant_conversion' do
921
921
  Currency: 'EUR',
922
922
  Amount: 79
923
923
  },
924
+ Fees: {
925
+ Currency: 'EUR',
926
+ Amount: 9
927
+ },
924
928
  Tag: 'Instant conversion test'
925
929
  )
926
930
  end
927
931
 
928
- def get_instant_conversion(id)
929
- MangoPay::InstantConversion.get(id, params = {})
932
+ def create_quoted_conversion()
933
+ user = new_natural_user
934
+ credited_wallet = MangoPay::Wallet.create(
935
+ Owners: [user['Id']],
936
+ Description: 'A test wallet',
937
+ Currency: 'GBP',
938
+ Tag: 'Test wallet'
939
+ )
940
+ quote = create_conversion_quote
941
+
942
+ MangoPay::Conversion.create_quoted_conversion(
943
+ AuthorId: user['Id'],
944
+ QuoteId: quote['Id'],
945
+ CreditedWalletId: credited_wallet['Id'],
946
+ DebitedWalletId: new_wallet_with_money['Id'],
947
+ Tag: 'Quoted conversion test'
948
+ )
949
+ end
950
+
951
+ def create_conversion_quote
952
+ MangoPay::Conversion.create_quote(
953
+ CreditedFunds: { Currency: 'GBP' },
954
+ DebitedFunds: { Currency: 'EUR', Amount: 50 },
955
+ Duration: 90,
956
+ Tag: 'Created using the Mangopay Ruby SDK'
957
+ )
958
+ end
959
+
960
+ def get_conversion(id)
961
+ MangoPay::Conversion.get(id, params = {})
962
+ end
963
+
964
+ def get_conversion_quote(id)
965
+ MangoPay::Conversion.get_quote(id, params = {})
930
966
  end
931
967
  end
932
968
 
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.22.0
4
+ version: 3.23.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: 2024-02-08 00:00:00.000000000 Z
12
+ date: 2024-03-08 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/conversion.rb
85
86
  - lib/mangopay/deposit.rb
86
87
  - lib/mangopay/dispute.rb
87
88
  - lib/mangopay/errors.rb
@@ -89,7 +90,6 @@ files:
89
90
  - lib/mangopay/filter_parameters.rb
90
91
  - lib/mangopay/hook.rb
91
92
  - lib/mangopay/http_calls.rb
92
- - lib/mangopay/instant_conversion.rb
93
93
  - lib/mangopay/json.rb
94
94
  - lib/mangopay/kyc_document.rb
95
95
  - lib/mangopay/legal_user.rb
@@ -118,6 +118,7 @@ files:
118
118
  - spec/mangopay/client_spec.png
119
119
  - spec/mangopay/client_spec.rb
120
120
  - spec/mangopay/configuration_spec.rb
121
+ - spec/mangopay/conversion_spec.rb
121
122
  - spec/mangopay/deposit_spec.rb
122
123
  - spec/mangopay/dispute_spec.png
123
124
  - spec/mangopay/dispute_spec.rb
@@ -125,7 +126,6 @@ files:
125
126
  - spec/mangopay/fetch_filters_spec.rb
126
127
  - spec/mangopay/hook_spec.rb
127
128
  - spec/mangopay/idempotency_spec.rb
128
- - spec/mangopay/instant_conversion_spec.rb
129
129
  - spec/mangopay/kyc_document_spec.png
130
130
  - spec/mangopay/kyc_document_spec.rb
131
131
  - spec/mangopay/log_requests_filter_spec.rb
@@ -196,6 +196,7 @@ test_files:
196
196
  - spec/mangopay/client_spec.png
197
197
  - spec/mangopay/client_spec.rb
198
198
  - spec/mangopay/configuration_spec.rb
199
+ - spec/mangopay/conversion_spec.rb
199
200
  - spec/mangopay/deposit_spec.rb
200
201
  - spec/mangopay/dispute_spec.png
201
202
  - spec/mangopay/dispute_spec.rb
@@ -203,7 +204,6 @@ test_files:
203
204
  - spec/mangopay/fetch_filters_spec.rb
204
205
  - spec/mangopay/hook_spec.rb
205
206
  - spec/mangopay/idempotency_spec.rb
206
- - spec/mangopay/instant_conversion_spec.rb
207
207
  - spec/mangopay/kyc_document_spec.png
208
208
  - spec/mangopay/kyc_document_spec.rb
209
209
  - spec/mangopay/log_requests_filter_spec.rb
@@ -1,24 +0,0 @@
1
- module MangoPay
2
-
3
- class InstantConversion < Resource
4
- include HTTPCalls::Fetch
5
- include HTTPCalls::Update
6
-
7
- class << self
8
- def get_rate(debited_currency, credited_currency, params)
9
- url = "#{MangoPay.api_path}/conversion/rate/#{debited_currency}/#{credited_currency}"
10
- MangoPay.request(:get, url, params)
11
- end
12
-
13
- def create(params)
14
- url = "#{MangoPay.api_path}/instant-conversion"
15
- MangoPay.request(:post, url, params)
16
- end
17
-
18
- def get(id, params)
19
- url = "#{MangoPay.api_path}/instant-conversion/#{id}"
20
- MangoPay.request(:get, url, params)
21
- end
22
- end
23
- end
24
- end
@@ -1,33 +0,0 @@
1
- describe MangoPay::InstantConversion, type: :feature do
2
- include_context 'instant_conversion'
3
-
4
- describe 'GET CONVERSION RATE' do
5
- it 'get a conversion rate' do
6
- conversion_rate = get_conversion_rate('EUR','GBP')
7
-
8
- expect(conversion_rate['ClientRate']).not_to be_nil
9
- expect(conversion_rate['MarketRate']).not_to be_nil
10
- end
11
- end
12
-
13
- describe 'CREATE CONVERSION' do
14
- it 'creates a new conversion' do
15
- conversion = create_instant_conversion
16
-
17
- expect(conversion['DebitedFunds']['Amount']).not_to be_nil
18
- expect(conversion['CreditedFunds']['Amount']).not_to be_nil
19
- expect(conversion['Status']).equal? 'SUCCEEDED'
20
- end
21
- end
22
-
23
- describe 'GET EXISTING CONVERSION' do
24
- it 'get an existing conversion' do
25
- conversion = create_instant_conversion
26
- returned_conversion = get_instant_conversion(conversion['Id'])
27
-
28
- expect(returned_conversion['DebitedFunds']['Amount']).not_to be_nil
29
- expect(returned_conversion['CreditedFunds']['Amount']).not_to be_nil
30
- expect(returned_conversion['Status']).equal? 'SUCCEEDED'
31
- end
32
- end
33
- end