डिजिटल वस्तुओं का थोक मंच

Digital Goods Orders के लिए Webhooks

Webhooks HTTP push notifications हैं जो supplier की system से आपके server पर order event होने पर भेजी जाती हैं। Digital goods के लिए critical events हैं: order created, order fulfilled, order failed। Code ready है या नहीं देखने के लिए बार-बार order status endpoint poll करने के बजाय, webhooks आपके server को fulfillment complete होते ही notify करते हैं। यह delivery faster बनाता है, API calls कम करता है और polling-related delays खत्म करता है।

Digital Goods Orders के लिए Webhooks


संक्षिप्त उत्तर

Webhooks HTTP push notifications हैं जो supplier की system से आपके server पर order event होने पर भेजी जाती हैं। Digital goods के लिए critical events हैं: order created, order fulfilled, order failed। Code ready है या नहीं देखने के लिए बार-बार order status endpoint poll करने के बजाय, webhooks आपके server को fulfillment complete होते ही notify करते हैं। यह delivery faster बनाता है, API calls कम करता है और polling-related delays खत्म करता है।


परिभाषा: Digital goods orders के लिए webhook एक HTTP POST request है जो supplier आपके server endpoint पर तब भेजता है जब order का status बदलता है — जैसे code delivery के लिए ready हो। आपका server event receive करता है और बिना poll किए delivery process करता है।


मुख्य निष्कर्ष: Order status endpoint को poll करना small scale पर काम करता है। High volume पर, polling rate limits hit करती है और latency introduce करती है। Webhooks production-grade solution हैं: हर order change पर एक event, जैसे होता है deliver होता है।


यह Guide किसके लिए है

  • Developers जो digital goods API integrate कर रहे हैं और async order handling चाहते हैं
  • Store operators जिनका order fulfillment कभी-कभी delayed होता है (pending orders)
  • High-volume digital goods pipeline build करने वाले

Polling vs. Webhooks

Factor Polling Webhooks
कैसे काम करता है आपका server हर N seconds "क्या order done है?" पूछता है Supplier आपके server को status change होने पर notify करता है
Latency Poll interval पर depend करता है लगभग instant
API call volume High (हर pending order पर N calls) हर event पर एक call
Rate limit risk Scale पर high None
Implementation Simpler थोड़ा complex (endpoint + validation)
Best for Development/testing Production

Webhook Event Types

Digital goods supplier API के लिए इन event types की उम्मीद करें:

Event कब Fire होता है आपके Server पर Action
order.created Supplier ने order receive किया Log; SLA timer start करें
order.fulfilled Code ready; order complete Customer को code deliver करें
order.failed Fulfillment failed Ops को alert करें; अगर payment लिया तो refund flow trigger करें
order.refunded Supplier ने order reverse किया Status update; customer को notify करें
balance.low Reseller balance threshold से नीचे Balance top-up process trigger करें

सबसे critical event है order.fulfilled — यह code delivery के लिए trigger है।


Webhook Payload Format (Typical)

{
  "event": "order.fulfilled",
  "timestamp": "2026-05-01T14:23:11Z",
  "data": {
    "order_id": "SUP-99887",
    "reference": "ORD-12345",
    "status": "fulfilled",
    "items": [
      {
        "sku": "steam-20-usd",
        "code": "XXXXX-YYYYY-ZZZZZ",
        "pin": null
      }
    ]
  },
  "signature": "sha256=abc123..."
}

reference field हमेशा check करें — यह आपका internal order ID है, जो supplier event को आपके database से match करने देता है बिना supplier के order IDs को primary keys के रूप में store किए।


Signature Validation

Suppliers webhook payloads sign करते हैं ताकि आप verify कर सकें कि वे legitimate source से आए हैं। Validation के बिना, कोई भी आपके endpoint पर POST कर सकता है।

HMAC-SHA256 validation (सबसे common):

import hmac
import hashlib

def validate_webhook(payload_body: bytes, signature_header: str, secret: str) -> bool:
    expected = hmac.new(
        secret.encode('utf-8'),
        payload_body,
        hashlib.sha256
    ).hexdigest()
    received = signature_header.replace('sha256=', '')
    return hmac.compare_digest(expected, received)

Rules:

  • किसी भी payload को process करने से पहले validate करें
  • Timing attacks रोकने के लिए constant-time comparison (hmac.compare_digest) use करें
  • Signature validation fail होने पर HTTP 400 return करें (200 नहीं)
  • Validation pass होने पर — event process करने से पहले — तुरंत HTTP 200 return करें

Async Processing

Webhook events को asynchronously process करें। आपका webhook endpoint supplier के timeout window (typically 3–10 seconds) के भीतर HTTP 200 return करना चाहिए। अगर आपकी event processing अधिक समय लेती है — database writes, email sends, API calls — supplier delivery को failed mark कर retry कर सकता है।

Correct architecture:

Webhook endpoint POST receive करता है
  → Signature validate करता है
  → तुरंत HTTP 200 return करता है
  → Event को queue में push करता है (Redis, SQS, DB queue table)

Background worker
  → Queue से event pull करता है
  → Process करता है: customer को code deliver करना, order status update करना

गलत: 200 return करने से पहले webhook handler के अंदर delivery process करना।


Retry Behavior

Suppliers webhook delivery retry करते हैं अगर timeout के भीतर HTTP 200 नहीं मिलता। Typical retry schedules:

  • 1st retry: failure के 30 seconds बाद
  • 2nd retry: 5 minutes
  • 3rd retry: 30 minutes
  • उसके बाद: varies (कुछ suppliers 24 hours तक retry करते हैं)

आपकी idempotency handling को retry fire होने पर same order को twice process होने से रोकना चाहिए। Order reference को idempotency key के रूप में use करें:

if order_already_delivered(reference):
    return HTTP 200  # Acknowledge, कुछ न करें

Fallback: Missing Events के लिए Polling

Webhooks fail हो सकते हैं। आपका endpoint down जा सकता है, या network issue delivery रोक सकती है। N minutes से अधिक pending status में रहने वाले orders के लिए polling fallback implement करें:

Scheduled job (हर 5 minutes):
  → Status = 'pending' और age > 5 minutes वाले सभी orders खोजें
  → हर एक के लिए: GET /orders/:id call करें
  → अगर status = fulfilled: delivery process करें
  → अगर status = failed: ops को alert करें

यह ensure करता है कि missed webhook के कारण कोई order indefinitely stuck न रहे।


Implementation Checklist

  • Webhook endpoint URL supplier के पास register करें (typically API settings में)
  • POST endpoint implement करें जो webhook payloads accept करे
  • JSON parsing से पहले raw body read करें (raw bytes पर signature validation के लिए)
  • Supplier के algorithm और shared secret से signature validation implement करें
  • Validation pass होने के बाद तुरंत HTTP 200 return करें
  • Event को async queue में push करें
  • Queue से events process करने वाला background worker build करें
  • Order reference से idempotency check implement करें
  • Pending orders के लिए fallback polling implement करें
  • Supplier के test event payload से test करें
  • Supplier dashboard में webhook delivery failures monitor करें

अक्सर पूछे जाने वाले प्रश्न

क्या small-volume store के लिए webhooks जरूरी हैं?
प्रतिदिन 100 से कम orders पर polling काम करती है और implement करना simpler है। Webhooks तब जरूरी हो जाते हैं जब polling higher volume पर rate limit pressure या latency issues create करे।
अगर event fire होने पर मेरा webhook endpoint down हो तो क्या होता है?
Supplier retry करता है। अगर retry window expire होने से पहले आपका endpoint वापस आ जाए, तो event deliver और process होगा। इसीलिए fallback polling job महत्वपूर्ण है — यह retries exhaust करने वाले events को catch करती है।
क्या multiple event types के लिए same webhook endpoint use कर सकते हैं?
हाँ। Payload में event field के basis पर route करें। हर event type के लिए switch/case या if-else use करें।
Development के दौरान locally webhooks test कैसे करें?
Local server को internet पर expose करने के लिए tunneling tool (ngrok, cloudflared) use करें, फिर tunnel URL को supplier के पास webhook endpoint के रूप में register करें।
अगर ऐसे order के लिए webhook मिले जो database में नहीं है तो क्या करें?
Unknown reference log करें, HTTP 200 return करें (ताकि supplier retry न करे), और investigate करें। यह आपकी side पर silently failed order creation step का indication हो सकता है।
FoxReload API access लें

संबंधित लेख

B2B Resale के लिए Amazon Gift Cards

Amazon Gift Cards globally सबसे universally recognized और broadly accepted digital gift cards हैं। ये Amazon पर बिकने वाली लगभग किसी भी चीज़ के लिए usable हैं, जो इन्हें mixed demographics वाले B2B reward programs के लिए safest choice बनाता है। Resellers के लिए Amazon Gift Cards high-demand, low-risk catalog staple हैं — tradeoff यह है कि gaming-specific products से margins thinner हैं competitive supply के कारण। Regional variants buyer के Amazon storefront (Amazon.com, Amazon.co.uk, Amazon.de, आदि) से match होने चाहिए।

मई 20266 मिनटपढ़ें

Apple Gift Cards Wholesale

Apple Gift Cards prepaid codes हैं जो Apple ID balance में credit add करते हैं, Apple ecosystem में purchases के लिए: App Store, Apple Music, Apple TV+, iCloud+, Apple Arcade और Apple One। ये country-specific हैं: US card केवल US Apple ID के साथ काम करती है। Resellers इन्हें B2B suppliers से API या CSV के through wholesale में source करते हैं और websites, Telegram bots और marketplaces पर बेचते हैं। Apple Gift Cards higher-income demographic को target करती हैं Google Play की तुलना में, device और ecosystem pricing के कारण।

मई 20266 मिनटपढ़ें

डिजिटल कोड डिलीवरी ऑटोमेट कैसे करें

डिजिटल कोड डिलीवरी ऑटोमेट करने का मतलब है मैन्युअल ऑर्डर प्रोसेसिंग को एक पाइपलाइन से रिप्लेस करना: कस्टमर पेमेंट आपके सप्लायर को API कॉल ट्रिगर करता है, सप्लायर कोड रिटर्न करता है, और आपका सिस्टम सेकंडों में कस्टमर को डिलीवर करता है। छह कंपोनेंट हैं: पेमेंट इवेंट लिसनर, सप्लायर API ऑर्डर कॉल, रिस्पॉन्स से कोड पार्सिंग, कस्टमर डिलीवरी (ईमेल/पेज/मैसेज), async अपडेट के लिए वेबहुक लिसनर, और फेल्ड ऑर्डर के लिए एरर हैंडलिंग। एक काम करती ऑटोमेशन बिना किसी मैन्युअल स्टेप के असीमित ऑर्डर प्रोसेस करती है।

मई 20269 मिनटपढ़ें