Class: Mercadopago::DisbursementRefund

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

Overview

Manages refunds on individual disbursements within an AdvancedPayment.

In marketplace split-payment scenarios each seller receives a separate disbursement. This resource allows refunding one specific disbursement (full or partial) or all disbursements at once.

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

Refunds a single disbursement (full or partial).

Omit amount for a full refund of the disbursement, or pass a specific amount for a partial refund.

Parameters:

  • advanced_payment_id (Integer, String)

    advanced payment ID

  • disbursement_id (Integer, String)

    disbursement ID within the advanced payment

  • amount (Float, nil) (defaults to: nil)

    partial refund amount; nil for a full refund

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with the created refund



39
40
41
42
43
44
# File 'lib/mercadopago/resources/disbursement_refund.rb', line 39

def create(advanced_payment_id, disbursement_id, amount: nil, request_options: nil)
  disbursement_refund_data = amount.nil? ? nil : { amount: amount }

  _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/disbursements/#{disbursement_id}/refunds",
        data: disbursement_refund_data, request_options: request_options)
end

#create_all(advanced_payment_id, request_options: nil) ⇒ Hash{Symbol => Object}

Refunds all disbursements of an advanced payment at once.

Parameters:

  • advanced_payment_id (Integer, String)

    advanced payment ID

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

    per-call configuration override

Returns:

  • (Hash{Symbol => Object})

    :status and :response with refund details



25
26
27
# File 'lib/mercadopago/resources/disbursement_refund.rb', line 25

def create_all(advanced_payment_id, request_options: nil)
  _post(uri: "/v1/advanced_payments/#{advanced_payment_id}/refunds", request_options: request_options)
end

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

Lists all refunds for an advanced payment.

Parameters:

  • advanced_payment_id (Integer, String)

    advanced 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



16
17
18
# File 'lib/mercadopago/resources/disbursement_refund.rb', line 16

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