Class: MethodRuby::Resources::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/method_ruby/resources/payments.rb,
lib/method_ruby/resources/payments/reversals.rb

Overview

ACH and clearing payments

Defined Under Namespace

Classes: Reversals

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Payments

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Payments.

Parameters:



205
206
207
208
# File 'lib/method_ruby/resources/payments.rb', line 205

def initialize(client:)
  @client = client
  @reversals = MethodRuby::Resources::Payments::Reversals.new(client: client)
end

Instance Attribute Details

#reversalsMethodRuby::Resources::Payments::Reversals (readonly)

Reversals for payments



9
10
11
# File 'lib/method_ruby/resources/payments.rb', line 9

def reversals
  @reversals
end

Instance Method Details

#create(amount:, description:, destination:, source:, method_version:, dry_run: nil, fee: nil, metadata: nil, reversal_account: nil, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::PaymentCreateResponse

Some parameter documentations has been truncated, see Models::PaymentCreateParams for more details.

Creates a new payment to transfer funds from a source account to a destination account.

Parameters:

  • amount (Integer)

    Body param: Payment amount in cents.

  • description (String)

    Body param: Human-readable description for the payment.

  • destination (String)

    Body param: The destination account ID.

  • source (String)

    Body param: The source account ID.

  • method_version (Symbol, MethodRuby::Models::PaymentCreateParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • dry_run (Boolean)

    Body param: Validate the payment request without moving funds.

  • fee (MethodRuby::Models::PaymentCreateParams::Fee)

    Body param: Optional fee configuration for the payment.

  • metadata (Hash{Symbol=>Object}, nil)

    Body param: Arbitrary key-value metadata attached to the resource.

  • reversal_account (String)

    Body param: Account ID to use for the reversal leg of the payment, if applicable

  • idempotency_key (String)

    Header param: Idempotency key for safely retrying a write request. Reuse the sam

  • request_options (MethodRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/method_ruby/resources/payments.rb', line 44

def create(params)
  parsed, options = MethodRuby::PaymentCreateParams.dump_request(params)
  header_params = {method_version: "method-version", idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "payments",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: MethodRuby::Models::PaymentCreateResponse,
    security: {secret_key: true},
    options: options
  )
end

#delete(payment_id, method_version:, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::PaymentDeleteResponse

Some parameter documentations has been truncated, see Models::PaymentDeleteParams for more details.

Cancels a pending payment. Only payments with a ‘pending` status can be canceled.

Parameters:

Returns:

See Also:



187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/method_ruby/resources/payments.rb', line 187

def delete(payment_id, params)
  parsed, options = MethodRuby::PaymentDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["payments/%1$s", payment_id],
    headers: parsed.transform_keys(
      method_version: "method-version",
      idempotency_key: "idempotency-key"
    ),
    model: MethodRuby::Models::PaymentDeleteResponse,
    security: {secret_key: true},
    options: options
  )
end

#list(method_version:, acc_id: nil, destination: nil, destination_holder_id: nil, expand: nil, from_date: nil, holder_id: nil, page: nil, page_cursor: nil, page_limit: nil, reversal_id: nil, source: nil, source_holder_id: nil, status: nil, to_date: nil, type: nil, request_options: {}) ⇒ MethodRuby::Models::PaymentListResponse

Some parameter documentations has been truncated, see Models::PaymentListParams for more details.

Returns a paginated list of payments. Results can be filtered by status, type, accounts, holders, reversal, and date range.

Parameters:

  • method_version (Symbol, MethodRuby::Models::PaymentListParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • acc_id (String)

    Query param: Filter payments by either the source or destination account ID.

  • destination (String)

    Query param: Filter payments by destination account ID.

  • destination_holder_id (String)

    Query param: Filter payments by destination entity ID.

  • expand (Array<Symbol, MethodRuby::Models::PaymentListParams::Expand>)

    Query param: Expand payment source or destination accounts inline. Nested accoun

  • from_date (Date)

    Query param: Filter results from this date (inclusive, YYYY-MM-DD format).

  • holder_id (String)

    Query param: Filter payments by either the source or destination entity ID.

  • page (Integer)

    Query param: Page number for pagination (1-indexed).

  • page_cursor (String)

    Query param: Cursor for cursor-based pagination. Use the value from ‘Pagination-

  • page_limit (Integer)

    Query param: Number of items per page.

  • reversal_id (String)

    Query param: Filter payments by reversal ID.

  • source (String)

    Query param: Filter payments by source account ID.

  • source_holder_id (String)

    Query param: Filter payments by source entity ID.

  • status (Symbol, MethodRuby::Models::PaymentListParams::Status)

    Query param: Filter payments by status.

  • to_date (Date)

    Query param: Filter results to this date (inclusive, YYYY-MM-DD format).

  • type (Symbol, MethodRuby::Models::PaymentListParams::Type)

    Query param: Filter payments by payment type.

  • request_options (MethodRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/method_ruby/resources/payments.rb', line 136

def list(params)
  query_params =
    [
      :acc_id,
      :destination,
      :destination_holder_id,
      :expand,
      :from_date,
      :holder_id,
      :page,
      :page_cursor,
      :page_limit,
      :reversal_id,
      :source,
      :source_holder_id,
      :status,
      :to_date,
      :type
    ]
  parsed, options = MethodRuby::PaymentListParams.dump_request(params)
  query = MethodRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "payments",
    query: query,
    headers: parsed.except(*query_params).transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::PaymentListResponse,
    security: {secret_key: true},
    options: options
  )
end

#retrieve(payment_id, method_version:, expand: nil, request_options: {}) ⇒ MethodRuby::Models::PaymentRetrieveResponse

Some parameter documentations has been truncated, see Models::PaymentRetrieveParams for more details.

Retrieves a payment by its unique identifier.

Parameters:

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/method_ruby/resources/payments.rb', line 76

def retrieve(payment_id, params)
  query_params = [:expand]
  parsed, options = MethodRuby::PaymentRetrieveParams.dump_request(params)
  query = MethodRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["payments/%1$s", payment_id],
    query: query,
    headers: parsed.except(*query_params).transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::PaymentRetrieveResponse,
    security: {secret_key: true},
    options: options
  )
end