mangopay 3.22.0 → 3.24.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: 7321bd891306f53afcbd49ecb871a872f7899d2ee039688392b076ee64c45142
4
+ data.tar.gz: c93e03ce101e31b67def7784e6a1d9490ca4cf5d4254f312f6cda02d32f528ec
5
5
  SHA512:
6
- metadata.gz: 53796ff9758362b4d5e6cf5cf848b14e55928876e15ea78cd4f7105f1731a62344851d786b9103dd4ac1f58976dcfbd8b8b3aac0f16fdec424ccc669c60ffdec
7
- data.tar.gz: 0a17dc77df68459acc86123ba7bd48806fe02fb8c07a5485aeaa8bef323a9998bd77d37e4ed241136774e20eb26054ed2db464fa3f7a678de7f3ea431a63a07e
6
+ metadata.gz: 889df791bf8d890fedbaca69373b91f7f14bb332b9bd2bda09524bfe8d5438c04c0189aea216627c097ccfb1453c1b8f5f4fcb53f6c90d328c04b143e47b75bb
7
+ data.tar.gz: 91c75bf32947a0eb9023d309164a5e416fb80744ca9516da1843b51dff4fdf01b7136c3c3489a3d50aecfa868c735c7f65330eebfe8f1e9ee37cbbaf79ad98de
@@ -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,19 @@
1
+ ## [3.24.0] - 2024-04-02
2
+ ### Added
3
+
4
+ - New endpoint [Add tracking to Paypal payin](https://mangopay.com/docs/endpoints/paypal#add-tracking-paypal-payin)
5
+
6
+ ## [3.23.0] - 2024-03-08
7
+ ### Fixed
8
+
9
+ - Conversions endpoint spelling
10
+
11
+ ### Added
12
+
13
+ - 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).
14
+ - 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).
15
+ - Introduced the `uk_header_flag` boolean configuration key. Platforms partnered with Mangopay's UK entity should set this key to true for proper configuration.
16
+
1
17
  ## [3.22.0] - 2024-02-08
2
18
  ### Added
3
19
 
@@ -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
@@ -21,6 +21,7 @@ module MangoPay
21
21
  # See http://docs.mangopay.com/api-references/payins/payins-card-web/
22
22
  class Web < Resource
23
23
  include HTTPCalls::Create
24
+
24
25
  def self.url(*)
25
26
  "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
26
27
  end
@@ -40,6 +41,7 @@ module MangoPay
40
41
  # See http://docs.mangopay.com/api-references/payins/payindirectcard/
41
42
  class Direct < Resource
42
43
  include HTTPCalls::Create
44
+
43
45
  def self.url(*)
44
46
  "#{MangoPay.api_path}/payins/card/#{CGI.escape(class_name.downcase)}"
45
47
  end
@@ -52,6 +54,7 @@ module MangoPay
52
54
  # See http://docs.mangopay.com/api-references/payins/preauthorized-payin/
53
55
  class Direct < Resource
54
56
  include HTTPCalls::Create
57
+
55
58
  def self.url(*)
56
59
  "#{MangoPay.api_path}/payins/preauthorized/direct"
57
60
  end
@@ -68,6 +71,7 @@ module MangoPay
68
71
  # See http://docs.mangopay.com/api-references/payins/payinbankwire/
69
72
  class Direct < Resource
70
73
  include HTTPCalls::Create
74
+
71
75
  def self.url(*)
72
76
  "#{MangoPay.api_path}/payins/bankwire/direct"
73
77
  end
@@ -83,6 +87,7 @@ module MangoPay
83
87
  # See http://docs.mangopay.com/api-references/payins/direct-debit-pay-in-web/
84
88
  class Web < Resource
85
89
  include HTTPCalls::Create
90
+
86
91
  def self.url(*)
87
92
  "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
88
93
  end
@@ -91,6 +96,7 @@ module MangoPay
91
96
  # See https://docs.mangopay.com/api-references/payins/direct-debit-pay-in-direct/
92
97
  class Direct < Resource
93
98
  include HTTPCalls::Create
99
+
94
100
  def self.url(*)
95
101
  "#{MangoPay.api_path}/payins/directdebit/#{CGI.escape(class_name.downcase)}"
96
102
  end
@@ -105,6 +111,7 @@ module MangoPay
105
111
  # Please use the 'create_v2' function - MangoPay::PayIn::PayPal::Web.create_new(params)
106
112
  class Web < Resource
107
113
  include HTTPCalls::Create
114
+
108
115
  def self.url(*)
109
116
  "#{MangoPay.api_path}/payins/paypal/#{CGI.escape(class_name.downcase)}"
110
117
  end
@@ -112,6 +119,14 @@ module MangoPay
112
119
  def self.create_v2(params, idempotency_key = nil)
113
120
  MangoPay.request(:post, "#{MangoPay.api_path}/payins/payment-methods/paypal", params, {}, idempotency_key)
114
121
  end
122
+
123
+ # Add tracking information to a PayPal PayIn (add the tracking number and carrier for LineItems shipments.)
124
+ # Caution – Tracking information cannot be edited
125
+ # You can’t modify the TrackingNumber, Carrier, or NotifyBuyer once added.
126
+ # You can only send a unique tracking number once.
127
+ def self.add_paypal_tracking_information(pay_in_id, params, idempotency_key = nil)
128
+ MangoPay.request(:put, "#{MangoPay.api_path}/payins/#{pay_in_id}/trackings", params, {}, idempotency_key)
129
+ end
115
130
  end
116
131
 
117
132
  end
@@ -120,6 +135,7 @@ module MangoPay
120
135
 
121
136
  class Web < Resource
122
137
  include HTTPCalls::Create
138
+
123
139
  def self.url(*)
124
140
  "#{MangoPay.api_path}/payins/payconiq/#{CGI.escape(class_name.downcase)}"
125
141
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.22.0'
2
+ VERSION = '3.24.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.24.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-04-02 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