Overview
Use the commerce WebSocket stream for realtimecommerce.order.* updates and linked commerce invoice/payment context. It emits the same event types as the commerce webhooks, but with replay and REST backfill for resilience.
Authentication in the SDK
The SDK connects via query params, so use a short-livedws_token minted server-side. WebSocket headers (for direct x-commerce-api-key auth) are supported by the raw endpoint but are not wired into the SDK today.
Request
Mint a ws_token
Connect to commerce events
Filters you can pass
types: Comma-separated event types (supports wildcards, e.g.commerce.order.*).order_id: Scope to a single order.invoice_id: Scope to a linked invoice.customer_id: Scope to a merchant customer.wallet_address: Scope to a payer wallet.wallet_network: Scope to a network (e.g.solana,bsc).format:event_v1(recommended).
Relationship to webhooks
- Webhooks and WebSockets deliver the same
commerce.order.*event types. - WebSockets include replay + REST backfill, so they are more resilient for realtime UX.
- Webhooks remain best for server-to-server side effects and audit trails.
Recovery and delivery
connectCommerceEvents returns a PepayEventStream that:
- Replays from
since=<last_event_id>on reconnect. - Backfills missed events via REST (
/api/v1/events). - Buffers WS frames during backfill and emits in order.
event.id.
Devnet simulator
Devnet order simulation (commerce.devnet.simulateOrder) emits the same commerce.order.updated events on this stream. See Orders for the simulation flow.
Next: Commerce API keys
