Class: Mercadopago::Refund

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

Overview

Issues full or partial refunds on approved payments.

Refunds can be created within 180 days of payment approval. The seller’s account must hold enough funds to cover the refund; otherwise the API returns a 400 Bad Request.

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

Creates a full or partial refund on a payment.

Omit refund_data for a full refund, or pass { amount: 10.0 } for a partial refund.

Parameters:

  • payment_id (Integer, String)

    MercadoPago payment ID

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

    optional refund attributes (e.g. { amount: 10.0 })

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the created refund

Raises:

  • (TypeError)

    if refund_data is not a Hash

See Also:



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

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

  _post(uri: "/v1/payments/#{payment_id}/refunds", data: refund_data, request_options: request_options)
end

#list(payment_id, request_options: nil) ⇒ Hash{Symbol => Object}

Lists all refunds for a given payment.

Parameters:

  • payment_id (Integer, String)

    MercadoPago payment ID

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with an array of refunds

See Also:



19
20
21
# File 'lib/mercadopago/resources/refund.rb', line 19

def list(payment_id, request_options: nil)
  _get(uri: "/v1/payments/#{payment_id}/refunds", request_options: request_options)
end