Track Order Status

Monitor your orders through APIs, Webhooks, or WebSockets

OZZOBiT provides multiple ways to track order status throughout its lifecycle. Choose the method that best fits your application architecture.

Poll the Get Order API endpoint at regular intervals to check status:

poll-order.jsjavascript
// Poll for order status
async function pollOrderStatus(orderId, maxAttempts = 30) {
  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch(
      `https://OZZOBiT.com/api/api/v2/orders/${orderId}`,
      {
        headers: {
          'Authorization': 'Bearer YOUR_SECRET_API_KEY',
        }
      }
    )
    const data = await response.json()
    
    console.log(`Attempt ${i + 1}: Status = ${data.status}`)
    
    if (['COMPLETED', 'FAILED', 'CANCELLED'].includes(data.status)) {
      return data  // Final state reached
    }
    
    // Wait 5 seconds before next poll
    await new Promise(resolve => setTimeout(resolve, 5000))
  }
  
  throw new Error('Polling timeout')
}

// Usage
const order = await pollOrderStatus('order-id-123')
console.log('Final status:', order.status)
StatusMeaningAction
PROCESSINGPayment being processedContinue polling
PENDING_DELIVERYCrypto being sent to walletContinue polling
COMPLETEDOrder fully completedStop - success
FAILEDOrder failedStop - handle error
CANCELLEDOrder cancelledStop - handle cancellation

Set up a webhook endpoint to receive push notifications when order status changes:

webhook-handler.tstypescript
// app/api/OZZOBiT-webhook/route.ts
import { NextRequest } from 'next/server'
import crypto from 'crypto'

export async function POST(request: NextRequest) {
  try {
    const payload = await request.text()
    const signature = request.headers.get('x-OZZOBiT-signature')
    
    // Verify webhook signature
    // (See decryption guide for full implementation)
    
    const event = JSON.parse(payload)
    const eventName = event.eventName
    
    switch (eventName) {
      case 'ORDER_COMPLETED':
        await handleOrderCompleted(event.data)
        break
      case 'ORDER_FAILED':
        await handleOrderFailed(event.data)
        break
      case 'ORDER_PROCESSING':
        await updateOrderStatus(event.data.id, 'PROCESSING')
        break
    }
    
    return Response.json({ received: true })
  } catch (error) {
    console.error('Webhook error:', error)
    return new Response('Error', { status: 500 })
  }
}

Use WebSocket connections for real-time updates without polling:

websocket-tracker.jsjavascript
import { io } from 'socket.io-client'

const socket = io('wss://OZZOBiT.com/ws', {
  auth: { apiKey: 'YOUR_API_KEY' },
})

socket.on('connect', () => {
  socket.emit('subscribe:order', { orderId: 'your-order-id' })
})

socket.on('order:update', (update) => {
  console.log('Real-time update:', update)
  
  if (update.status === 'COMPLETED') {
    showSuccessNotification(update)
  }
})

Which Method Should You Use?

MethodBest ForLatencyReliability
WebhooksServer-side processing, database updates< 1sHighest
WebSocketsReal-time dashboards, live UIInstantHigh
API PollingSimple implementations, fallback5-60sMedium