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



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

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



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

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



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

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