cable

WebSocket

Connect to the WebSocket endpoint for real-time payment event updates. Ideal for live dashboard UIs.

URLwss://api.paycrypt.io/ws
ProtocolWebSocket (ws / wss)
AuthSend auth message within 12 seconds of connecting
Eventspayment.created, payment.confirmed, payment.expired
javascriptConnect & authenticate
const ws = new WebSocket('wss://api.paycrypt.io/ws');

ws.onopen = () => {
  // Must authenticate within 12 seconds
  ws.send(JSON.stringify({
    type: 'auth',
    token: 'Bearer eyJhbGci...'  // Your JWT token
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  
  if (data.type === 'auth' && data.status === 'ok') {
    console.log('Authenticated!');
    return;
  }
  
  // Payment events
  switch (data.event) {
    case 'payment.created':
      console.log('New payment:', data.payment_id);
      break;
    case 'payment.confirmed':
      console.log('Confirmed:', data.payment_id, data.tx_hash);
      break;
    case 'payment.expired':
      console.log('Expired:', data.payment_id);
      break;
  }
};

ws.onclose = (e) => {
  console.log('Disconnected:', e.code, e.reason);
  // Implement reconnection logic here
};

Authentication Flow

1

Connect

Open a WebSocket connection to the endpoint.

2

Authenticate

Send a JSON message with type: "auth" and your JWT token within 12 seconds.

3

Receive confirmation

Server responds with { type: "auth", status: "ok" }.

4

Listen for events

All payment events for your merchant are broadcast in real-time.