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)| Status | Meaning | Action |
|---|---|---|
| PROCESSING | Payment being processed | Continue polling |
| PENDING_DELIVERY | Crypto being sent to wallet | Continue polling |
| COMPLETED | Order fully completed | Stop - success |
| FAILED | Order failed | Stop - handle error |
| CANCELLED | Order cancelled | Stop - 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?
| Method | Best For | Latency | Reliability |
|---|---|---|---|
| Webhooks | Server-side processing, database updates | < 1s | Highest |
| WebSockets | Real-time dashboards, live UI | Instant | High |
| API Polling | Simple implementations, fallback | 5-60s | Medium |