Wayout LogoDocumentation

Websocket

Websocket client for receiving real-time events


Introduction

The Websocket client is a package that interacts with our Websocket API to receive real-time payment events, reliably, with a simple interface.

This feature is available to Business plan users only

Supported langauges

JS

JavaScript

Supports Node.js and other JavaScript runtimes

Installation

npm install @wayout/websocket-client

Code examples

const WebsocketClient = require('@wayout/websocket-client');

const client = new WebsocketClient("REPLACE_WITH_API_KEY");

client.serve((event) => {

// Handle the event here

});
API key must have Automate Payments permission scope or higher.

The serve function will receive all payment events sequentially.

After the handler completes for one event, the next event will be received, or the client will wait for one to be sent.

If the serve function's handler completes without error, the notification is considered a success.

The handler can also be asynchronous, and the promise it returns will automatically be awaited before the next event will be served. However, if you run the async function without the await operator, we can no longer guarantee reliable delivery because uncaught errors will not be detectable.

Event Payloads

Websocket Event Payload
{
  "id": "17000000000-0",
  "invoice_id": "12345",
  "status": "Paid",
  "paid_at": "2025-11-11T11:11:00.000Z",
  "payment_id": "6789"
}

Schema

FieldTypeDescription
idstringThe unique identifier for the event.
invoice_idstringThe ID of the invoice.
statusstringThe status of the invoice. Possible values are "Paid", "Confirming", and "Failed".
paid_atstringThe timestamp when the invoice was paid, in ISO 8601
payment_idstringThe ID of the payment triggering this event associated with the invoice.