Class: Mercadopago::Invoice

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

Overview

Provides read access to subscription invoices (authorized payments).

Each invoice corresponds to a billing cycle of a Preapproval and tracks the charge amount, status, retry attempts, and the resulting payment. Use #get and #search to monitor billing cycles and their outcomes.

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

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

Retrieves a single invoice (authorized payment) by its ID.

Parameters:

  • invoice_id (Integer, String)

    unique invoice identifier

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the full invoice object including :status, :transaction_amount, :preapproval_id, and :payment details

See Also:



21
22
23
# File 'lib/mercadopago/resources/invoice.rb', line 21

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

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

Searches invoices matching the given filters.

Parameters:

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

    query parameters such as :preapproval_id, :status, :payer_id, :offset, and :limit

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with :paging metadata and a :results list of matching invoices

Raises:

  • (TypeError)

    if filters is not a Hash

See Also:



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

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

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