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:



85
86
87
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 85

def initialize(client:)
  @client = client
end

Instance Method Details

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

Some parameter documentations has been truncated, see Models::V1::Customers::PaymentMethodAttachParams for more details.

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

Parameters:

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 36

def attach(id, params)
  parsed, options = Stigg::V1::Customers::PaymentMethodAttachParams.dump_request(params)
  header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
  @client.request(
    method: :post,
    path: ["api/v1/customers/%1$s/payment-method", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Stigg::V1::CustomerResponse,
    options: options
  )
end

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

Some parameter documentations has been truncated, see Models::V1::Customers::PaymentMethodDetachParams for more details.

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

  • x_account_id (String)

    Account ID — optional when authenticating with a user JWT (Bearer token); falls

  • x_environment_id (String)

    Environment ID — required when authenticating with a user JWT (Bearer token) on

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

Returns:

See Also:



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/stigg/resources/v1/customers/payment_method.rb', line 68

def detach(id, params = {})
  parsed, options = Stigg::V1::Customers::PaymentMethodDetachParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["api/v1/customers/%1$s/payment-method", id],
    headers: parsed.transform_keys(
      x_account_id: "x-account-id",
      x_environment_id: "x-environment-id"
    ),
    model: Stigg::V1::CustomerResponse,
    options: options
  )
end