Skip to main content

Function: useSubscribeOrderNotification()

useSubscribeOrderNotification(params: {onError: (err: Event) => void;onMessage: (order: Order) => void;profile: string;state: OrderState; }): () => undefined | void

API consumers have the option to subscribe to a WebSocket for real-time order notifications. This WebSocket complies with the standard WebSocket Protocol, allowing the use of standard WebSocket libraries for subscription.

The WebSocket emits an event when a order changes state:

placed: The order has been created but not yet processed.

pending: The order is awaiting fulfillment (e.g., review, minting/burning tokens, or sending/receiving SEPA payment).

processed: The order has been completed successfully.

rejected: The order was rejected, possibly due to compliance reasons or insufficient funds.

Parameters

ParameterTypeDescription
paramsobject
params.onError?(err: Event) => voidCallback function to handle the error notification.
params.onMessage(order: Order) => voidCallback function to handle the order notification.
params.profile?stringFilter based on the profile id of the order.
params.state?OrderStateFilter based on the state of the order.

Returns

Function

Unsubscribe from order notifications.

Returns

undefined | void

Example

const {
state,
profile,
onMessage,
onError
} = useSubscribeOrderNotification();

See

API Documentation

Defined in

sdk-react-provider/src/lib/hooks.tsx:1045