mercadopago-sdk 2.0.2 → 2.0.3

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
- SHA1:
3
- metadata.gz: 1a028d1665b138bef922596f5d780c99111abfc7
4
- data.tar.gz: 27102b30802beabd7e3b4fb30e4121e661c9a8be
2
+ SHA256:
3
+ metadata.gz: b8e6135cb3e0d5f8f0c998dfb10e9df4cf73277c8668f4828f8e5546278e6d2b
4
+ data.tar.gz: 1146f18fff0281cce92e9da15277a526bd3f739fcd456967aa2a3c8de6827bd6
5
5
  SHA512:
6
- metadata.gz: d1f97dca83f4fbafb1e4ed4052517dfd1168be5a03c3f33006f04495c4a838cd093fb4dfd750dcd9e922faeacba085cd5c273677eccd6e395445100e02c72ce3
7
- data.tar.gz: a166429baae7c7aed15ab4fff5acc17fd3197563fd69197f592794d08535da415eb5a409daafc1cab9e9747edc76584c5722aca481e828cb6dc8519395d789aa
6
+ metadata.gz: 0c6420857efa67afe2a7524e0e23a996d7d5805550921321eff0eaac1cf07770b82069ee0b776e642ad3bdba6124c2d44874530832a152b02c8adc9c3d593164
7
+ data.tar.gz: 1507f8d854b70dd1ad8d9be129b245824c6c04f5caf16b9e6b03c96225f8b7d966380c1f3cdfdb1c874b65fbefacc0bfdc9d883012a6c22f10e540d57b0c922b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mercadopago-sdk (2.0.2)
4
+ mercadopago-sdk (2.0.3)
5
5
  json (~> 2.5)
6
6
  rest-client (~> 2.1)
7
7
 
@@ -13,14 +13,14 @@ GEM
13
13
  domain_name (0.5.20190701)
14
14
  unf (>= 0.0.5, < 1.0.0)
15
15
  http-accept (1.7.0)
16
- http-cookie (1.0.3)
16
+ http-cookie (1.0.4)
17
17
  domain_name (~> 0.5)
18
18
  jaro_winkler (1.5.4)
19
- json (2.5.1)
19
+ json (2.6.1)
20
20
  method_source (1.0.0)
21
- mime-types (3.3.1)
21
+ mime-types (3.4.1)
22
22
  mime-types-data (~> 3.2015)
23
- mime-types-data (3.2021.0225)
23
+ mime-types-data (3.2021.1115)
24
24
  minitest (5.14.4)
25
25
  netrc (0.11.0)
26
26
  parallel (1.19.2)
@@ -48,7 +48,7 @@ GEM
48
48
  ruby-progressbar (1.11.0)
49
49
  unf (0.1.4)
50
50
  unf_ext
51
- unf_ext (0.0.7.7)
51
+ unf_ext (0.0.8)
52
52
  unicode-display_width (1.7.0)
53
53
 
54
54
  PLATFORMS
@@ -62,4 +62,4 @@ DEPENDENCIES
62
62
  rubocop
63
63
 
64
64
  BUNDLED WITH
65
- 1.17.0
65
+ 2.2.22
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Mercadopago
5
5
  class Config
6
- @@VERSION = '2.0.2'
6
+ @@VERSION = '2.0.3'
7
7
  @@USER_AGENT = "MercadoPago Ruby SDK v#{@@VERSION}"
8
8
  @@PRODUCT_ID = 'bc32a7vtrpp001u8nhjg'
9
9
  @@TRACKING_ID = "plataform: ?,type:SDK#{@@VERSION},so;"
@@ -35,7 +35,7 @@ module Mercadopago
35
35
  headers['x-integrator-id'] = @integrator_id unless @integrator_id.nil?
36
36
  headers['x-platform-id'] = @platform_id unless @platform_id.nil?
37
37
 
38
- headers.merge(@custom_headers) unless @custom_headers.nil?
38
+ headers.merge!(@custom_headers) unless @custom_headers.nil?
39
39
 
40
40
  headers
41
41
  end
@@ -29,7 +29,7 @@ module Mercadopago
29
29
  end
30
30
 
31
31
  def _check_headers(request_options = nil, extra_headers = nil)
32
- headers = request_options.nil? ? request_options.get_headers : @request_options.get_headers
32
+ headers = request_options.nil? ? @request_options.get_headers : request_options.get_headers
33
33
 
34
34
  headers.merge!(extra_headers) unless extra_headers.nil?
35
35
 
data/mercadopago.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mercadopago-sdk'
5
- gem.version = '2.0.2'
5
+ gem.version = '2.0.3'
6
6
  gem.required_ruby_version = '>= 2.3.0'
7
7
  gem.author = 'Mercado Pago'
8
8
  gem.description = 'Mercado Pago Ruby SDK'
data/tests/test_card.rb CHANGED
@@ -22,7 +22,6 @@ class TestCard < Minitest::Test
22
22
  number: '29804555'
23
23
  },
24
24
  address: {
25
- zip_code: '2300',
26
25
  street_name: 'some street'
27
26
  },
28
27
  description: 'customer description'
@@ -0,0 +1,97 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/mercadopago'
5
+ require 'minitest/autorun'
6
+ require 'securerandom'
7
+
8
+ ##
9
+ # TestRefund
10
+ class TestRefund < Minitest::Test
11
+ def test_method_post_with_custom_headers
12
+ sdk = Mercadopago::SDK.new('TEST-6130770563612470-121314-d27bbd7363e64c3853f058251cf8fc6e-537031659')
13
+ card_token_object = {
14
+ card_number: '5031433215406351',
15
+ expiration_year: 2025,
16
+ expiration_month: 11,
17
+ security_code: '123',
18
+ cardholder: {
19
+ name: 'APRO'
20
+ }
21
+ }
22
+ result_card_token = sdk.card_token.create(card_token_object)
23
+
24
+ payment_object = {
25
+ token: result_card_token[:response]['id'],
26
+ installments: 1,
27
+ transaction_amount: 10,
28
+ description: 'Point Mini a maquininha que dá o dinheiro de suas vendas na hora',
29
+ payment_method_id: 'master',
30
+ payer: {
31
+ email: 'test_user_123456@testuser.com',
32
+ identification: {
33
+ number: '19119119100',
34
+ type: 'CPF'
35
+ }
36
+ },
37
+ notification_url: 'https://www.suaurl.com/notificacoes/',
38
+ binary_mode: false,
39
+ external_reference: 'MP0001',
40
+ statement_descriptor: 'MercadoPago',
41
+ additional_info: {
42
+ items: [
43
+ {
44
+ id: 'PR0001',
45
+ title: 'Point Mini',
46
+ description: 'Producto Point para cobros con tarjetas mediante bluetooth',
47
+ picture_url: 'https://http2.mlstatic.com/resources/frontend/statics/growth-sellers-landings/device-mlb-point-i_medium@2x.png',
48
+ category_id: 'electronics',
49
+ quantity: 1,
50
+ unit_price: 58.80
51
+ }
52
+ ],
53
+ payer: {
54
+ first_name: 'Nome',
55
+ last_name: 'Sobrenome',
56
+ address: {
57
+ zip_code: '06233-200',
58
+ street_name: 'Av das Nacoes Unidas',
59
+ street_number: 3003
60
+ },
61
+ registration_date: '2019-01-01T12:01:01.000-03:00',
62
+ phone: {
63
+ area_code: '011',
64
+ number: '987654321'
65
+ }
66
+ },
67
+ shipments: {
68
+ receiver_address: {
69
+ street_name: 'Av das Nacoes Unidas',
70
+ street_number: 3003,
71
+ zip_code: '06233200',
72
+ city_name: 'Buzios',
73
+ state_name: 'Rio de Janeiro'
74
+ }
75
+ }
76
+ }
77
+ }
78
+ result_payment = sdk.payment.create(payment_object)
79
+ payment_id = result_payment[:response]['id']
80
+ refund_data = {
81
+ 'amount': 2.95
82
+ }
83
+ uuid = SecureRandom.uuid
84
+ custom_headers = {
85
+ 'x-idempotency-key': uuid
86
+ }
87
+ custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers)
88
+ result = sdk.refund.create(payment_id, refund_data: refund_data, request_options: custom_request_options)
89
+ assert_equal 201, result[:status]
90
+ assert_equal 'approved', result[:response]['status']
91
+
92
+ # calling a request with an existing 'x-idempotency-key', the API should return 200,
93
+ # instead of create other refund
94
+ result = sdk.refund.create(payment_id, refund_data: refund_data, request_options: custom_request_options)
95
+ assert_equal 200, result[:status]
96
+ end
97
+ end
data/tests/tests.rb CHANGED
@@ -8,5 +8,6 @@ require_relative './test_merchant_order'
8
8
  require_relative './test_payment_methods'
9
9
  require_relative './test_payment'
10
10
  require_relative './test_preference'
11
+ require_relative './test_refund_with_custom_headers'
11
12
  require_relative './test_refund'
12
13
  require_relative './test_user'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadopago-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mercado Pago
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-29 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -183,6 +183,7 @@ files:
183
183
  - tests/test_payment_methods.rb
184
184
  - tests/test_preference.rb
185
185
  - tests/test_refund.rb
186
+ - tests/test_refund_with_custom_headers.rb
186
187
  - tests/test_user.rb
187
188
  - tests/tests.rb
188
189
  homepage: http://github.com/mercadopago/sdk-ruby
@@ -204,8 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
205
  - !ruby/object:Gem::Version
205
206
  version: '0'
206
207
  requirements: []
207
- rubyforge_project:
208
- rubygems_version: 2.5.1
208
+ rubygems_version: 3.2.22
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Mercado Pago Ruby SDK
@@ -219,5 +219,6 @@ test_files:
219
219
  - tests/test_payment_methods.rb
220
220
  - tests/test_preference.rb
221
221
  - tests/test_refund.rb
222
+ - tests/test_refund_with_custom_headers.rb
222
223
  - tests/test_user.rb
223
224
  - tests/tests.rb