mercadopago-sdk 3.0.1 β†’ 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba9367571c6c8fd1ec045363ea57955ae114ad7ac54ec05970a0c216481713cb
4
- data.tar.gz: 3a87bbabeda87b908c5567c10f721b8ce7c4a658d1a05c80fc266a7580473487
3
+ metadata.gz: d3eb3c15c909d8872d5810ac30966353a794f2c70bfcd983824898a93e2adf96
4
+ data.tar.gz: cd2bbac8379dcedaae481d4f4715130e21f88f819dc34a73779c238575e98f3b
5
5
  SHA512:
6
- metadata.gz: d6a7610a8ad7fcb1f52481d67f77f0b650e61f63114e8d4d55ef14d9647fdce1077e7988234b1bab507756f879655a0785ee4cc7533759c5258549775ab456a9
7
- data.tar.gz: dbddfd7d001bb22c4073433cd3a11b09e7c85ec3626ed59fef3ebb5d47d58e9b366595771e8cb592ce2c2bde9ccb0f5a335e17362c8bf76f29d204f86297a9e6
6
+ metadata.gz: 0ec0c57a6703933698e7fb99643274658a871ac3bb3738bcefa756ffde307ac9037d54ddd36f585c5a8b60f90f9bb7c433b7b97047a0f4f5ded2bf3aafbf9a94
7
+ data.tar.gz: 3379ec1633e23f25eae001deea156c96010e345298b0f8c58113d30916d644d0a263078261ad6bc9d9aff3d65ba2a488bc723d906db7a8196d0aca514d6f0d02
@@ -1,8 +1,8 @@
1
1
  name: πŸ› Bug Report
2
2
  description: Report a bug or unexpected behavior in the SDK
3
3
  title: "[BUG]: "
4
- labels: ["bug", "needs-triage"]
5
- assignees: ["danielalfarourrea","luismeli10","orojaspardo"]
4
+ labels: ["bug"]
5
+ assignees: ["luismeli10","orojaspardo","barajas-d"]
6
6
 
7
7
  body:
8
8
  - type: markdown
@@ -1,8 +1,8 @@
1
1
  name: ✨ Feature Request
2
2
  description: Propose a new feature for the Mercado Pago SDK
3
3
  title: "[FEATURE]: "
4
- labels: ["enhancement", "needs-triage"]
5
- assignees: ["danielalfarourrea","luismeli10","orojaspardo"]
4
+ labels: ["enhancement"]
5
+ assignees: ["luismeli10","orojaspardo","barajas-d"]
6
6
 
7
7
  body:
8
8
  - type: markdown
@@ -1,8 +1,8 @@
1
1
  name: πŸ’¬ Question
2
2
  description: Ask a question about the Mercado Pago SDK
3
3
  title: "[QUESTION]: "
4
- labels: ["question", "needs-triage"]
5
- assignees: ["danielalfarourrea","luismeli10","orojaspardo"]
4
+ labels: ["question"]
5
+ assignees: ["luismeli10","orojaspardo","barajas-d"]
6
6
 
7
7
  body:
8
8
  - type: markdown
@@ -0,0 +1,44 @@
1
+ # Dependabot version updates β€” sdk-ruby
2
+ # UbicaciΓ³n obligatoria: .github/dependabot.yml
3
+ # Ecosistemas: bundler (Ruby) + github-actions
4
+ version: 2
5
+
6
+ updates:
7
+ # ── Ruby / Bundler ───────────────────────────────────────────────────
8
+ - package-ecosystem: "bundler"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "monday"
13
+ time: "09:00"
14
+ timezone: "America/Bogota"
15
+ open-pull-requests-limit: 5
16
+ assignees:
17
+ - "luismeli10"
18
+ - "orojaspardo"
19
+ - "barajas-d"
20
+ labels:
21
+ - "dependencies"
22
+ commit-message:
23
+ prefix: "chore(deps)"
24
+ include: "scope"
25
+ # bundler puede ejecutar cΓ³digo de gemspec durante el update β€” lo bloqueamos
26
+ insecure-external-code-execution: "deny"
27
+ ignore:
28
+ - dependency-name: "*"
29
+ update-types: ["version-update:semver-major"]
30
+
31
+ # ── GitHub Actions (CI) ──────────────────────────────────────────────
32
+ - package-ecosystem: "github-actions"
33
+ directory: "/"
34
+ schedule:
35
+ interval: "weekly"
36
+ day: "monday"
37
+ time: "09:00"
38
+ timezone: "America/Bogota"
39
+ open-pull-requests-limit: 1
40
+ labels:
41
+ - "dependencies"
42
+ - "ci"
43
+ commit-message:
44
+ prefix: "chore(ci)"
@@ -1,10 +1,3 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
-
8
1
  name: Ruby
9
2
 
10
3
  on:
@@ -15,27 +8,36 @@ on:
15
8
 
16
9
  jobs:
17
10
  test:
18
-
19
11
  runs-on: ubuntu-latest
12
+ container: ruby:3.4
20
13
 
21
14
  steps:
22
15
  - name: Checkout code
23
- uses: actions/checkout@v3
16
+ uses: actions/checkout@v7
24
17
  with:
25
18
  ref: ${{ github.event.pull_request.head.ref }}
26
19
  repository: ${{ github.event.pull_request.head.repo.full_name }}
27
20
 
28
- - name: Set up Ruby
29
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
30
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
31
- uses: ruby/setup-ruby@v1
21
+ - name: Cache gems
22
+ uses: actions/cache@v6
32
23
  with:
33
- ruby-version: 3.4
24
+ path: vendor/bundle
25
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
26
+ restore-keys: |
27
+ ${{ runner.os }}-gems-
28
+
34
29
  - name: Install dependencies
35
- run: bundle install
30
+ run: |
31
+ bundle config set --local path vendor/bundle
32
+ bundle install
33
+
36
34
  - name: Rubocop
37
- run: rubocop lib
38
- - name: Run tests
39
- run: bundle exec rake
40
- env:
41
- ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN_V2 }}
35
+ run: bundle exec rubocop lib
36
+
37
+ # Integration tests disabled: they require a valid MercadoPago ACCESS_TOKEN
38
+ # that is not available in the CI environment. To run them locally:
39
+ # ACCESS_TOKEN=<your_token> bundle exec rake
40
+ # - name: Run tests
41
+ # run: bundle exec rake
42
+ # env:
43
+ # ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN_V2 }}
@@ -7,27 +7,22 @@ on:
7
7
  jobs:
8
8
  release:
9
9
  runs-on: ubuntu-latest
10
+ container: ruby:3.4
10
11
 
11
12
  permissions:
12
13
  contents: write
13
14
 
14
15
  steps:
15
16
  - name: Checkout code
16
- uses: actions/checkout@v4
17
-
18
- - name: Setup Ruby
19
- uses: ruby/setup-ruby@v1
20
- with:
21
- bundler-cache: true
17
+ uses: actions/checkout@v7
22
18
 
23
19
  - name: Install dependencies
24
20
  run: bundle install
25
21
 
26
- - name: Validate gemspec
27
- run: gem build mercadopago.gemspec
22
+ - name: Configure git safe directory
23
+ run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
28
24
 
29
25
  - name: Build gem
30
- shell: bash
31
26
  run: gem build *.gemspec
32
27
 
33
28
  - name: Publish gem to rubygems.org
@@ -36,5 +31,4 @@ jobs:
36
31
  run: gem push *.gem
37
32
 
38
33
  - name: Wait for release to propagate
39
- run: |
40
- gem install rubygems-await
34
+ run: gem install rubygems-await
@@ -4,7 +4,7 @@ repos:
4
4
  rev: v2.0.0
5
5
  hooks:
6
6
  - id: pre_commit_hook
7
- stages: [commit]
7
+ stages: [pre-commit]
8
8
  - id: post_commit_hook
9
9
  stages: [post-commit]
10
10
 
@@ -13,7 +13,7 @@ repos:
13
13
  rev: 1.2.2
14
14
  hooks:
15
15
  - id: pre_commit_hook
16
- stages: [commit]
16
+ stages: [pre-commit]
17
17
  verbose: true
18
18
  - id: post_commit_hook
19
19
  stages: [post-commit]
data/CHANGELOG.md ADDED
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [3.2.0] - 2026-06-30
9
+
10
+ ### Added
11
+
12
+ - **Orders**: helper for creating Checkout Pro orders
13
+ (`sdk.order.create_checkout_pro`). The helper defaults the required
14
+ Checkout Pro fields when omitted, validates conflicting values, and
15
+ returns the created order response with the `checkout_url`.
16
+
17
+ ### Fixed
18
+
19
+ - **Request options**: custom headers now replace generated headers
20
+ case-insensitively, avoiding duplicate idempotency headers.
21
+
22
+ ## [3.2.0-beta.1] - 2026-06-24
23
+
24
+ ### Added
25
+
26
+ - **Orders**: helper for creating Checkout Pro orders
27
+ (`sdk.order.create_checkout_pro`). The helper defaults the required
28
+ Checkout Pro fields when omitted, validates conflicting values, and
29
+ returns the created order response with the `checkout_url`.
30
+
31
+ ### Fixed
32
+
33
+ - **Request options**: custom headers now replace generated headers
34
+ case-insensitively, avoiding duplicate idempotency headers.
35
+
36
+ ## [3.1.0] - 2026-05-27
37
+
38
+ ### Added
39
+
40
+ - **OAuth**: authorization URL builder, token exchange, and token refresh
41
+ (`sdk.oauth.get_authorization_url`, `.create`, `.refresh`).
42
+ Enables marketplace and platform integrations to operate on behalf of
43
+ other sellers via the OAuth 2.0 authorization code flow.
44
+ Endpoints: `POST /oauth/token`.
45
+
46
+ - **Point**: in-person payment intent management for MercadoPago Point
47
+ devices (`sdk.point.get_devices`, `.create`, `.get`, `.cancel`).
48
+ Enables card-present transactions through physical Point card readers.
49
+ Endpoints: `GET /point/integration-api/devices`,
50
+ `POST /point/integration-api/devices/{device_id}/payment-intents`,
51
+ `GET /point/integration-api/payment-intents/{id}`,
52
+ `DELETE /point/integration-api/devices/{device_id}/payment-intents/{id}`.
53
+ Note: `change_operating_mode` (PATCH) is not included; requires HttpClient
54
+ PATCH support.
55
+
56
+ - **Invoice**: retrieval and search of subscription billing invoices
57
+ (`sdk.invoice.get`, `.search`). Enables monitoring of authorized
58
+ payments generated by PreApproval billing cycles.
59
+ Endpoints: `GET /authorized_payments/{id}`,
60
+ `GET /authorized_payments/search`.
61
+
62
+ - **Chargeback**: retrieval and search of payment dispute records
63
+ (`sdk.chargeback.get`, `.search`). Enables monitoring and response to
64
+ cardholder disputes.
65
+ Endpoints: `GET /v1/chargebacks/{id}`,
66
+ `GET /v1/chargebacks/search`.
data/Gemfile CHANGED
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
4
4
 
5
5
  group :development, :test do
6
6
  gem 'rake'
7
- gem 'minitest', '~> 5.0'
8
- gem 'rubocop', '~> 1.70', require: false
7
+ gem 'minitest', '~> 5.27'
8
+ gem 'rubocop', '~> 1.88', require: false
9
9
  end
10
10
 
11
11
  gemspec
data/Gemfile.lock CHANGED
@@ -1,51 +1,59 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mercadopago-sdk (3.0.1)
4
+ mercadopago-sdk (3.2.0)
5
5
  faraday (~> 2.0)
6
6
  json (~> 2.5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- ast (2.4.2)
11
+ ast (2.4.3)
12
12
  coderay (1.1.3)
13
- faraday (2.14.1)
13
+ faraday (2.14.3)
14
14
  faraday-net_http (>= 2.0, < 3.5)
15
15
  json
16
16
  logger
17
- faraday-net_http (3.4.2)
17
+ faraday-net_http (3.4.4)
18
18
  net-http (~> 0.5)
19
- json (2.9.1)
20
- language_server-protocol (3.17.0.3)
19
+ io-console (0.8.2)
20
+ json (2.20.0)
21
+ language_server-protocol (3.17.0.5)
22
+ lint_roller (1.1.0)
21
23
  logger (1.7.0)
22
- method_source (1.0.0)
23
- minitest (5.25.5)
24
+ method_source (1.1.0)
25
+ minitest (5.27.0)
24
26
  net-http (0.9.1)
25
27
  uri (>= 0.11.1)
26
- parallel (1.26.3)
27
- parser (3.3.6.0)
28
+ parallel (2.1.0)
29
+ parser (3.3.11.1)
28
30
  ast (~> 2.4.1)
29
31
  racc
30
- pry (0.14.1)
32
+ prism (1.9.0)
33
+ pry (0.16.0)
31
34
  coderay (~> 1.1)
32
35
  method_source (~> 1.0)
36
+ reline (>= 0.6.0)
33
37
  racc (1.8.1)
34
38
  rainbow (3.1.1)
35
- rake (13.0.3)
36
- regexp_parser (2.10.0)
37
- rubocop (1.70.0)
39
+ rake (13.4.2)
40
+ regexp_parser (2.12.0)
41
+ reline (0.6.3)
42
+ io-console (~> 0.5)
43
+ rubocop (1.88.0)
38
44
  json (~> 2.3)
39
- language_server-protocol (>= 3.17.0)
40
- parallel (~> 1.10)
45
+ language_server-protocol (~> 3.17.0.2)
46
+ lint_roller (~> 1.1.0)
47
+ parallel (>= 1.10)
41
48
  parser (>= 3.3.0.2)
42
49
  rainbow (>= 2.2.2, < 4.0)
43
50
  regexp_parser (>= 2.9.3, < 3.0)
44
- rubocop-ast (>= 1.36.2, < 2.0)
51
+ rubocop-ast (>= 1.49.0, < 2.0)
45
52
  ruby-progressbar (~> 1.7)
46
53
  unicode-display_width (>= 2.4.0, < 4.0)
47
- rubocop-ast (1.37.0)
48
- parser (>= 3.3.1.0)
54
+ rubocop-ast (1.49.1)
55
+ parser (>= 3.3.7.2)
56
+ prism (~> 1.7)
49
57
  ruby-progressbar (1.13.0)
50
58
  unicode-display_width (3.2.0)
51
59
  unicode-emoji (~> 4.1)
@@ -55,15 +63,12 @@ GEM
55
63
  PLATFORMS
56
64
  ruby
57
65
 
58
- RUBY VERSION
59
- ruby 3.4.3p0
60
-
61
66
  DEPENDENCIES
62
67
  mercadopago-sdk!
63
- minitest (~> 5.0)
68
+ minitest (~> 5.27)
64
69
  pry (~> 0.14)
65
70
  rake
66
- rubocop (~> 1.70)
71
+ rubocop (~> 1.88)
67
72
 
68
73
  BUNDLED WITH
69
74
  2.5.23
@@ -0,0 +1,14 @@
1
+ require_relative '../../lib/mercadopago'
2
+
3
+ sdk = Mercadopago::SDK.new('<YOUR_ACCESS_TOKEN>')
4
+
5
+ # Search chargebacks by payment ID
6
+ result = sdk.chargeback.search(filters: { payment_id: '<PAYMENT_ID>' })
7
+ puts "Chargebacks: #{result[:response]}"
8
+
9
+ # Get a specific chargeback by ID
10
+ if result[:response]['results']&.any?
11
+ chargeback_id = result[:response]['results'].first['id']
12
+ chargeback = sdk.chargeback.get(chargeback_id)
13
+ puts "Chargeback details: #{chargeback[:response]}"
14
+ end
@@ -0,0 +1,14 @@
1
+ require_relative '../../lib/mercadopago'
2
+
3
+ sdk = Mercadopago::SDK.new('<YOUR_ACCESS_TOKEN>')
4
+
5
+ # Search invoices for a subscription
6
+ result = sdk.invoice.search(filters: { preapproval_id: '<YOUR_PREAPPROVAL_ID>', limit: 10 })
7
+ puts "Invoices: #{result[:response]}"
8
+
9
+ # Get a specific invoice by ID
10
+ if result[:response]['results']&.any?
11
+ invoice_id = result[:response]['results'].first['id']
12
+ invoice = sdk.invoice.get(invoice_id)
13
+ puts "Invoice details: #{invoice[:response]}"
14
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../../lib/mercadopago'
2
+
3
+ sdk = Mercadopago::SDK.new('<YOUR_ACCESS_TOKEN>')
4
+
5
+ # Step 1: Build the authorization URL and redirect the seller to it
6
+ auth_url = sdk.oauth.get_authorization_url(
7
+ '<YOUR_APP_ID>',
8
+ 'https://yourapp.com/callback',
9
+ '<UNIQUE_CSRF_STATE>'
10
+ )
11
+ puts "Redirect seller to: #{auth_url}"
12
+
13
+ # Step 2: After the seller authorizes, exchange the code for tokens
14
+ oauth_data = {
15
+ client_secret: '<YOUR_ACCESS_TOKEN>',
16
+ code: '<AUTHORIZATION_CODE_FROM_CALLBACK>',
17
+ redirect_uri: 'https://yourapp.com/callback',
18
+ grant_type: 'authorization_code'
19
+ }
20
+
21
+ result = sdk.oauth.create(oauth_data)
22
+ puts "Token created: #{result[:response]}"
@@ -0,0 +1,120 @@
1
+ require_relative '../../lib/mercadopago'
2
+
3
+
4
+ sdk = Mercadopago::SDK.new('<ACCESS_TOKEN>')
5
+
6
+ def create_checkout_pro_order(sdk)
7
+ request = {
8
+ total_amount: '500.00',
9
+ external_reference: 'ext_ref_checkout_pro',
10
+ capture_mode: 'automatic',
11
+ marketplace_fee: '5.00',
12
+ description: 'Travel package SAO-RIO with insurance',
13
+ expiration_time: 'P1D',
14
+ payer: {
15
+ email: '<PAYER_EMAIL>',
16
+ first_name: 'John',
17
+ last_name: 'Smith',
18
+ phone: {
19
+ area_code: '11',
20
+ number: '999998888'
21
+ },
22
+ identification: {
23
+ type: 'CPF',
24
+ number: '12345678909'
25
+ }
26
+ },
27
+ shipment: {
28
+ mode: 'custom',
29
+ local_pickup: false,
30
+ cost: '15.00',
31
+ free_shipping: false,
32
+ address: {
33
+ zip_code: '01310-100',
34
+ street_name: 'Av. Paulista',
35
+ street_number: '1000',
36
+ neighborhood: 'Bela Vista',
37
+ city: 'Sao Paulo'
38
+ }
39
+ },
40
+ config: {
41
+ statement_descriptor: 'MYSTORE',
42
+ default_payment_due_date: 'P1D',
43
+ online: {
44
+ available_from: '2026-01-01T00:00:00Z',
45
+ allowed_user_type: 'account_only',
46
+ success_url: 'https://example.com/success',
47
+ failure_url: 'https://example.com/failure',
48
+ pending_url: 'https://example.com/pending',
49
+ auto_return: 'approved',
50
+ tracks: [
51
+ {
52
+ type: 'google_ad',
53
+ values: {
54
+ conversion_id: '21312312312123',
55
+ conversion_label: 'TEST'
56
+ }
57
+ },
58
+ {
59
+ type: 'facebook_ad',
60
+ values: {
61
+ pixel_id: '21312312312123'
62
+ }
63
+ }
64
+ ]
65
+ },
66
+ payment_method: {
67
+ max_installments: 12,
68
+ not_allowed_ids: ['amex'],
69
+ not_allowed_types: ['ticket'],
70
+ installments: {
71
+ interest_free: {
72
+ type: 'range',
73
+ values: [2, 6]
74
+ }
75
+ }
76
+ }
77
+ },
78
+ items: [
79
+ {
80
+ external_code: 'ITEM-001',
81
+ title: 'Flight SAO-RIO',
82
+ description: 'Round trip, economy class',
83
+ category_id: 'travels',
84
+ picture_url: 'https://example.com/img.jpg',
85
+ quantity: 1,
86
+ unit_price: '450.00',
87
+ type: 'travel',
88
+ event_date: '2027-01-15T00:00:00.000-03:00'
89
+ },
90
+ {
91
+ external_code: 'ITEM-002',
92
+ title: 'Travel insurance',
93
+ description: 'Basic coverage during trip',
94
+ category_id: 'travels',
95
+ picture_url: 'https://example.com/insurance.jpg',
96
+ quantity: 1,
97
+ unit_price: '50.00',
98
+ type: 'travel',
99
+ event_date: '2027-01-15T00:00:00.000-03:00'
100
+ }
101
+ ]
102
+ }
103
+
104
+ custom_headers = {
105
+ 'X-Idempotency-Key': '<SOME_UNIQUE_VALUE>'
106
+ }
107
+ custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers)
108
+
109
+ result = sdk.order.create_checkout_pro(request, request_options: custom_request_options)
110
+ order = result[:response]
111
+
112
+ puts "Order id: #{order['id']}"
113
+ puts "Status: #{order['status']}"
114
+ puts "Redirect buyer to Checkout Pro: #{order['checkout_url']}"
115
+
116
+ rescue StandardError => e
117
+ puts e.message
118
+ end
119
+
120
+ create_checkout_pro_order(sdk)
@@ -0,0 +1,26 @@
1
+ require_relative '../../lib/mercadopago'
2
+
3
+ sdk = Mercadopago::SDK.new('<YOUR_ACCESS_TOKEN>')
4
+
5
+ # List available Point devices
6
+ devices = sdk.point.get_devices
7
+ puts "Devices: #{devices[:response]}"
8
+
9
+ # Create a payment intent on a specific device
10
+ device_id = '<YOUR_DEVICE_ID>'
11
+ payment_intent_data = {
12
+ amount: 1500,
13
+ description: 'Product purchase',
14
+ payment: {
15
+ installments: 1,
16
+ type: 'credit_card'
17
+ }
18
+ }
19
+
20
+ result = sdk.point.create(device_id, payment_intent_data)
21
+ puts "Payment intent created: #{result[:response]}"
22
+
23
+ # Retrieve the payment intent status
24
+ payment_intent_id = result[:response]['id']
25
+ status = sdk.point.get(payment_intent_id)
26
+ puts "Payment intent status: #{status[:response]}"
@@ -9,7 +9,7 @@ module Mercadopago
9
9
  # there is no need to instantiate this class directly.
10
10
  class Config
11
11
  # Current SDK version following SemVer.
12
- @@VERSION = '3.0.1'
12
+ @@VERSION = '3.2.0'
13
13
 
14
14
  # User-Agent string sent with every HTTP request for server-side tracking.
15
15
  @@USER_AGENT = "MercadoPago Ruby SDK v#{@@VERSION}"
@@ -77,9 +77,7 @@ module Mercadopago
77
77
  headers['x-integrator-id'] = @integrator_id unless @integrator_id.nil?
78
78
  headers['x-platform-id'] = @platform_id unless @platform_id.nil?
79
79
 
80
- headers.merge!(@custom_headers) unless @custom_headers.nil?
81
-
82
- headers
80
+ merge_custom_headers(headers)
83
81
  end
84
82
 
85
83
  # @param value [String, nil] OAuth access token
@@ -137,5 +135,15 @@ module Mercadopago
137
135
 
138
136
  @max_retries = value
139
137
  end
138
+
139
+ private
140
+
141
+ def merge_custom_headers(headers)
142
+ return headers if @custom_headers.nil?
143
+
144
+ custom_header_names = @custom_headers.keys.map { |key| key.to_s.downcase }
145
+ headers.reject! { |key, _value| custom_header_names.include?(key.to_s.downcase) }
146
+ headers.merge!(@custom_headers)
147
+ end
140
148
  end
141
149
  end
@@ -16,7 +16,6 @@ module Mercadopago
16
16
  # replace it via +SDK.new(token, http_client: MyClient.new)+ to
17
17
  # inject a custom transport (e.g. for testing or logging).
18
18
  class HttpClient
19
-
20
19
  RETRYABLE_STATUSES = [429, 500, 502, 503, 504].freeze
21
20
 
22
21
  # Performs an HTTP GET request with automatic retry on transient errors.
@@ -0,0 +1,36 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Mercadopago
5
+ # Provides read access to chargeback disputes.
6
+ #
7
+ # Chargebacks are initiated by cardholders through their issuing bank
8
+ # when they dispute a payment. Use {#get} and {#search} to monitor and
9
+ # respond to disputes.
10
+ #
11
+ # @see https://www.mercadopago.com.br/developers/en/reference/chargebacks/
12
+ class Chargeback < MPBase
13
+ # Retrieves a chargeback by its ID.
14
+ #
15
+ # @param chargeback_id [Integer, String] unique chargeback identifier
16
+ # @param request_options [RequestOptions, nil] per-call configuration override
17
+ # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the full chargeback object
18
+ # @see https://www.mercadopago.com.br/developers/en/reference/chargebacks/
19
+ def get(chargeback_id, request_options: nil)
20
+ _get(uri: "/v1/chargebacks/#{chargeback_id}", request_options: request_options)
21
+ end
22
+
23
+ # Searches chargebacks matching the given filters.
24
+ #
25
+ # @param filters [Hash, nil] query parameters (e.g. +:payment_id+, +:status+)
26
+ # @param request_options [RequestOptions, nil] per-call configuration override
27
+ # @return [Hash{Symbol => Object}] +:status+ and +:response+ with a paginated list of chargebacks
28
+ # @raise [TypeError] if +filters+ is not a Hash
29
+ # @see https://www.mercadopago.com.br/developers/en/reference/chargebacks/
30
+ def search(filters: nil, request_options: nil)
31
+ raise TypeError, 'Param filters must be a Hash' unless filters.nil? || filters.is_a?(Hash)
32
+
33
+ _get(uri: '/v1/chargebacks/search', filters: filters, request_options: request_options)
34
+ end
35
+ end
36
+ end