Skip to content

SR King FamPay Gateway guide

How to receive and verify HMAC-SHA256 signed UPI payment webhooks

Instead of polling /api/public/order every few seconds, SR King FamPay Gateway can push real-time payment.verified webhooks directly to your server the instant a payment is confirmed, signed with HMAC-SHA256.

Updated

Open my dashboard

1. Enable webhooks in your dashboard

Every webhook request includes three headers: X-SRKing-Event, X-SRKing-Timestamp, and X-SRKing-Signature.

  1. Open Dashboard -> Webhooks.
  2. Paste your public HTTPS endpoint (e.g. https://api.yoursite.com/webhooks/fampay) and click Save webhook.
  3. Copy your generated whsec_... signing secret and click Send test event to verify HTTP 200 delivery.

2. Verify the HMAC-SHA256 signature (Python)

Always verify X-SRKing-Signature against the raw request body using constant-time comparison before fulfilling an order:

import hmac, hashlib

def verify_srking_signature(raw_body: bytes, timestamp: str, signature: str, secret: str) -> bool:
    payload = f"{timestamp}.".encode() + raw_body
    expected = "sha256=" + hmac.new(secret.encode(), payload, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature or '', expected)

3. Make your webhook handler idempotent

Store processed txn_id or order_id values in your database so if a webhook is retried due to a network timeout, you never deliver the same digital item twice.

Questions about this topic

What events are sent?

payment.verified when a real customer payment is confirmed, and webhook.test when you click Send test event from your dashboard.

Can I still use /api/public/order alongside webhooks?

Yes. Using webhooks for instant fulfillment and /api/public/order as a fallback check gives you maximum reliability.

हिंदी में जानकारी

Dashboard ke Webhooks tab mein apna HTTPS URL set karein aur har verified payment par instant HMAC-SHA256 signed POST notification paayein — bina polling loop ke.