Class: Mercadopago::OrderTransaction

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

Overview

Manages individual transactions within an Order.

Each transaction represents a payment attempt or payment method attached to an order. You can add, update, or remove transactions before the order is processed.

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(order_id, order_transaction_data, request_options: nil) ⇒ Hash{Symbol => Object}

Adds a new transaction to an order.

Parameters:

  • order_id (String)

    parent order ID

  • order_transaction_data (Hash)

    transaction attributes (payment method, amount, etc.)

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the created transaction

Raises:

  • (TypeError)

    if order_transaction_data is not a Hash



21
22
23
24
25
# File 'lib/mercadopago/resources/order_transaction.rb', line 21

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

  _post(uri: "/v1/orders/#{order_id}/transactions", data: order_transaction_data, request_options: request_options)
end

#delete(order_id, transaction_id, request_options: nil) ⇒ Hash{Symbol => Object}

Removes a transaction from an order.

Parameters:

  • order_id (String)

    parent order ID

  • transaction_id (String)

    transaction ID to delete

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response



47
48
49
# File 'lib/mercadopago/resources/order_transaction.rb', line 47

def delete(order_id, transaction_id, request_options: nil)
  _delete(uri: "/v1/orders/#{order_id}/transactions/#{transaction_id}", request_options: request_options)
end

#update(order_id, transaction_id, order_transaction_data, request_options: nil) ⇒ Hash{Symbol => Object}

Updates an existing transaction within an order.

Parameters:

  • order_id (String)

    parent order ID

  • transaction_id (String)

    transaction ID to update

  • order_transaction_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 transaction

Raises:

  • (TypeError)

    if order_transaction_data is not a Hash



35
36
37
38
39
# File 'lib/mercadopago/resources/order_transaction.rb', line 35

def update(order_id, transaction_id, order_transaction_data, request_options: nil)
  raise TypeError, 'Param order_transaction_data must be a Hash' unless order_transaction_data.is_a?(Hash)

  _put(uri: "/v1/orders/#{order_id}/transactions/#{transaction_id}", data: order_transaction_data, request_options: request_options)
end