Class: MetronomeSDK::Resources::V1::Payments

Inherits:
Object
  • Object
show all
Defined in:
lib/metronome_sdk/resources/v1/payments.rb

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:



96
97
98
# File 'lib/metronome_sdk/resources/v1/payments.rb', line 96

def initialize(client:)
  @client = client
end

Instance Method Details

#attempt(customer_id: , invoice_id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::PaymentAttemptResponse

Trigger a new attempt by canceling any existing attempts for this invoice and creating a new Payment. This will trigger another attempt to charge the Customer’s configured Payment Gateway. Payment can only be attempted if all of the following are true:

  • The Metronome Invoice is finalized

  • PLG Invoicing is configured for the Customer

  • You cannot attempt payments for invoices that have already been ‘paid` or `voided`.

Attempting to payment on an ineligible Invoice or Customer will result in a ‘400` response.

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
68
69
# File 'lib/metronome_sdk/resources/v1/payments.rb', line 60

def attempt(params)
  parsed, options = MetronomeSDK::V1::PaymentAttemptParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/payments/attempt",
    body: parsed,
    model: MetronomeSDK::Models::V1::PaymentAttemptResponse,
    options: options
  )
end

#cancel(customer_id: , invoice_id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::PaymentCancelResponse

Cancel an existing payment attempt for an invoice.

Parameters:

Returns:

See Also:



82
83
84
85
86
87
88
89
90
91
# File 'lib/metronome_sdk/resources/v1/payments.rb', line 82

def cancel(params)
  parsed, options = MetronomeSDK::V1::PaymentCancelParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/payments/cancel",
    body: parsed,
    model: MetronomeSDK::Models::V1::PaymentCancelResponse,
    options: options
  )
end

#list(customer_id: , invoice_id: , limit: nil, next_page: nil, statuses: nil, request_options: {}) ⇒ MetronomeSDK::Internal::BodyCursorPage<MetronomeSDK::Models::V1::Payment>

Fetch all payment attempts for the given invoice.

Parameters:

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/metronome_sdk/resources/v1/payments.rb', line 26

def list(params)
  parsed, options = MetronomeSDK::V1::PaymentListParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/payments/list",
    body: parsed,
    page: MetronomeSDK::Internal::BodyCursorPage,
    model: MetronomeSDK::V1::Payment,
    options: options
  )
end