mangopay 3.23.0 → 3.24.1

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: 3fe8c22cc128558db9e859283f7e723af2e7bc54e1b2b98cb82afc23f03de814
4
- data.tar.gz: 2747bafde96b9a150cdd9505b2348da658d098746ec5fc1d6e5ffd0eafd4637c
3
+ metadata.gz: c227169098718116d4d2473a9e9f5373c5556a89a1bc851b304093fd6e8ff511
4
+ data.tar.gz: b925a267ad094eb69801beafb04904c95852820837d158298d2c8b49506be8fb
5
5
  SHA512:
6
- metadata.gz: f530fd2a85bdeb7ef143048d9ce12f12d2e51a6ddbec4254c316235248add77f52ddf50e890906ca1ea4b0ac43720a397a37e37df5dc8051d5ecc4f5769e801a
7
- data.tar.gz: 8044741c0cbb7650780e340321c8e5035f2ed817b355d22fb0f265e81fb1f5afd411c0df0fa2c8b5ca061fa898213cf593f3409a3c7e0fc5dba727804d3fdbc3
6
+ metadata.gz: 88c78792b4aff5d84ebc7c0687cf11b12f974507e09bec368a28101ca169520e3269353536af528669f37305fc0030c414e61754ea1c8f0fb4c7130b09639efd
7
+ data.tar.gz: c122b794f79e18718d833359d58d0ca6dd4fce57a21195eaae2130a275a0279d138d21939fe02ca754073bfc249f22676212cb7e435553c0cb6a21bfe9edef3a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [3.24.1] - 2024-04-10
2
+ ### Fixed
3
+
4
+ - #249 Improve error handling when logging is enabled
5
+ - #226 MultiJson::ParseError is thrown on HTTP error 5XX
6
+
7
+ ## [3.24.0] - 2024-04-02
8
+ ### Added
9
+
10
+ - New endpoint [Add tracking to Paypal payin](https://mangopay.com/docs/endpoints/paypal#add-tracking-paypal-payin)
11
+
1
12
  ## [3.23.0] - 2024-03-08
2
13
  ### Fixed
3
14
 
@@ -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.23.0'
2
+ VERSION = '3.24.1'
3
3
  end
data/lib/mangopay.rb CHANGED
@@ -214,7 +214,13 @@ module MangoPay
214
214
  raise MangoPay::ResponseError.new(uri, '408', {'Message' => 'Request Timeout'}) if res.nil?
215
215
 
216
216
  # decode json data
217
- data = res.body.to_s.empty? ? {} : JSON.load(res.body.to_s)
217
+ begin
218
+ data = res.body.to_s.empty? ? {} : JSON.load(res.body.to_s)
219
+ rescue MultiJson::ParseError
220
+ details = {}
221
+ details['Message'] = res.body
222
+ raise MangoPay::ResponseError.new(uri, res.code, details)
223
+ end
218
224
 
219
225
  unless res.is_a?(Net::HTTPOK)
220
226
  raise MangoPay::ResponseError.new(uri, res.code, data)
@@ -298,12 +304,17 @@ module MangoPay
298
304
  res
299
305
  ensure
300
306
  line = "#{log_severity(res)} #{line}"
307
+ if time.nil?
308
+ time_log = "[Unknown ms]"
309
+ else
310
+ time_log = "[#{(time * 1000).round(1)}ms]"
311
+ end
301
312
  if res.nil?
302
313
  params = ''
303
- line += "\n [#{(time * 1000).round(1)}ms] 408 Request Timeout #{params}\n"
314
+ line += "\n #{time_log} 408 Request Timeout #{params}\n"
304
315
  else
305
316
  params = FilterParameters.response(res.body)
306
- line += "\n [#{(time * 1000).round(1)}ms] #{res.code} #{params}\n"
317
+ line += "\n #{time_log} #{res.code} #{params}\n"
307
318
  end
308
319
  logger.info { line }
309
320
  end
@@ -6,7 +6,6 @@ describe MangoPay::CardRegistration do
6
6
  it 'creates a new card registration' do
7
7
  created = new_card_registration
8
8
  expect(created['Id']).not_to be_nil
9
- expect(created['Id'].to_i).to be > 0
10
9
  expect(created['AccessKey']).not_to be_nil
11
10
  expect(created['PreregistrationData']).not_to be_nil
12
11
  expect(created['CardRegistrationURL']).not_to be_nil
@@ -51,7 +50,6 @@ describe MangoPay::CardRegistration do
51
50
 
52
51
  # card id filled-in...
53
52
  expect(card_id).not_to be_nil
54
- expect(card_id.to_i).to be > 0
55
53
 
56
54
  # ...and points to existing (newly created) card
57
55
  card = MangoPay::Card.fetch(card_id)
@@ -7,7 +7,6 @@ describe MangoPay::PreAuthorization do
7
7
  cardreg = new_card_registration_completed
8
8
  created = new_card_preauthorization
9
9
  expect(created['Id']).not_to be_nil
10
- expect(created['Id'].to_i).to be > 0
11
10
  expect(created['CardId']).to eq(cardreg['CardId'])
12
11
  expect(created['AuthorId']).to eq(new_natural_user["Id"])
13
12
  expect(created['PayInId']).to be_nil
@@ -144,7 +144,6 @@ describe MangoPay::User do
144
144
  fetched = MangoPay::Card.fetch(card['CardId'])
145
145
 
146
146
  expect(fetched['Id']).not_to be_nil
147
- expect(fetched['Id'].to_i).to be > 0
148
147
  expect(fetched['UserId']).to eq(new_natural_user["Id"])
149
148
  expect(fetched['Currency']).to eq('EUR')
150
149
  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.23.0
4
+ version: 3.24.1
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-03-08 00:00:00.000000000 Z
12
+ date: 2024-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json