Class: Mercadopago::MerchantOrder

Inherits:
MPBase
  • Object
show all
Defined in:
lib/mercadopago/resources/merchant_order.rb

Overview

Groups one or more payments into a single merchant order.

Merchant orders are useful for marketplace and multi-payment scenarios where you need to track the fulfilment status of several payments as a unit.

Instance Method Summary collapse

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

#create(merchant_order_data, request_options: nil) ⇒ Hash{Symbol => Object}

Creates a new merchant order.

Parameters:

  • merchant_order_data (Hash)

    order attributes (items, preference_id, etc.)

  • request_options (RequestOptions, nil) (defaults to: nil)

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the created order

Raises:

  • (TypeError)

    if merchant_order_data is not a Hash

See Also:



43
44
45
46
47
# File 'lib/mercadopago/resources/merchant_order.rb', line 43

def create(merchant_order_data, request_options: nil)
  raise TypeError, 'Param merchant_orders_object must be a Hash' unless merchant_order_data.is_a?(Hash)

  _post(uri: '/merchant_orders', data: merchant_order_data, request_options: request_options)
end

#get(merchant_order_id, request_options: nil) ⇒ Hash{Symbol => Object}

Retrieves a single merchant order by ID.

Parameters:

  • merchant_order_id (Integer, String)

    merchant order ID

  • request_options (RequestOptions, nil) (defaults to: nil)

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with order details

See Also:



32
33
34
# File 'lib/mercadopago/resources/merchant_order.rb', line 32

def get(merchant_order_id, request_options: nil)
  _get(uri: "/merchant_orders/#{merchant_order_id}", request_options: request_options)
end

#search(filters: nil, request_options: nil) ⇒ Hash{Symbol => Object}

Searches merchant orders matching the given filters.

Parameters:

  • filters (Hash, nil) (defaults to: nil)

    query parameters

  • request_options (RequestOptions, nil) (defaults to: nil)

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with search results

Raises:

  • (TypeError)

    if filters is not a Hash

See Also:



20
21
22
23
24
# File 'lib/mercadopago/resources/merchant_order.rb', line 20

def search(filters: nil, request_options: nil)
  raise TypeError, 'Param filters must be a Hash' unless filters.nil? || filters.is_a?(Hash)

  _get(uri: '/merchant_orders/search', filters: filters, request_options: request_options)
end

#update(merchant_order_id, merchant_order_data, request_options: nil) ⇒ Hash{Symbol => Object}

Updates an existing merchant order.

Parameters:

  • merchant_order_id (Integer, String)

    merchant order ID

  • merchant_order_data (Hash)

    fields to update

  • request_options (RequestOptions, nil) (defaults to: nil)

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the updated order

Raises:

  • (TypeError)

    if merchant_order_data is not a Hash

See Also:



57
58
59
60
61
62
# File 'lib/mercadopago/resources/merchant_order.rb', line 57

def update(merchant_order_id, merchant_order_data, request_options: nil)
  raise TypeError, 'Param merchant_orders_object must be a Hash' unless merchant_order_data.is_a?(Hash)

  _put(uri: "/merchant_orders/#{merchant_order_id}", data: merchant_order_data,
       request_options: request_options)
end