Skip to content

feature-invoice hooks

The components already use these hooks. Reach for them when you build your own UI on the same data. Open a hook for its options and what it returns.

Reading data

useInvoiceRead a single invoice by id for the active scope.
import { useInvoice } from "@evolve-storefront/feature-invoice/hooks";

Gated on auth, so it reports isPending (not isLoading) until the client auth context validates. Render the skeleton while isPending; only isSuccess && !data is a real 404.

function useInvoice(id: string)

Returns A React Query result: data, isPending, error and the rest.

useInvoiceCreditRead the active business unit's credit; pass it to CreditSummary.
import { useInvoiceCredit } from "@evolve-storefront/feature-invoice/hooks";
function useInvoiceCredit()

Returns A React Query result: data, isPending, error and the rest.

useInvoicePaymentMethodsThe payment methods offered for an invoice that still owes money.
import { useInvoicePaymentMethods } from "@evolve-storefront/feature-invoice/hooks";

Read from the invoice, not from a cart: the invoice may bill several orders or none, and paying on account is deliberately absent from this list because the invoice exists in the first place because credit was granted.

Gated like every other read here, so it reports isPending (not isLoading) until the client auth context validates. An empty array is a real answer — nothing is offered for this amount, buyer and device — which a surface has to say out loud rather than render as an empty list with a dead control beneath it.

device has no default. The offered set differs by client, and guessing would offer a method the buyer cannot complete.

function useInvoicePaymentMethods(id: string, device: InvoiceClientDevice)

Returns A React Query result: data, isPending, error and the rest.

useInvoicesRead a page of invoices for the active scope.
import { useInvoices } from "@evolve-storefront/feature-invoice/hooks";
function useInvoices(args?: ({ page?: number | undefined; pageSize?: number | undefined; status?: InvoiceStatus[] | undefined; } & InvoiceListFilterValues))

Returns A React Query result: data, isPending, error and the rest.

useInvoiceStatusCountsHow many invoices each status holds under the list's search and date range, for InvoiceStatusTabs's counts.
import { useInvoiceStatusCounts } from "@evolve-storefront/feature-invoice/hooks";
function useInvoiceStatusCounts(args?: InvoiceListFilterValues)
OptionTypeDescription
searchTerm?string
invoiceDateFrom?string

yyyy-mm-dd, inclusive.

invoiceDateUntil?string

yyyy-mm-dd, inclusive.

Returns A React Query result: data, isPending, error and the rest.

Changing data

usePayInvoicePay an invoice.
import { usePayInvoice } from "@evolve-storefront/feature-invoice/hooks";

The same call every other payment goes through — paymentCreate with a target, not an invoice-specific mutation. A second checkout-shaped mutation is what checkoutComplete was.

The amount is never passed. A part-paid invoice is charged its balance, and the engine derives that from the same amounts it derives amountDue from. A client naming a figure is a client that can name the wrong one.

Blocked on the schema. PaymentTargetType is CART | ORDER, so the target cannot name an invoice yet, and this throws at the gateway rather than at build time — the value sits in a variable, so no document validation can see it. payment-target.test.ts asserts the enum and fails the day it gains the value.

function usePayInvoice()

Returns A React Query mutation: mutate, mutateAsync, isPending and the rest.

Other hooks

useInvoiceReturnUrlsInvoiceProvider's returnUrls: the order payments' arrival point at path, naming the invoice.
import { useInvoiceReturnUrls } from "@evolve-storefront/feature-invoice/hooks";
function useInvoiceReturnUrls(
path: string,
invoiceId: string,
): InvoiceReturnUrls | undefined

Returns InvoiceReturnUrls | undefined