Class: Stigg::Resources::V1::Customers::PaymentMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/stigg/resources/v1/customers/payment_method.rb

Overview

Operations related to customers

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ PaymentMethod

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

Parameters:



64
65
66
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 64

def initialize(client:)
  @client = client
end

Instance Method Details

#attach(id, integration_id:, payment_method_id:, vendor_identifier:, billing_currency: nil, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse

Attaches a payment method to a customer for billing. Required for paid subscriptions when integrated with a billing provider.

Parameters:

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 29

def attach(id, params)
  parsed, options = Stigg::V1::Customers::PaymentMethodAttachParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/v1/customers/%1$s/payment-method", id],
    body: parsed,
    model: Stigg::V1::CustomerResponse,
    options: options
  )
end

#detach(id, request_options: {}) ⇒ Stigg::Models::V1::CustomerResponse

Removes the payment method from a customer. Ensure active paid subscriptions have an alternative payment method.

Parameters:

  • id (String)

    The unique identifier of the entity

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

Returns:

See Also:



52
53
54
55
56
57
58
59
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 52

def detach(id, params = {})
  @client.request(
    method: :delete,
    path: ["api/v1/customers/%1$s/payment-method", id],
    model: Stigg::V1::CustomerResponse,
    options: params[:request_options]
  )
end