Skip to main content

Webhook Receiver Examples

This page provides simple webhook receiver examples in various programming languages to help you get started with OpenTiendas webhooks. Each example shows how to:

  • Receive HTTP POST requests
  • Parse the JSON payload
  • Verify the X-Signature header for authenticity
  • Respond with HTTP 200 upon success
info

These minimal examples focus on signature verification logic only.
To build a full receiver, integrate them into your preferred web framework or server setup, and add logic to handle the event payload.

import hmac
import hashlib

SECRET = b"your_webhook_secret"
payload = b'{"example":"data"}'
signature_header = "sha256=" + hmac.new(SECRET, payload, hashlib.sha256).hexdigest()

def is_valid_signature(secret, payload, signature):
expected_signature = "sha256=" + hmac.new(secret, payload, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected_signature, signature)

if is_valid_signature(SECRET, payload, signature_header):
# TODO: Process the webhook event here
print("Valid signature. Processing event...")
else:
print("Invalid signature. Ignoring.")

Use these examples as a starting point to integrate OpenTiendas webhooks into your system. Rememebr to check Retries and Error Handling and Security and validation section.