webhooks

python
import hashlib
import hmac
import time


class SignatureError(Exception):

Verify Stripe-Style Webhook HMAC Signatures Before Processing in Flask

flask webhooks hmac
by codesnips 3 tabs
ruby
class CreateWebhookEvents < ActiveRecord::Migration[7.1]
  def change
    create_table :webhook_events do |t|
      t.string :event_id, null: false
      t.string :source, null: false, default: "stripe"
      t.string :event_type, null: false

Idempotent Stripe Webhook Processing with a Unique Event Key in Rails

rails postgres webhooks
by codesnips 4 tabs
ruby
class SyncContactJob < ApplicationJob
  queue_as :external

  BACKOFF = ->(executions) do
    (2**executions) + rand(0.0..1.0) # exponential + jitter, in seconds
  end

Exponential Backoff with Jitter for Flaky External API Calls in ActiveJob

rails activejob background-jobs
by codesnips 3 tabs
javascript
const express = require('express');
const webhookRouter = require('./webhookRouter');
const apiRouter = require('./apiRouter');

const app = express();

Verify Stripe Webhook Signatures with a Raw-Body Express Route

express stripe webhooks
by codesnips 3 tabs
ruby
class WebhookSignature
  class VerificationError < StandardError; end

  TOLERANCE = 300 # seconds

  def initialize(payload:, header:, secrets:)

Robust Webhook Verification (HMAC + Timestamp)

rails security webhooks
by codesnips 3 tabs
go
package webhook

import (
	"encoding/json"
	"io"
	"net/http"

Verifying and Dispatching Stripe-Style Webhooks by Event Type in Go

webhooks go hmac
by codesnips 3 tabs
python
import hmac
import hashlib
import time
from fastapi import Request, HTTPException, status

Verifying Stripe Webhook Signatures With a Reusable FastAPI Dependency

fastapi webhooks security
by codesnips 3 tabs
go
package webhooks

import (
  "bytes"
  "crypto/hmac"
  "crypto/sha256"

Webhook signature verification with HMAC (timing-safe compare)

go security http
by Leah Thompson 1 tab