Capxul Docs
HooksPayments

useCapxulPayment

Query hook for a single Payment by id — null when no such payment is visible to the signed-in user.

Reads a single Payment by id — for a payment detail screen or for polling one payment's status. List the ledger with useCapxulPayments.

Import

import { useCapxulPayment } from "@capxul/sdk-react";

Usage

"use client";

import { useCapxulPayment } from "@capxul/sdk-react";

function PaymentDetail({ paymentId }: { paymentId: string }) {
  const payment = useCapxulPayment(paymentId);

  if (payment.isLoading) return <p>Loading payment…</p>;
  if (payment.error) return <p>{payment.error.message}</p>;
  if (payment.data === null) return <p>Payment not found.</p>;

  return (
    <p>
      {payment.data.amount.value} {payment.data.amount.currency} to{" "}
      {payment.data.recipient.label} — {payment.data.status}
    </p>
  );
}

Parameters

paymentId

string | undefined

The payment to read. The query stays disabled while paymentId is undefined, so you can pass a value that arrives asynchronously (for example from route params or another query) without manual gating.

options

{ enabled?: boolean } | undefined

Pass enabled: false to skip the read until your UI is ready for it.

Return type

import { type UseCapxulPaymentReturn } from "@capxul/sdk-react";
// UseQueryResult<Payment | null, CapxulError>

data is the Payment, or null when no payment with that id is visible to the signed-in user — "not found" is data, not an error.

The hook returns TanStack Query's UseQueryResult. The most-used fields:

FieldDescription
dataThe query data (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last fetch failed, otherwise null.
status'pending' | 'error' | 'success'.
isLoadingtrue during the first fetch (no data yet).
isFetchingtrue whenever a fetch is in flight, including background refetches.
refetchManually refetch the query.

Capxul query hooks stay pending until the provider finishes bootstrapping — you do not need to gate them on useCapxul() yourself. The full field list is in the TanStack Query useQuery reference; see also the TanStack Query integration guide.

Query key

["capxul", "payments", paymentId] — nested under the payments prefix, so every money mutation that refreshes useCapxulPayments refreshes payment details too. Mutations that return a specific payment (useCapxulPay, useCapxulPayout, useCapxulWithdraw) also invalidate that payment's key directly.

Client method

This hook wraps client.payments.get(paymentId) on the core SDK.

On this page