Class: Pago::V2026_04::Services::Payments

Inherits:
Service
  • Object
show all
Defined in:
lib/pago/v2026_04/services/payments.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

#get(id) ⇒ Object

Get a payment by ID.

Scopes: payments:read

Parameters:

  • id (String)

    The payment ID.

Returns:

  • (Object)

Raises:



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

def get(id)
  data = client.request(
    http_method: "GET",
    path: "/v1/payments/{id}",
    path_params: { "id" => id },
    query: {},
    response_type: :json,
    errors: { 404 => Errors::ResourceNotFound, 422 => Errors::HTTPValidationError }
  )
  Unions::Payment.from_json(data)
end

#list(organization_id: nil, checkout_id: nil, order_id: nil, customer_id: nil, status: nil, method: nil, customer_email: nil, page: 1, limit: 10, sorting: ["-created_at"]) ⇒ Models::ListResourcePayment

List payments.

Scopes: payments:read

Parameters:

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

    Filter by organization ID.

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

    Filter by checkout ID.

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

    Filter by order ID.

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

    Filter by customer ID.

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

    Filter by payment status.

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

    Filter by payment method.

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

    Filter by customer email.

  • 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.

  • organization_id: (Object) (defaults to: nil)
  • checkout_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • status: (Object) (defaults to: nil)
  • method: (Object) (defaults to: nil)
  • customer_email: (Object) (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/payments.rb', line 24

def list(organization_id: nil, checkout_id: nil, order_id: nil, customer_id: nil, status: nil, method: nil, customer_email: nil, page: 1, limit: 10, sorting: ["-created_at"])
  data = client.request(
    http_method: "GET",
    path: "/v1/payments/",
    path_params: {},
    query: { "organization_id" => organization_id, "checkout_id" => checkout_id, "order_id" => order_id, "customer_id" => customer_id, "status" => status, "method" => method, "customer_email" => customer_email, "page" => page, "limit" => limit, "sorting" => sorting },
    response_type: :json,
    errors: { 422 => Errors::HTTPValidationError }
  )
  Models::ListResourcePayment.from_json(data)
end

#list_each(organization_id: nil, checkout_id: nil, order_id: nil, customer_id: nil, status: nil, method: nil, customer_email: nil, limit: 10, sorting: ["-created_at"]) {|item| ... } ⇒ Pago::Paginator

Enumerate every item of list, fetching pages on demand.

Parameters:

  • organization_id: (Object) (defaults to: nil)
  • checkout_id: (Object) (defaults to: nil)
  • order_id: (Object) (defaults to: nil)
  • customer_id: (Object) (defaults to: nil)
  • status: (Object) (defaults to: nil)
  • method: (Object) (defaults to: nil)
  • customer_email: (Object) (defaults to: nil)
  • limit: (Integer, nil) (defaults to: 10)
  • sorting: (Array[String], nil) (defaults to: ["-created_at"])

Yield Parameters:

  • item (Object)

Returns:



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

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