Class: Mercadopago::Order
- Defined in:
- lib/mercadopago/resources/order.rb
Overview
Manages orders through the Checkout API v1.
An order groups one or more transactions and supports the full lifecycle: create, process, capture, refund, cancel, and search. Use OrderTransaction to manage individual transactions within an order.
Instance Method Summary collapse
-
#cancel(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Cancels an order that has not yet been captured.
-
#capture(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Captures a previously authorized order.
-
#create(order_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new order.
-
#get(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single order by ID.
-
#process(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Processes (confirms) an order, triggering payment execution.
-
#refund(order_id, refund_data: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Refunds an order (full or partial).
-
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches orders matching the given filters.
Methods inherited from MPBase
#_check_headers, #_check_request_options, #_delete, #_get, #_post, #_put, #initialize
Constructor Details
This class inherits a constructor from Mercadopago::MPBase
Instance Method Details
#cancel(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Cancels an order that has not yet been captured.
67 68 69 |
# File 'lib/mercadopago/resources/order.rb', line 67 def cancel(order_id, request_options: nil) _post(uri: "/v1/orders/#{order_id}/cancel", data: nil, request_options: ) end |
#capture(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Captures a previously authorized order.
76 77 78 |
# File 'lib/mercadopago/resources/order.rb', line 76 def capture(order_id, request_options: nil) _post(uri: "/v1/orders/#{order_id}/capture", data: nil, request_options: ) end |
#create(order_data, request_options: nil) ⇒ Hash{Symbol => Object}
Creates a new order.
20 21 22 23 24 |
# File 'lib/mercadopago/resources/order.rb', line 20 def create(order_data, request_options: nil) raise TypeError, 'Param order_data must be a Hash' unless order_data.is_a?(Hash) _post(uri: '/v1/orders', data: order_data, request_options: ) end |
#get(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Retrieves a single order by ID.
31 32 33 |
# File 'lib/mercadopago/resources/order.rb', line 31 def get(order_id, request_options: nil) _get(uri: "/v1/orders/#{order_id}", request_options: ) end |
#process(order_id, request_options: nil) ⇒ Hash{Symbol => Object}
Processes (confirms) an order, triggering payment execution.
40 41 42 |
# File 'lib/mercadopago/resources/order.rb', line 40 def process(order_id, request_options: nil) _post(uri: "/v1/orders/#{order_id}/process", data: nil,request_options: ) end |
#refund(order_id, refund_data: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Refunds an order (full or partial).
Omit refund_data for a full refund, or pass { amount: 10.0 } for a partial refund.
54 55 56 57 58 59 60 |
# File 'lib/mercadopago/resources/order.rb', line 54 def refund(order_id, refund_data: nil, request_options: nil) unless refund_data.nil? raise TypeError, 'Param refund_data must be a Hash' unless refund_data.is_a?(Hash) end _post(uri: "/v1/orders/#{order_id}/refund", data: refund_data, request_options: ) end |
#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}
Searches orders matching the given filters.
85 86 87 |
# File 'lib/mercadopago/resources/order.rb', line 85 def search(filters: nil, request_options: nil) _get(uri: '/v1/orders', params: filters, request_options: ) end |