Skip to main content

Overview

Transaction API provides WebSocket support for real-time payment updates. This allows you to receive instant notifications about payment status changes without polling the API.

Connection

WebSocket URL

Authentication

Include your JWT token in the connection query parameter:

Connection Management

Basic Connection

Advanced Connection with Heartbeat

Supported Events

Payment Status Update

Payment Completed

Payment Expired

Event Handling

Payment Status Updates

Payment Completion

Payment Expiration

React Integration

Custom Hook

Component Usage

Error Handling

Connection Errors

Best Practices

Connection Management

1

Implement Reconnection

Always implement automatic reconnection for production applications.
2

Handle Connection States

Track connection status and show appropriate UI feedback.
3

Use Heartbeats

Implement ping/pong to detect dead connections.
4

Graceful Degradation

Fall back to polling if WebSocket connection fails.

Performance Optimization

WebSocket vs Webhooks

WebSocket

Best for:
  • Real-time UI updates
  • Client-side applications
  • Interactive dashboards
  • Mobile apps
Pros:
  • Real-time updates
  • Low latency
  • Persistent connection

Webhooks

Best for:
  • Server-to-server communication
  • Backend processing
  • Reliable delivery
  • Audit trails
Pros:
  • Reliable delivery
  • Retry mechanism
  • Server-side processing
  • Better for critical operations

Testing WebSocket Connections

Local Testing

Production Monitoring

Production Tip: Use both WebSocket and webhooks for critical applications. WebSocket for real-time UI updates and webhooks for reliable server-side processing.