> ## Documentation Index
> Fetch the complete documentation index at: https://docs.payunifi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# React integration

> Use the complete UniFi widget or compose its checkout components.

Import React components from `unifi-pay-widget/react` and load
`unifi-pay-widget/styles.css` once. React 18 and 19 are supported.

## Complete widget

`UniFiPayWidget` is the shortest integration path. It combines asset/network selection, session
creation, checkout launch, a 15-minute countdown, manual or opt-in automatic session-status
checking, and receipt-detected/error callbacks.

```tsx theme={null}
import { UniFiPayWidget } from "unifi-pay-widget/react";
import "unifi-pay-widget/styles.css";

export function StablecoinPayment({
  total,
  merchantWalletAddress,
  saveSession,
  saveDetectedReceipt,
}: {
  total: string;
  merchantWalletAddress: string;
  saveSession: (sessionId: string) => void;
  saveDetectedReceipt: (receiptId: string) => void;
}) {
  return (
    <UniFiPayWidget
      amount={total}
      recipient={merchantWalletAddress}
      defaultValue={{ asset: "USDT", network: "Ethereum" }}
      statusPollIntervalMs={30_000}
      onSession={(session) => saveSession(session.sessionId)}
      onPaid={(receiptId) => saveDetectedReceipt(receiptId)}
      onError={(error) => console.error(error)}
    />
  );
}
```

### Widget props

| Prop | Required | Purpose |
| - | - | - |
| `amount` | Yes | Decimal string or number to request |
| `recipient` | Yes | Merchant wallet address that receives the payment |
| `value`, `onChange` | No | Controlled asset/network selection |
| `defaultValue` | No | Initial uncontrolled selection |
| `onSession` | No | Persist the generated session ID against the order |
| `onStatus` | No | Observe `pending`, `paid`, or `failed` results |
| `onPaid` | No | Receive the detected receipt ID and payment session; finality still must be checked |
| `onError` | No | Handle invalid input or unexpected failures |
| `expirySeconds` | No | Shorten the default 900-second UI countdown |
| `buttonLabel` | No | Replace the default Pay button label |
| `disabled` | No | Disable pair selection and payment launch |
| `openInNewTab` | No | Open the hosted checkout in a new tab; defaults to `true` |
| `proxyBaseUrl` | No | Override the default same-origin `/api/unifi` proxy prefix |
| `checkoutBaseUrl` | No | Admin/local override for the hosted checkout base URL |
| `statusPollIntervalMs` | No | Positive milliseconds between automatic session-status checks; omitted or `null` keeps manual checking |

### Automatic session checks

Automatic checking is opt-in. Pass a positive `statusPollIntervalMs` value, such as `30_000`,
`60_000`, or `120_000`. The waiting card then shows a draining progress ring, the time until the
next check, the last-check time, and a compact refresh control for an immediate check. While a
request is in flight, the controller suppresses overlapping checks.

Omit the prop or pass `null` to retain the manual **Check payment status** button. If your
application exposes a public value such as `PAYMENT_STATUS_POLL_INTERVAL`, parse it as positive
whole seconds and multiply it by `1_000` before passing it to the widget.

## Compose into an existing checkout

Use `UniFiPaymentOption` when the merchant page owns its payment-method radio group, Pay button,
status state, and order-completion UI.

```tsx theme={null}
import { useState } from "react";
import { UniFiPaymentOption } from "unifi-pay-widget/react";
import {
  createUniFiPayment,
  type UniFiPaymentSelection,
} from "unifi-pay-widget";

const [selection, setSelection] = useState<UniFiPaymentSelection>({
  asset: "USDT",
  network: "Ethereum",
});

<UniFiPaymentOption
  radioName="payment-method"
  selected={paymentMethod === "unifi"}
  onSelect={() => setPaymentMethod("unifi")}
  value={selection}
  onChange={setSelection}
/>;

function payWithUniFi() {
  const payment = createUniFiPayment({
    ...selection,
    amount: order.total,
    recipient: merchantWalletAddress,
  });

  saveSession(order.id, payment.sessionId);
  window.open(payment.payUrl, "_blank", "noopener,noreferrer");
}
```

![UniFi asset and network picker open over the FliQ Market checkout](https://mintcdn.com/test-ccbd1339/a7-7soYiK1kc9L9N/images/payment-gateway/asset-network-picker.webp?fit=max\&auto=format\&n=a7-7soYiK1kc9L9N\&q=85\&s=328ca6bb199d0715264d5dc8428b3748)

The pair picker is part of the merchant checkout, so the customer never loses order context.

## Add the status sheet

`UniFiPaymentStatusSheet` is controlled by your application. Supply its visibility, countdown,
status text, generated payment URL, and handlers:

```tsx theme={null}
<UniFiPaymentStatusSheet
  open={statusOpen}
  secondsLeft={secondsLeft}
  statusText={statusText}
  payUrl={payment?.payUrl}
  statusPollIntervalMs={paymentStatusPollIntervalMs}
  autoCheckSecondsLeft={autoCheckSecondsLeft}
  autoCheckActive={autoCheckActive}
  lastCheckedAt={lastCheckedAt}
  onCheckStatus={checkCurrentPayment}
  onClose={() => setStatusOpen(false)}
/>;
```

When `checking` is omitted, the component manages its own button-loading state while it awaits
`onCheckStatus`. The sheet handles Escape-to-close, initial close-button focus, body scroll locking,
and a copyable hosted checkout link. Its icon-only close control retains an accessible **Close**
label.

For composed integrations, pass `statusPollIntervalMs`, `autoCheckSecondsLeft`, `autoCheckActive`,
and `lastCheckedAt` from `useUniFiPayment` to render the automatic-check treatment shown above.

The status sheet finds the receipt ID; it does not establish chain finality. After `onPaid`, call
`checkUniFiReceiptStatus`, keep `Processing` and `Confirmed` in an in-progress order UI, refresh
automatically no more than every 15 minutes, and offer a manual refresh action. Confirm the order
only after `Finalized`.

## Link a receipt

```tsx theme={null}
import { UniFiReceiptLink } from "unifi-pay-widget/react";

<UniFiReceiptLink receiptId={order.unifiReceiptId}>
  View payment receipt
</UniFiReceiptLink>;
```

## Theme the components

Class names use the `unifi-widget` prefix. Override CSS variables near the host checkout root:

```css theme={null}
.my-checkout {
  --unifi-primary: #321967;
  --unifi-primary-hover: #281252;
  --unifi-accent: #6d28d9;
  --unifi-accent-soft: #f5f3ff;
}
```

The widget inherits the host application's font.

> [card] [See the complete FliQ Market composition](https://docs.payunifi.com/payment-gateway/fliq-market.md)
>
> Inspect how the payment option, hosted checkout, status sheet, and receipt link work together.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.