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
| Parameter | Type | Description |
|---|---|---|
params | { onError: (err: Event) => void; onMessage: (order: Order) => void; profile: string; state: OrderState; } | |
params.onError? | (err: Event) => void | Callback function to handle the error notification. |
params.onMessage | (order: Order) => void | Callback function to handle the order notification. |
params.profile? | string | Filter based on the profile id of the order. |
params.state? | OrderState | Filter based on the state of the order. |
Returns
Function
Unsubscribe from order notifications.
Returns
undefined | void
Example
const {
state,
profile,
onMessage,
onError
} = useSubscribeOrderNotification();