Connect to WebSocket (WSS) with JWT — of-v

You can securely subscribe to real-time payment updates using your JWT token and WebSocket.

Prepare your JWT

Replace YOUR_JWT_HERE with the actual JWT string you received after login or registration.

const jwtToken = "YOUR_JWT_HERE";

Encode the JWT

This ensures the token is safe to include in the WebSocket URL.

const tokenParam = encodeURIComponent(jwtToken);

Open a secure WebSocket connection

wss:// means secure WebSocket. You must use this if your website uses HTTPS.

  • 
    const ws = new WebSocket(
      `wss://of-v.com:99/jwt/v1/ws?token=${tokenParam}`
    );
    

Handle WebSocket events

  • 
    ws.onopen = () => {
    console.log("✅ Connected to WSS");
    
      // Send a subscription message
      ws.send(JSON.stringify({
        action: "subscribe",
        ag_id: "your_email@example.com"  // or your user ID
      }));
    };
    
    ws.onmessage = (event) => {
      const data = JSON.parse(event.data);
      console.log("📨 Received message:", data);
    
      // You can check payment status here
      // Example: if (data.payst === 2 || data.payst === 3) { ... }
    };
    
    ws.onerror = (err) => {
      console.error("❌ WebSocket error:", err);
    };
    
    ws.onclose = () => {
      console.log("🔌 WebSocket closed");
    };
    
    
  • Example Output Message (From Server)

  • 
     {
      "ag_id": "9@9autos.com",
      "payst": 2,
      "order_id": 12345,
      "status": "Deposit Confirmed"
    }
    
  • If payst equals 2 or 3, it indicates the payment is either confirmed (2) or canceled/closed (3).
  • You may want to trigger window.location.href = ... after receiving this.

Common Issues

  • Mixed Content Error: If your page uses https://, you must use wss:// (not ws://)
  • 401 Unauthorized: Make sure your JWT is valid, not expired, and passed via ?token=...
  • Connection Refused: Check that port 99 is open and of-v.com has a valid TLS certificate

For Frontend Integration (JavaScript):

of-v@of-v.com

infbtwitterinstragram

© 2025 Yuka.Nikin Coding Studio

Made with   by Yuka.Nikin