Class: WhopSDK::Resources::Invoices

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/invoices.rb

Overview

Invoices

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Invoices

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

Parameters:



267
268
269
# File 'lib/whop_sdk/resources/invoices.rb', line 267

def initialize(client:)
  @client = client
end

Instance Method Details

#create(body:, request_options: {}) ⇒ WhopSDK::Models::Invoice

Create an invoice for a customer. The invoice can be charged automatically using a stored payment method, or sent to the customer for manual payment.

Required permissions:

  • ‘invoice:create`



23
24
25
26
27
28
29
30
31
32
# File 'lib/whop_sdk/resources/invoices.rb', line 23

def create(params)
  parsed, options = WhopSDK::InvoiceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "invoices",
    body: parsed[:body],
    model: WhopSDK::Invoice,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Boolean

Delete a draft invoice.

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The unique identifier of the draft invoice to delete.

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

Returns:

  • (Boolean)

See Also:



182
183
184
185
186
187
188
189
# File 'lib/whop_sdk/resources/invoices.rb', line 182

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["invoices/%1$s", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#list(after: nil, before: nil, collection_methods: nil, company_id: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, product_ids: nil, statuses: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::InvoiceListItem>

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

Returns a paginated list of invoices for a company, with optional filtering by product, status, collection method, and creation date.

Required permissions:

  • ‘invoice:basic:read`

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • collection_methods (Array<Symbol, WhopSDK::Models::CollectionMethod>, nil)

    Filter invoices by their collection method.

  • company_id (String, nil)

    The unique identifier of the company to list invoices for.

  • created_after (Time, nil)

    Only return invoices created after this timestamp.

  • created_before (Time, nil)

    Only return invoices created before this timestamp.

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order (Symbol, WhopSDK::Models::InvoiceListParams::Order, nil)

    Which columns can be used to sort.

  • product_ids (Array<String>, nil)

    Filter invoices to only those associated with these specific product identifiers

  • statuses (Array<Symbol, WhopSDK::Models::InvoiceStatus>, nil)

    Filter invoices by their current status.

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

Returns:

See Also:



154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/whop_sdk/resources/invoices.rb', line 154

def list(params = {})
  parsed, options = WhopSDK::InvoiceListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "invoices",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::InvoiceListItem,
    options: options
  )
end

#mark_paid(id, request_options: {}) ⇒ Boolean

Mark an open invoice as paid when payment was collected outside of Whop.

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The unique identifier of the invoice to mark as paid.

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

Returns:

  • (Boolean)

See Also:



206
207
208
209
210
211
212
213
# File 'lib/whop_sdk/resources/invoices.rb', line 206

def mark_paid(id, params = {})
  @client.request(
    method: :post,
    path: ["invoices/%1$s/mark_paid", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#mark_uncollectible(id, request_options: {}) ⇒ Boolean

Mark an open invoice as uncollectible when payment is not expected.

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The unique identifier of the invoice to mark as uncollectible.

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

Returns:

  • (Boolean)

See Also:



230
231
232
233
234
235
236
237
# File 'lib/whop_sdk/resources/invoices.rb', line 230

def mark_uncollectible(id, params = {})
  @client.request(
    method: :post,
    path: ["invoices/%1$s/mark_uncollectible", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Invoice

Retrieves the details of an existing invoice.

Required permissions:

  • ‘invoice:basic:read`

Parameters:

  • id (String)

    The unique identifier of the invoice, or a secure token.

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

Returns:

See Also:



49
50
51
52
53
54
55
56
# File 'lib/whop_sdk/resources/invoices.rb', line 49

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["invoices/%1$s", id],
    model: WhopSDK::Invoice,
    options: params[:request_options]
  )
end

#update(id, automatically_finalizes_at: nil, billing_address: nil, charge_buyer_fee: nil, collection_method: nil, customer_name: nil, due_date: nil, email_address: nil, line_items: nil, mailing_address_id: nil, member_id: nil, payment_method_id: nil, plan: nil, subscription_billing_anchor_at: nil, request_options: {}) ⇒ WhopSDK::Models::Invoice

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

Update a draft invoice’s details.

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The unique identifier of the invoice to update.

  • automatically_finalizes_at (Time, nil)

    The date and time when the invoice will be automatically finalized. For charge_a

  • billing_address (WhopSDK::Models::InvoiceUpdateParams::BillingAddress, nil)

    Inline billing address to create or update a mailing address for this invoice.

  • charge_buyer_fee (Boolean, nil)

    Whether to charge the customer a buyer fee on this invoice.

  • collection_method (Symbol, WhopSDK::Models::CollectionMethod, nil)

    The method of collection for an invoice.

  • customer_name (String, nil)

    The name of the customer.

  • due_date (Time, nil)

    The date by which the invoice must be paid.

  • email_address (String, nil)

    The email address of the customer.

  • line_items (Array<WhopSDK::Models::InvoiceUpdateParams::LineItem>, nil)

    Line items that break down the invoice total.

  • mailing_address_id (String, nil)

    The unique identifier of an existing mailing address to attach.

  • member_id (String, nil)

    The unique identifier of a member to assign as the customer.

  • payment_method_id (String, nil)

    The unique identifier of the payment method to charge.

  • plan (WhopSDK::Models::InvoiceUpdateParams::Plan, nil)

    Updated plan attributes.

  • subscription_billing_anchor_at (Time, nil)

    The date that defines when the subscription billing cycle should start.

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

Returns:

See Also:



102
103
104
105
106
107
108
109
110
111
# File 'lib/whop_sdk/resources/invoices.rb', line 102

def update(id, params = {})
  parsed, options = WhopSDK::InvoiceUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["invoices/%1$s", id],
    body: parsed,
    model: WhopSDK::Invoice,
    options: options
  )
end

#void(id, request_options: {}) ⇒ Boolean

Void an open invoice so it can no longer be paid. Voiding is permanent and cannot be undone.

Required permissions:

  • ‘invoice:update`

Parameters:

  • id (String)

    The unique identifier of the invoice to void.

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

Returns:

  • (Boolean)

See Also:



255
256
257
258
259
260
261
262
# File 'lib/whop_sdk/resources/invoices.rb', line 255

def void(id, params = {})
  @client.request(
    method: :post,
    path: ["invoices/%1$s/void", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end