Skip to main content
The root unifi-pay-widget entry point has no React dependency. Use it when your application owns all presentation or uses another framework.

Create a payment

createUniFiPayment validates and normalizes the input, generates a cryptographically random 32-byte session ID encoded as 64 hexadecimal characters, and returns the hosted checkout URL.

Input

Do not encode customer names, email addresses, order details, or other private data into a custom session ID.

Check payment status

The client requests the same-origin /api/unifi proxy by default:
For a single check without retaining a client instance:
The result is always one of:
An empty upstream value maps to pending; a non-empty value maps to paid with the receipt ID. Network errors, non-success responses, and invalid response bodies map to failed. The paid state is the historical name for receipt detected. Check the receipt before confirming the order:
Check once immediately after receipt detection. If the state is Processing or Confirmed, wait 15 minutes before the next automatic check to conserve API credits. A user-triggered refresh may check immediately. Stop automatic checks after Finalized, Failed, or Reorged.
Store the receipt ID itself in the merchant database. Recreate the public link when rendering order history, customer support tools, or a payment confirmation page.

Runtime requirements

Core helpers use Web Crypto, Fetch, URL, Request, and Response APIs. Modern browsers, Node.js 20+, Cloudflare Workers/Pages, Deno, and Bun provide these primitives. You can supply a custom fetch implementation to UniFiClient for another compatible runtime or for tests.

Add the protected status route

The browser client intentionally talks to your server, never directly to the secret-bearing API.