mercadopago-sdk 3.2.0 → 3.2.1

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: d3eb3c15c909d8872d5810ac30966353a794f2c70bfcd983824898a93e2adf96
4
- data.tar.gz: cd2bbac8379dcedaae481d4f4715130e21f88f819dc34a73779c238575e98f3b
3
+ metadata.gz: 7dfcf7186c9d72f9b02200699acf4807a80aee9014b0c8b1905097850b6ed5fe
4
+ data.tar.gz: 3cb25341c72de1d3686fe217c7fb81e3ec0bfa87a74cf80cee163b1c3ec6a0d6
5
5
  SHA512:
6
- metadata.gz: 0ec0c57a6703933698e7fb99643274658a871ac3bb3738bcefa756ffde307ac9037d54ddd36f585c5a8b60f90f9bb7c433b7b97047a0f4f5ded2bf3aafbf9a94
7
- data.tar.gz: 3379ec1633e23f25eae001deea156c96010e345298b0f8c58113d30916d644d0a263078261ad6bc9d9aff3d65ba2a488bc723d906db7a8196d0aca514d6f0d02
6
+ metadata.gz: c446ae477af4b97192b150ac3618b2e363d0d98dc8cb060aa08a26f4dc13811612fa69d6f618180fcd315f77cdd83757872f4c052b6689a86ab533411a7fd8bb
7
+ data.tar.gz: '086a6f76e544b588f0f09a55d59946bd68f9eb373dbd3328841fe977168273e2b5a2d35d9e30cf0b9672d81fd31947b8fcdc1bfaca17d21a1b6529e55adbad7b'
@@ -13,13 +13,13 @@ jobs:
13
13
 
14
14
  steps:
15
15
  - name: Checkout code
16
- uses: actions/checkout@v7
16
+ uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
17
17
  with:
18
18
  ref: ${{ github.event.pull_request.head.ref }}
19
19
  repository: ${{ github.event.pull_request.head.repo.full_name }}
20
20
 
21
21
  - name: Cache gems
22
- uses: actions/cache@v6
22
+ uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v6
23
23
  with:
24
24
  path: vendor/bundle
25
25
  key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
@@ -14,7 +14,7 @@ jobs:
14
14
 
15
15
  steps:
16
16
  - name: Checkout code
17
- uses: actions/checkout@v7
17
+ uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
18
18
 
19
19
  - name: Install dependencies
20
20
  run: bundle install
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mercadopago-sdk (3.2.0)
4
+ mercadopago-sdk (3.2.1)
5
5
  faraday (~> 2.0)
6
6
  json (~> 2.5)
7
7
 
@@ -17,8 +17,8 @@ GEM
17
17
  faraday-net_http (3.4.4)
18
18
  net-http (~> 0.5)
19
19
  io-console (0.8.2)
20
- json (2.20.0)
21
- language_server-protocol (3.17.0.5)
20
+ json (2.21.1)
21
+ language_server-protocol (3.17.0.6)
22
22
  lint_roller (1.1.0)
23
23
  logger (1.7.0)
24
24
  method_source (1.1.0)
@@ -40,7 +40,7 @@ GEM
40
40
  regexp_parser (2.12.0)
41
41
  reline (0.6.3)
42
42
  io-console (~> 0.5)
43
- rubocop (1.88.0)
43
+ rubocop (1.88.2)
44
44
  json (~> 2.3)
45
45
  language_server-protocol (~> 3.17.0.2)
46
46
  lint_roller (~> 1.1.0)
@@ -51,7 +51,7 @@ GEM
51
51
  rubocop-ast (>= 1.49.0, < 2.0)
52
52
  ruby-progressbar (~> 1.7)
53
53
  unicode-display_width (>= 2.4.0, < 4.0)
54
- rubocop-ast (1.49.1)
54
+ rubocop-ast (1.50.0)
55
55
  parser (>= 3.3.7.2)
56
56
  prism (~> 1.7)
57
57
  ruby-progressbar (1.13.0)
@@ -22,11 +22,18 @@ def create_checkout_pro_order(sdk)
22
22
  identification: {
23
23
  type: 'CPF',
24
24
  number: '12345678909'
25
- }
25
+ },
26
+ date_created: '2024-01-01T00:00:00Z',
27
+ authentication_type: 'Gmail',
28
+ is_prime_user: false,
29
+ is_first_purchase_online: false,
30
+ last_purchase: '2024-01-01T00:00:00Z',
31
+ registration_date: '2023-01-01T00:00:00Z'
26
32
  },
27
33
  shipment: {
28
34
  mode: 'custom',
29
35
  local_pickup: false,
36
+ express_shipment: false,
30
37
  cost: '15.00',
31
38
  free_shipping: false,
32
39
  address: {
@@ -34,7 +41,11 @@ def create_checkout_pro_order(sdk)
34
41
  street_name: 'Av. Paulista',
35
42
  street_number: '1000',
36
43
  neighborhood: 'Bela Vista',
37
- city: 'Sao Paulo'
44
+ city: 'Sao Paulo',
45
+ state_name: 'Sao Paulo',
46
+ city_name: 'Sao Paulo',
47
+ floor: '2',
48
+ apartment: 'A'
38
49
  }
39
50
  },
40
51
  config: {
@@ -85,7 +96,25 @@ def create_checkout_pro_order(sdk)
85
96
  quantity: 1,
86
97
  unit_price: '450.00',
87
98
  type: 'travel',
88
- event_date: '2027-01-15T00:00:00.000-03:00'
99
+ warranty: false,
100
+ event_date: '2027-01-15T00:00:00.000-03:00',
101
+ category_descriptor: {
102
+ passenger: {
103
+ first_name: 'John',
104
+ last_name: 'Smith',
105
+ identification: {
106
+ type: 'CPF',
107
+ number: '12345678909'
108
+ }
109
+ },
110
+ route: {
111
+ departure: 'SAO',
112
+ destination: 'RIO',
113
+ departure_date_time: '2027-01-15T08:00:00.000-03:00',
114
+ arrival_date_time: '2027-01-15T09:30:00.000-03:00',
115
+ company: 'LATAM'
116
+ }
117
+ }
89
118
  },
90
119
  {
91
120
  external_code: 'ITEM-002',
@@ -96,7 +125,25 @@ def create_checkout_pro_order(sdk)
96
125
  quantity: 1,
97
126
  unit_price: '50.00',
98
127
  type: 'travel',
99
- event_date: '2027-01-15T00:00:00.000-03:00'
128
+ warranty: true,
129
+ event_date: '2027-01-15T00:00:00.000-03:00',
130
+ category_descriptor: {
131
+ passenger: {
132
+ first_name: 'John',
133
+ last_name: 'Smith',
134
+ identification: {
135
+ type: 'CPF',
136
+ number: '12345678909'
137
+ }
138
+ },
139
+ route: {
140
+ departure: 'SAO',
141
+ destination: 'RIO',
142
+ departure_date_time: '2027-01-15T08:00:00.000-03:00',
143
+ arrival_date_time: '2027-01-15T09:30:00.000-03:00',
144
+ company: 'LATAM'
145
+ }
146
+ }
100
147
  }
101
148
  ]
102
149
  }
@@ -0,0 +1,137 @@
1
+ # Example: Create a Checkout Preference with industry-specific fields.
2
+ # Demonstrates payer authentication info, item category descriptors,
3
+ # passenger/route details, and shipment address enrichment.
4
+
5
+ require_relative '../../lib/mercadopago'
6
+
7
+ sdk = Mercadopago::SDK.new('<ACCESS_TOKEN>')
8
+
9
+ def create_preference_with_industry_fields(sdk)
10
+ request = {
11
+ payer: {
12
+ name: 'John',
13
+ surname: 'Smith',
14
+ email: '<PAYER_EMAIL>',
15
+ phone: {
16
+ area_code: '11',
17
+ number: '999998888'
18
+ },
19
+ identification: {
20
+ type: 'CPF',
21
+ number: '12345678909'
22
+ },
23
+ address: {
24
+ zip_code: '01310-100',
25
+ street_name: 'Av. Paulista',
26
+ street_number: 1000
27
+ },
28
+ date_created: '2024-01-01T00:00:00Z',
29
+ authentication_type: 'Gmail',
30
+ is_prime_user: false,
31
+ is_first_purchase_online: false,
32
+ last_purchase: '2024-01-01T00:00:00Z',
33
+ registration_date: '2023-01-01T00:00:00Z'
34
+ },
35
+ items: [
36
+ {
37
+ id: 'ITEM-001',
38
+ title: 'Flight SAO-RIO',
39
+ description: 'Round trip, economy class',
40
+ category_id: 'travels',
41
+ picture_url: 'https://example.com/img.jpg',
42
+ quantity: 1,
43
+ currency_id: 'BRL',
44
+ unit_price: 450.00,
45
+ warranty: false,
46
+ event_date: '2027-01-15T00:00:00.000-03:00',
47
+ category_descriptor: {
48
+ passenger: {
49
+ first_name: 'John',
50
+ last_name: 'Smith',
51
+ identification: {
52
+ type: 'CPF',
53
+ number: '12345678909'
54
+ }
55
+ },
56
+ route: {
57
+ departure: 'SAO',
58
+ destination: 'RIO',
59
+ departure_date_time: '2027-01-15T08:00:00.000-03:00',
60
+ arrival_date_time: '2027-01-15T09:30:00.000-03:00',
61
+ company: 'LATAM'
62
+ }
63
+ }
64
+ },
65
+ {
66
+ id: 'ITEM-002',
67
+ title: 'Travel insurance',
68
+ description: 'Basic coverage during trip',
69
+ category_id: 'travels',
70
+ picture_url: 'https://example.com/insurance.jpg',
71
+ quantity: 1,
72
+ currency_id: 'BRL',
73
+ unit_price: 50.00,
74
+ warranty: true,
75
+ event_date: '2027-01-15T00:00:00.000-03:00',
76
+ category_descriptor: {
77
+ passenger: {
78
+ first_name: 'John',
79
+ last_name: 'Smith',
80
+ identification: {
81
+ type: 'CPF',
82
+ number: '12345678909'
83
+ }
84
+ },
85
+ route: {
86
+ departure: 'SAO',
87
+ destination: 'RIO',
88
+ departure_date_time: '2027-01-15T08:00:00.000-03:00',
89
+ arrival_date_time: '2027-01-15T09:30:00.000-03:00',
90
+ company: 'LATAM'
91
+ }
92
+ }
93
+ }
94
+ ],
95
+ shipments: {
96
+ mode: 'custom',
97
+ local_pickup: false,
98
+ express_shipment: false,
99
+ cost: 15.0,
100
+ free_shipping: false,
101
+ receiver_address: {
102
+ zip_code: '01310-100',
103
+ street_name: 'Av. Paulista',
104
+ street_number: 1000,
105
+ state_name: 'Sao Paulo',
106
+ city_name: 'Sao Paulo',
107
+ floor: '2',
108
+ apartment: 'A'
109
+ }
110
+ },
111
+ back_urls: {
112
+ success: 'https://example.com/success',
113
+ failure: 'https://example.com/failure',
114
+ pending: 'https://example.com/pending'
115
+ },
116
+ auto_return: 'approved',
117
+ external_reference: 'MP0001',
118
+ notification_url: 'https://example.com/notifications',
119
+ statement_descriptor: 'MYSTORE'
120
+ }
121
+
122
+ custom_headers = {
123
+ 'X-Idempotency-Key': '<SOME_UNIQUE_VALUE>'
124
+ }
125
+ custom_request_options = Mercadopago::RequestOptions.new(custom_headers: custom_headers)
126
+
127
+ result = sdk.preference.create(request, request_options: custom_request_options)
128
+ preference = result[:response]
129
+
130
+ puts "Preference id: #{preference['id']}"
131
+ puts "Init point: #{preference['init_point']}"
132
+
133
+ rescue StandardError => e
134
+ puts e.message
135
+ end
136
+
137
+ create_preference_with_industry_fields(sdk)
@@ -1,6 +1,8 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'cgi'
5
+
4
6
  module Mercadopago
5
7
  # Abstract base class for every API resource (Payment, Customer, Order, etc.).
6
8
  #
@@ -61,6 +63,11 @@ module Mercadopago
61
63
  headers
62
64
  end
63
65
 
66
+ # Encodes a dynamic URL path segment before interpolation.
67
+ def _path_param(value)
68
+ CGI.escape(value.to_s).gsub('+', '%20')
69
+ end
70
+
64
71
  # Performs a GET request against the MercadoPago API.
65
72
  #
66
73
  # @param uri [String] API path (e.g. "/v1/payments/123")
@@ -29,7 +29,7 @@ module Mercadopago
29
29
  # @param request_options [RequestOptions, nil] per-call configuration override
30
30
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with payment details
31
31
  def get(advanced_payment_id, request_options: nil)
32
- _get(uri: "/v1/advanced_payments/#{advanced_payment_id}", request_options: request_options)
32
+ _get(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}", request_options: request_options)
33
33
  end
34
34
 
35
35
  # Creates a new advanced payment with split disbursements.
@@ -54,7 +54,7 @@ module Mercadopago
54
54
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the captured payment
55
55
  def capture(advanced_payment_id, request_options: nil)
56
56
  capture_data = { capture: true }
57
- _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: capture_data, request_options: request_options)
57
+ _put(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}", data: capture_data, request_options: request_options)
58
58
  end
59
59
 
60
60
  # Updates an existing advanced payment.
@@ -67,7 +67,7 @@ module Mercadopago
67
67
  def update(advanced_payment_id, advanced_payment_data, request_options: nil)
68
68
  raise TypeError, 'Param advanced_payment_data must be a Hash' unless advanced_payment_data.is_a?(Hash)
69
69
 
70
- _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: advanced_payment_data,
70
+ _put(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}", data: advanced_payment_data,
71
71
  request_options: request_options)
72
72
  end
73
73
 
@@ -78,7 +78,7 @@ module Mercadopago
78
78
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the cancelled payment
79
79
  def cancel(advanced_payment_id, request_options: nil)
80
80
  cancel_data = { status: 'cancelled' }
81
- _put(uri: "/v1/advanced_payments/#{advanced_payment_id}", data: cancel_data, request_options: request_options)
81
+ _put(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}", data: cancel_data, request_options: request_options)
82
82
  end
83
83
 
84
84
  # Changes the money release date for an advanced payment's disbursements.
@@ -89,7 +89,7 @@ module Mercadopago
89
89
  # @return [Hash{Symbol => Object}] +:status+ and +:response+
90
90
  def update_release_date(advanced_payment_id, release_date, request_options: nil)
91
91
  disbursement_data = { money_release_date: release_date.strftime('%Y-%m-%d %H:%M:%S.%f') }
92
- _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/disburses", data: disbursement_data,
92
+ _post(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}/disburses", data: disbursement_data,
93
93
  request_options: request_options)
94
94
  end
95
95
  end
@@ -18,7 +18,7 @@ module Mercadopago
18
18
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with card details
19
19
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api/cards/get-card/get
20
20
  def get(customer_id, card_id, request_options: nil)
21
- _get(uri: "/v1/customers/#{customer_id}/cards/#{card_id}", request_options: request_options)
21
+ _get(uri: "/v1/customers/#{_path_param(customer_id)}/cards/#{_path_param(card_id)}", request_options: request_options)
22
22
  end
23
23
 
24
24
  # Saves a new card for a customer using a previously generated card token.
@@ -32,7 +32,7 @@ module Mercadopago
32
32
  def create(customer_id, card_data, request_options: nil)
33
33
  raise TypeError, 'Param card_data must be a Hash' if card_data.nil? || !card_data.is_a?(Hash)
34
34
 
35
- _post(uri: "/v1/customers/#{customer_id}/cards/", data: card_data, request_options: request_options)
35
+ _post(uri: "/v1/customers/#{_path_param(customer_id)}/cards/", data: card_data, request_options: request_options)
36
36
  end
37
37
 
38
38
  # Deletes a saved card from a customer.
@@ -43,7 +43,7 @@ module Mercadopago
43
43
  # @return [Hash{Symbol => Object}] +:status+ and +:response+
44
44
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api/cards/delete-card/delete
45
45
  def delete(customer_id, card_id, request_options: nil)
46
- _delete(uri: "/v1/customers/#{customer_id}/cards/#{card_id}", request_options: request_options)
46
+ _delete(uri: "/v1/customers/#{_path_param(customer_id)}/cards/#{_path_param(card_id)}", request_options: request_options)
47
47
  end
48
48
 
49
49
  # Lists all saved cards for a customer.
@@ -53,7 +53,7 @@ module Mercadopago
53
53
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with an array of cards
54
54
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api/cards/get-customer-cards/get
55
55
  def list(customer_id, request_options: nil)
56
- _get(uri: "/v1/customers/#{customer_id}/cards", request_options: request_options)
56
+ _get(uri: "/v1/customers/#{_path_param(customer_id)}/cards", request_options: request_options)
57
57
  end
58
58
  end
59
59
  end
@@ -16,7 +16,7 @@ module Mercadopago
16
16
  # @param request_options [RequestOptions, nil] per-call configuration override
17
17
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with token details
18
18
  def get(card_token_id, request_options: nil)
19
- _get(uri: "/v1/card_tokens/#{card_token_id}", request_options: request_options)
19
+ _get(uri: "/v1/card_tokens/#{_path_param(card_token_id)}", request_options: request_options)
20
20
  end
21
21
 
22
22
  # Creates a new card token from raw card data.
@@ -17,7 +17,7 @@ module Mercadopago
17
17
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the full chargeback object
18
18
  # @see https://www.mercadopago.com.br/developers/en/reference/chargebacks/
19
19
  def get(chargeback_id, request_options: nil)
20
- _get(uri: "/v1/chargebacks/#{chargeback_id}", request_options: request_options)
20
+ _get(uri: "/v1/chargebacks/#{_path_param(chargeback_id)}", request_options: request_options)
21
21
  end
22
22
 
23
23
  # Searches chargebacks matching the given filters.
@@ -26,7 +26,7 @@ module Mercadopago
26
26
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with customer details
27
27
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api/customers/get-customer/get
28
28
  def get(customer_id, request_options: nil)
29
- _get(uri: "/v1/customers/#{customer_id}", request_options: request_options)
29
+ _get(uri: "/v1/customers/#{_path_param(customer_id)}", request_options: request_options)
30
30
  end
31
31
 
32
32
  # Creates a new customer.
@@ -53,7 +53,7 @@ module Mercadopago
53
53
  def update(customer_id, customer_data, request_options: nil)
54
54
  raise TypeError, 'Param customer_data must be a Hash' unless customer_data.is_a?(Hash)
55
55
 
56
- _put(uri: "/v1/customers/#{customer_id}", data: customer_data, request_options: request_options)
56
+ _put(uri: "/v1/customers/#{_path_param(customer_id)}", data: customer_data, request_options: request_options)
57
57
  end
58
58
 
59
59
  # Deletes a customer permanently.
@@ -62,7 +62,7 @@ module Mercadopago
62
62
  # @param request_options [RequestOptions, nil] per-call configuration override
63
63
  # @return [Hash{Symbol => Object}] +:status+ and +:response+
64
64
  def delete(customer_id, request_options: nil)
65
- _delete(uri: "/v1/customers/#{customer_id}", request_options: request_options)
65
+ _delete(uri: "/v1/customers/#{_path_param(customer_id)}", request_options: request_options)
66
66
  end
67
67
  end
68
68
  end
@@ -14,7 +14,7 @@ module Mercadopago
14
14
  # @param request_options [RequestOptions, nil] per-call configuration override
15
15
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with an array of refunds
16
16
  def list(advanced_payment_id, request_options: nil)
17
- _get(uri: "/v1/advanced_payments/#{advanced_payment_id}/refunds", request_options: nil)
17
+ _get(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}/refunds", request_options: nil)
18
18
  end
19
19
 
20
20
  # Refunds all disbursements of an advanced payment at once.
@@ -23,7 +23,7 @@ module Mercadopago
23
23
  # @param request_options [RequestOptions, nil] per-call configuration override
24
24
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with refund details
25
25
  def create_all(advanced_payment_id, request_options: nil)
26
- _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/refunds", request_options: request_options)
26
+ _post(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}/refunds", request_options: request_options)
27
27
  end
28
28
 
29
29
  # Refunds a single disbursement (full or partial).
@@ -39,7 +39,7 @@ module Mercadopago
39
39
  def create(advanced_payment_id, disbursement_id, amount: nil, request_options: nil)
40
40
  disbursement_refund_data = amount.nil? ? nil : { amount: amount }
41
41
 
42
- _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/disbursements/#{disbursement_id}/refunds",
42
+ _post(uri: "/v1/advanced_payments/#{_path_param(advanced_payment_id)}/disbursements/#{_path_param(disbursement_id)}/refunds",
43
43
  data: disbursement_refund_data, request_options: request_options)
44
44
  end
45
45
  end
@@ -19,7 +19,7 @@ module Mercadopago
19
19
  # including +:status+, +:transaction_amount+, +:preapproval_id+, and +:payment+ details
20
20
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/subscriptions/get-authorized-payment/get
21
21
  def get(invoice_id, request_options: nil)
22
- _get(uri: "/authorized_payments/#{invoice_id}", request_options: request_options)
22
+ _get(uri: "/authorized_payments/#{_path_param(invoice_id)}", request_options: request_options)
23
23
  end
24
24
 
25
25
  # Searches invoices matching the given filters.
@@ -30,7 +30,7 @@ module Mercadopago
30
30
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with order details
31
31
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-pro/merchant_orders/get-merchant-order/get
32
32
  def get(merchant_order_id, request_options: nil)
33
- _get(uri: "/merchant_orders/#{merchant_order_id}", request_options: request_options)
33
+ _get(uri: "/merchant_orders/#{_path_param(merchant_order_id)}", request_options: request_options)
34
34
  end
35
35
 
36
36
  # Creates a new merchant order.
@@ -57,7 +57,7 @@ module Mercadopago
57
57
  def update(merchant_order_id, merchant_order_data, request_options: nil)
58
58
  raise TypeError, 'Param merchant_orders_object must be a Hash' unless merchant_order_data.is_a?(Hash)
59
59
 
60
- _put(uri: "/merchant_orders/#{merchant_order_id}", data: merchant_order_data,
60
+ _put(uri: "/merchant_orders/#{_path_param(merchant_order_id)}", data: merchant_order_data,
61
61
  request_options: request_options)
62
62
  end
63
63
  end
@@ -99,7 +99,7 @@ module Mercadopago
99
99
  # @param request_options [RequestOptions, nil] per-call configuration override
100
100
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with order details
101
101
  def get(order_id, request_options: nil)
102
- _get(uri: "/v1/orders/#{order_id}", request_options: request_options)
102
+ _get(uri: "/v1/orders/#{_path_param(order_id)}", request_options: request_options)
103
103
  end
104
104
 
105
105
  # Processes (confirms) an order, triggering payment execution.
@@ -108,7 +108,7 @@ module Mercadopago
108
108
  # @param request_options [RequestOptions, nil] per-call configuration override
109
109
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the processed order
110
110
  def process(order_id, request_options: nil)
111
- _post(uri: "/v1/orders/#{order_id}/process", data: nil, request_options: request_options)
111
+ _post(uri: "/v1/orders/#{_path_param(order_id)}/process", data: nil, request_options: request_options)
112
112
  end
113
113
 
114
114
  # Refunds an order (full or partial).
@@ -124,7 +124,7 @@ module Mercadopago
124
124
  def refund(order_id, refund_data: nil, request_options: nil)
125
125
  raise TypeError, 'Param refund_data must be a Hash' unless refund_data.nil? || refund_data.is_a?(Hash)
126
126
 
127
- _post(uri: "/v1/orders/#{order_id}/refund", data: refund_data, request_options: request_options)
127
+ _post(uri: "/v1/orders/#{_path_param(order_id)}/refund", data: refund_data, request_options: request_options)
128
128
  end
129
129
 
130
130
  # Cancels an order that has not yet been captured.
@@ -133,7 +133,7 @@ module Mercadopago
133
133
  # @param request_options [RequestOptions, nil] per-call configuration override
134
134
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the cancelled order
135
135
  def cancel(order_id, request_options: nil)
136
- _post(uri: "/v1/orders/#{order_id}/cancel", data: nil, request_options: request_options)
136
+ _post(uri: "/v1/orders/#{_path_param(order_id)}/cancel", data: nil, request_options: request_options)
137
137
  end
138
138
 
139
139
  # Captures a previously authorized order.
@@ -142,7 +142,7 @@ module Mercadopago
142
142
  # @param request_options [RequestOptions, nil] per-call configuration override
143
143
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with the captured order
144
144
  def capture(order_id, request_options: nil)
145
- _post(uri: "/v1/orders/#{order_id}/capture", data: nil, request_options: request_options)
145
+ _post(uri: "/v1/orders/#{_path_param(order_id)}/capture", data: nil, request_options: request_options)
146
146
  end
147
147
 
148
148
  # Searches orders matching the given filters.
@@ -20,7 +20,7 @@ module Mercadopago
20
20
  def create(order_id, order_transaction_data, request_options: nil)
21
21
  raise TypeError, 'Param order_transaction_data must be a Hash' unless order_transaction_data.is_a?(Hash)
22
22
 
23
- _post(uri: "/v1/orders/#{order_id}/transactions", data: order_transaction_data, request_options: request_options)
23
+ _post(uri: "/v1/orders/#{_path_param(order_id)}/transactions", data: order_transaction_data, request_options: request_options)
24
24
  end
25
25
 
26
26
  # Updates an existing transaction within an order.
@@ -34,7 +34,8 @@ module Mercadopago
34
34
  def update(order_id, transaction_id, order_transaction_data, request_options: nil)
35
35
  raise TypeError, 'Param order_transaction_data must be a Hash' unless order_transaction_data.is_a?(Hash)
36
36
 
37
- _put(uri: "/v1/orders/#{order_id}/transactions/#{transaction_id}", data: order_transaction_data, request_options: request_options)
37
+ _put(uri: "/v1/orders/#{_path_param(order_id)}/transactions/#{_path_param(transaction_id)}",
38
+ data: order_transaction_data, request_options: request_options)
38
39
  end
39
40
 
40
41
  # Removes a transaction from an order.
@@ -44,7 +45,7 @@ module Mercadopago
44
45
  # @param request_options [RequestOptions, nil] per-call configuration override
45
46
  # @return [Hash{Symbol => Object}] +:status+ and +:response+
46
47
  def delete(order_id, transaction_id, request_options: nil)
47
- _delete(uri: "/v1/orders/#{order_id}/transactions/#{transaction_id}", request_options: request_options)
48
+ _delete(uri: "/v1/orders/#{_path_param(order_id)}/transactions/#{_path_param(transaction_id)}", request_options: request_options)
48
49
  end
49
50
  end
50
51
  end
@@ -29,7 +29,7 @@ module Mercadopago
29
29
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with payment details
30
30
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api-payments/get-payment/get
31
31
  def get(payment_id, request_options: nil)
32
- _get(uri: "/v1/payments/#{payment_id}", request_options: request_options)
32
+ _get(uri: "/v1/payments/#{_path_param(payment_id)}", request_options: request_options)
33
33
  end
34
34
 
35
35
  # Creates a new payment.
@@ -56,7 +56,7 @@ module Mercadopago
56
56
  def update(payment_id, payment_data, request_options: nil)
57
57
  raise TypeError, 'Param payment_data must be a Hash' unless payment_data.is_a?(Hash)
58
58
 
59
- _put(uri: "/v1/payments/#{payment_id}", data: payment_data, request_options: request_options)
59
+ _put(uri: "/v1/payments/#{_path_param(payment_id)}", data: payment_data, request_options: request_options)
60
60
  end
61
61
  end
62
62
  end
@@ -43,7 +43,7 @@ module Mercadopago
43
43
  raise TypeError, 'Param payment_intent_data must be a Hash' unless payment_intent_data.is_a?(Hash)
44
44
 
45
45
  _post(
46
- uri: "/point/integration-api/devices/#{device_id}/payment-intents",
46
+ uri: "/point/integration-api/devices/#{_path_param(device_id)}/payment-intents",
47
47
  data: payment_intent_data,
48
48
  request_options: request_options
49
49
  )
@@ -61,7 +61,7 @@ module Mercadopago
61
61
  # @see https://www.mercadopago.com/developers/en/reference/in-person-payments/point/orders/get-order/get
62
62
  def get(payment_intent_id, request_options: nil)
63
63
  _get(
64
- uri: "/point/integration-api/payment-intents/#{payment_intent_id}",
64
+ uri: "/point/integration-api/payment-intents/#{_path_param(payment_intent_id)}",
65
65
  request_options: request_options
66
66
  )
67
67
  end
@@ -78,7 +78,7 @@ module Mercadopago
78
78
  # @see https://www.mercadopago.com/developers/en/reference/in-person-payments/point/orders/cancel-order/post
79
79
  def cancel(device_id, payment_intent_id, request_options: nil)
80
80
  _delete(
81
- uri: "/point/integration-api/devices/#{device_id}/payment-intents/#{payment_intent_id}",
81
+ uri: "/point/integration-api/devices/#{_path_param(device_id)}/payment-intents/#{_path_param(payment_intent_id)}",
82
82
  request_options: request_options
83
83
  )
84
84
  end
@@ -31,7 +31,7 @@ module Mercadopago
31
31
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with subscription details
32
32
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/subscriptions/get-preapproval/get
33
33
  def get(preapproval_id, request_options: nil)
34
- _get(uri: "/preapproval/#{preapproval_id}", request_options: request_options)
34
+ _get(uri: "/preapproval/#{_path_param(preapproval_id)}", request_options: request_options)
35
35
  end
36
36
 
37
37
  # Creates a new subscription.
@@ -58,7 +58,7 @@ module Mercadopago
58
58
  def update(preapproval_id, preapproval_data, request_options: nil)
59
59
  raise TypeError, 'Param preapproval_data must be a Hash' unless preapproval_data.is_a?(Hash)
60
60
 
61
- _put(uri: "/preapproval/#{preapproval_id}", data: preapproval_data, request_options: request_options)
61
+ _put(uri: "/preapproval/#{_path_param(preapproval_id)}", data: preapproval_data, request_options: request_options)
62
62
  end
63
63
  end
64
64
  end
@@ -30,7 +30,7 @@ module Mercadopago
30
30
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with plan details
31
31
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/subscriptions/get-preapproval-plan/get
32
32
  def get(preapproval_plan_id, request_options: nil)
33
- _get(uri: "/preapproval_plan/#{preapproval_plan_id}", request_options: request_options)
33
+ _get(uri: "/preapproval_plan/#{_path_param(preapproval_plan_id)}", request_options: request_options)
34
34
  end
35
35
 
36
36
  # Creates a new subscription plan.
@@ -57,7 +57,7 @@ module Mercadopago
57
57
  def update(preapproval_plan_id, preapproval_plan_data, request_options: nil)
58
58
  raise TypeError, 'Param preapproval_plan_data must be a Hash' unless preapproval_plan_data.is_a?(Hash)
59
59
 
60
- _put(uri: "/preapproval_plan/#{preapproval_plan_id}", data: preapproval_plan_data, request_options: request_options)
60
+ _put(uri: "/preapproval_plan/#{_path_param(preapproval_plan_id)}", data: preapproval_plan_data, request_options: request_options)
61
61
  end
62
62
  end
63
63
  end
@@ -17,7 +17,7 @@ module Mercadopago
17
17
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with preference details
18
18
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-pro/preferences/get-preference/get
19
19
  def get(preference_id, request_options: nil)
20
- _get(uri: "/checkout/preferences/#{preference_id}", request_options: request_options)
20
+ _get(uri: "/checkout/preferences/#{_path_param(preference_id)}", request_options: request_options)
21
21
  end
22
22
 
23
23
  # Creates a new Checkout Pro preference.
@@ -44,7 +44,7 @@ module Mercadopago
44
44
  def update(preference_id, preference_data, request_options: nil)
45
45
  raise TypeError, 'Param preference_data must be a Hash' unless preference_data.is_a?(Hash)
46
46
 
47
- _put(uri: "/checkout/preferences/#{preference_id}", data: preference_data, request_options: request_options)
47
+ _put(uri: "/checkout/preferences/#{_path_param(preference_id)}", data: preference_data, request_options: request_options)
48
48
  end
49
49
  end
50
50
  end
@@ -17,7 +17,7 @@ module Mercadopago
17
17
  # @return [Hash{Symbol => Object}] +:status+ and +:response+ with an array of refunds
18
18
  # @see https://www.mercadopago.com/developers/en/reference/online-payments/checkout-api-payments/get-refunds/get
19
19
  def list(payment_id, request_options: nil)
20
- _get(uri: "/v1/payments/#{payment_id}/refunds", request_options: request_options)
20
+ _get(uri: "/v1/payments/#{_path_param(payment_id)}/refunds", request_options: request_options)
21
21
  end
22
22
 
23
23
  # Creates a full or partial refund on a payment.
@@ -34,7 +34,7 @@ module Mercadopago
34
34
  def create(payment_id, refund_data: nil, request_options: nil)
35
35
  raise TypeError, 'Param refund_data must be a Hash' unless refund_data.nil? || refund_data.is_a?(Hash)
36
36
 
37
- _post(uri: "/v1/payments/#{payment_id}/refunds", data: refund_data, request_options: request_options)
37
+ _post(uri: "/v1/payments/#{_path_param(payment_id)}/refunds", data: refund_data, request_options: request_options)
38
38
  end
39
39
  end
40
40
  end
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 = '3.2.0'
5
+ gem.version = '3.2.1'
6
6
  gem.required_ruby_version = '>= 3.3.0'
7
7
  gem.author = 'Mercado Pago'
8
8
  gem.description = 'Mercado Pago Ruby SDK'
@@ -0,0 +1,14 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/mercadopago'
5
+
6
+ require 'minitest/autorun'
7
+
8
+ class TestPathParam < Minitest::Test
9
+ def test_path_param_escapes_path_traversal
10
+ base = Mercadopago::MPBase.new(Mercadopago::RequestOptions.new(access_token: 'token'), nil)
11
+
12
+ assert_equal '..%2F..%2Fapplications%2F123', base.send(:_path_param, '../../applications/123')
13
+ end
14
+ end
@@ -60,15 +60,27 @@ class TestPayment < Minitest::Test
60
60
  phone: {
61
61
  area_code: '011',
62
62
  number: '987654321'
63
+ },
64
+ authentication_type: 'WEB',
65
+ is_prime_user: false,
66
+ is_first_purchase_online: false,
67
+ last_purchase: '2024-01-01T00:00:00Z',
68
+ identification: {
69
+ type: 'CPF',
70
+ number: '19119119100'
63
71
  }
64
72
  },
65
73
  shipments: {
74
+ express_shipment: false,
75
+ local_pickup: false,
66
76
  receiver_address: {
67
77
  street_name: 'Av das Nacoes Unidas',
68
78
  street_number: 3003,
69
79
  zip_code: '06233200',
70
80
  city_name: 'Buzios',
71
- state_name: 'Rio de Janeiro'
81
+ state_name: 'Rio de Janeiro',
82
+ floor: '3',
83
+ apartment: 'B'
72
84
  }
73
85
  }
74
86
  }
@@ -136,15 +148,27 @@ class TestPayment < Minitest::Test
136
148
  phone: {
137
149
  area_code: '011',
138
150
  number: '987654321'
151
+ },
152
+ authentication_type: 'WEB',
153
+ is_prime_user: false,
154
+ is_first_purchase_online: false,
155
+ last_purchase: '2024-01-01T00:00:00Z',
156
+ identification: {
157
+ type: 'CPF',
158
+ number: '19119119100'
139
159
  }
140
160
  },
141
161
  shipments: {
162
+ express_shipment: false,
163
+ local_pickup: false,
142
164
  receiver_address: {
143
165
  street_name: 'Av das Nacoes Unidas',
144
166
  street_number: 3003,
145
167
  zip_code: '06233200',
146
168
  city_name: 'Buzios',
147
- state_name: 'Rio de Janeiro'
169
+ state_name: 'Rio de Janeiro',
170
+ floor: '3',
171
+ apartment: 'B'
148
172
  }
149
173
  }
150
174
  }
@@ -208,15 +232,27 @@ class TestPayment < Minitest::Test
208
232
  phone: {
209
233
  area_code: '011',
210
234
  number: '987654321'
235
+ },
236
+ authentication_type: 'WEB',
237
+ is_prime_user: false,
238
+ is_first_purchase_online: false,
239
+ last_purchase: '2024-01-01T00:00:00Z',
240
+ identification: {
241
+ type: 'CPF',
242
+ number: '19119119100'
211
243
  }
212
244
  },
213
245
  shipments: {
246
+ express_shipment: false,
247
+ local_pickup: false,
214
248
  receiver_address: {
215
249
  street_name: 'Av das Nacoes Unidas',
216
250
  street_number: 3003,
217
251
  zip_code: '06233200',
218
252
  city_name: 'Buzios',
219
- state_name: 'Rio de Janeiro'
253
+ state_name: 'Rio de Janeiro',
254
+ floor: '3',
255
+ apartment: 'B'
220
256
  }
221
257
  }
222
258
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadopago-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mercado Pago
@@ -176,6 +176,7 @@ files:
176
176
  - examples/order/transaction/update.rb
177
177
  - examples/point/create_payment_intent.rb
178
178
  - examples/preference/create.rb
179
+ - examples/preference/create_with_industry_fields.rb
179
180
  - lib/mercadopago.rb
180
181
  - lib/mercadopago/config/config.rb
181
182
  - lib/mercadopago/config/request_options.rb
@@ -214,6 +215,7 @@ files:
214
215
  - tests/test_oauth.rb
215
216
  - tests/test_order.rb
216
217
  - tests/test_order_transaction.rb
218
+ - tests/test_path_param.rb
217
219
  - tests/test_payment.rb
218
220
  - tests/test_payment_methods.rb
219
221
  - tests/test_point.rb
@@ -257,6 +259,7 @@ test_files:
257
259
  - tests/test_oauth.rb
258
260
  - tests/test_order.rb
259
261
  - tests/test_order_transaction.rb
262
+ - tests/test_path_param.rb
260
263
  - tests/test_payment.rb
261
264
  - tests/test_payment_methods.rb
262
265
  - tests/test_point.rb