Nombaone.Invoices (Nomba One v0.1.0)

View Source

Invoices — read what the billing engine produced; void what should never be collected. You never create invoices — subscription cycles do.

Summary

Functions

List invoices, newest first. Optional filters: :customer_id, :subscription_id, :status, :limit, :cursor.

Retrieve an invoice by id. Common errors: 404 INVOICE_NOT_FOUND.

Void an open, unpaid invoice. Paid invoices can't be voided — refund the settlement instead. Accepts an optional :comment.

Functions

list(client, params \\ %{}, opts \\ [])

@spec list(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.Page.t()} | {:error, Nombaone.Error.t()}

List invoices, newest first. Optional filters: :customer_id, :subscription_id, :status, :limit, :cursor.

Note: the :status filter accepts draft | open | paid | void | uncollectiblenot partially_paid, even though an invoice object can carry that status.

Example

for invoice <- Nombaone.Invoices.list!(client, %{status: "open"}) do
  IO.inspect({invoice.id, invoice.amount_due_in_kobo})
end

list!(client, params \\ %{}, opts \\ [])

@spec list!(Nombaone.Client.t(), map(), keyword()) :: Nombaone.Page.t()

Raising variant of list/3.

retrieve(client, id, opts \\ [])

@spec retrieve(Nombaone.Client.t(), String.t(), keyword()) ::
  {:ok, Nombaone.Invoice.t()} | {:error, Nombaone.Error.t()}

Retrieve an invoice by id. Common errors: 404 INVOICE_NOT_FOUND.

retrieve!(client, id, opts \\ [])

@spec retrieve!(Nombaone.Client.t(), String.t(), keyword()) :: Nombaone.Invoice.t()

Raising variant of retrieve/3.

void(client, id, params \\ %{}, opts \\ [])

@spec void(Nombaone.Client.t(), String.t(), map(), keyword()) ::
  {:ok, Nombaone.Invoice.t()} | {:error, Nombaone.Error.t()}

Void an open, unpaid invoice. Paid invoices can't be voided — refund the settlement instead. Accepts an optional :comment.

Common errors: 409 INVOICE_NOT_VOIDABLE, 409 INVOICE_ALREADY_PAID.

void!(client, id, params \\ %{}, opts \\ [])

Raising variant of void/4.