Class: MethodRuby::Resources::Simulate::Payments

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

Overview

Sandbox payment simulation

Defined Under Namespace

Classes: PaymentInstruments

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:



53
54
55
56
# File 'lib/method_ruby/resources/simulate/payments.rb', line 53

def initialize(client:)
  @client = client
  @payment_instruments = MethodRuby::Resources::Simulate::Payments::PaymentInstruments.new(client: client)
end

Instance Attribute Details

#payment_instrumentsMethodRuby::Resources::Simulate::Payments::PaymentInstruments (readonly)

Sandbox payment simulation



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

def payment_instruments
  @payment_instruments
end

Instance Method Details

#create(payment_id, status:, method_version:, error_code: nil, request_options: {}) ⇒ MethodRuby::Models::Simulate::PaymentCreateResponse

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

Updates the status of a payment in the sandbox environment. Use this to test payment lifecycle and status transition flows during development.

**Development only** - This endpoint is only available in the sandbox environment.

Parameters:

  • payment_id (String)

    Path param: Unique identifier for the payment.

  • status (String)

    Body param: The status to transition the payment to.

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

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

  • error_code (String)

    Body param: Error code for the simulated failure. Required when status is revers

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

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/method_ruby/resources/simulate/payments.rb', line 36

def create(payment_id, params)
  parsed, options = MethodRuby::Simulate::PaymentCreateParams.dump_request(params)
  header_params = {method_version: "method-version"}
  @client.request(
    method: :post,
    path: ["simulate/payments/%1$s", payment_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: MethodRuby::Models::Simulate::PaymentCreateResponse,
    security: {secret_key: true},
    options: options
  )
end