Skip to content

Instantly share code, notes, and snippets.

@puneetkaura
Last active July 10, 2025 16:18
Show Gist options
  • Save puneetkaura/5119d2045befd4c9b8b3bc5b966487e4 to your computer and use it in GitHub Desktop.
Save puneetkaura/5119d2045befd4c9b8b3bc5b966487e4 to your computer and use it in GitHub Desktop.
Verify Cashfree Webhook
def pg_webhook_verify(self, timestamp,request):
pg_payload = self.get_cashfree_headers()
pg_secret_key = self.api_secret_key
try:
import base64
import hmac
import hashlib
import json
body_unicode = request.body.decode('utf-8')
body_data = json.dumps(body_unicode)
message = timestamp + body_data
computeSig = request.headers['X-Webhook-Signature'].encode()
print("computeSig: ", computeSig)
return True, computeSig
except Exception as e :
raise CashFreeException({"message": str(e)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment