class WebhookSignature
class VerificationError < StandardError; end
TOLERANCE = 300 # seconds
def initialize(payload:, header:, secrets:)
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[serde(tag = "type", content = "data", rename_all = "snake_case")]
pub enum WebhookEvent {
#[serde(rename = "payment.succeeded")]
package webhook
import (
"encoding/json"
"io"
"net/http"
import hmac
import hashlib
import time
from fastapi import Request, HTTPException, status
const { pool } = require('./db');
async function recordEvent(client, { eventId, type, payload }) {
const { rows } = await client.query(
`INSERT INTO webhook_events (event_id, type, payload, status)
VALUES ($1, $2, $3, 'received')
package webhooks
import (
"bytes"
"crypto/hmac"
"crypto/sha256"