Class: Pago::V2026_04::Services::Refunds

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/refunds.rb,
sig/pago/v2026_04/generated.rbs

Instance Attribute Summary

Attributes inherited from Service

#client

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Pago::Service

Instance Method Details

#create(body: {}) ⇒ Models::Refund

Create a refund.

Scopes: refunds:write

Parameters:

  • body (Hash, Models::RefundCreate) (defaults to: {})

    the request body.

  • body: (Object) (defaults to: {})

Returns:

Raises:



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/pago/v2026_04/services/refunds.rb', line 56

def create(body: {})
  data = client.request(
    http_method: "POST",
    path: "/v1/refunds/",
    path_params: {},
    query: {},
    body: body,
    response_type: :json,
    errors: { 403 => Errors::RefundedAlready, 422 => Errors::HTTPValidationError }
  )
  Models::Refund.from_json(data)
end

#list(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, page: 1, limit: 10, sorting: ["-created_at"]) ⇒ Models::ListResourceRefund

List refunds.

Scopes: refunds:read refunds:write

Parameters:

  • id (String, Array<String>, nil) (defaults to: nil)

    Filter by refund ID.

  • organization_id (String, Array<String>, nil) (defaults to: nil)

    Filter by organization ID.

  • order_id (String, Array<String>, nil) (defaults to: nil)

    Filter by order ID.

  • subscription_id (String, Array<String>, nil) (defaults to: nil)

    Filter by subscription ID.

  • customer_id (String, Array<String>, nil) (defaults to: nil)

    Filter by customer ID.

  • external_customer_id (String, Array<String>, nil) (defaults to: nil)

    Filter by customer external ID.

  • succeeded (Boolean, nil) (defaults to: nil)

    Filter by succeeded.

  • page (Integer) (defaults to: 1)

    Page number, defaults to 1.

  • limit (Integer) (defaults to: 10)

    Size of a page, defaults to 10. Maximum is 100.

  • sorting (Array<String>, nil) (defaults to: ["-created_at"])

    Sorting criterion. Several criteria can be used simultaneously and will be applied in order. Add a minus sign - before the criteria name to sort by descending order.

  • id: (Object) (defaults to: nil)
  • organization_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • subscription_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • external_customer_id: (Object) (defaults to: nil)
  • succeeded: (Boolean, nil) (defaults to: nil)
  • page: (Integer, nil) (defaults to: 1)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-created_at"])

Returns:

Raises:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pago/v2026_04/services/refunds.rb', line 24

def list(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, page: 1, limit: 10, sorting: ["-created_at"])
  data = client.request(
    http_method: "GET",
    path: "/v1/refunds/",
    path_params: {},
    query: { "id" => id, "organization_id" => organization_id, "order_id" => order_id, "subscription_id" => subscription_id, "customer_id" => customer_id, "external_customer_id" => external_customer_id, "succeeded" => succeeded, "page" => page, "limit" => limit, "sorting" => sorting },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourceRefund.from_json(data)
end

#list_each(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, limit: 10, sorting: ["-created_at"]) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • id: (Object) (defaults to: nil)
  • organization_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • subscription_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • external_customer_id: (Object) (defaults to: nil)
  • succeeded: (Boolean, nil) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-created_at"])

Yield Parameters:

Returns:



40
41
42
43
44
45
# File 'lib/pago/v2026_04/services/refunds.rb', line 40

def list_each(id: nil, organization_id: nil, order_id: nil, subscription_id: nil, customer_id: nil, external_customer_id: nil, succeeded: nil, limit: 10, sorting: ["-created_at"], &block)
  paginator = ::Pago::Paginator.new do |page_number|
    list(id: id, organization_id: organization_id, order_id: order_id, subscription_id: subscription_id, customer_id: customer_id, external_customer_id: external_customer_id, succeeded: succeeded, page: page_number, limit: limit, sorting: sorting)
  end
  block ? paginator.each(&block) : paginator
end