webhooks

typescript
import { Queue } from "bullmq";
import { createHash } from "crypto";

export const connection = { host: "127.0.0.1", port: 6379 };

export interface ChargePayload {

BullMQ job idempotency via dedupe id

node redis background-jobs
by codesnips 3 tabs
ruby
module Webhooks
  class StripeController < ApplicationController
    skip_before_action :verify_authenticity_token

    def create
      payload = request.body.read

Webhook signature verification

rails security webhooks
by Alex Kumar 1 tab
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
typescript
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  // rawBody: true preserves the exact bytes Stripe signed
  const app = await NestFactory.create(AppModule, { rawBody: true });

Verify Stripe Webhook Signatures in a NestJS Guard Before the Handler

nestjs webhooks stripe
by codesnips 4 tabs
javascript
const crypto = require('crypto');

function parseSignatureHeader(header) {
  const parts = {};
  for (const segment of String(header || '').split(',')) {
    const [key, value] = segment.split('=');

Verify Stripe-Style Webhook HMAC Signatures with a Timestamped Scheme in Express

express webhooks hmac
by codesnips 3 tabs
python
import datetime as dt

from sqlalchemy import Column, DateTime, Integer, String, UniqueConstraint
from sqlalchemy.orm import declarative_base

Base = declarative_base()

Idempotent Webhook Ingestion With a Postgres Dedupe Store in FastAPI

fastapi webhooks idempotency
by codesnips 3 tabs
python
from datetime import datetime
from app.extensions import db


class IdempotencyKey(db.Model):
    __tablename__ = "idempotency_keys"

Idempotency-Key Deduplication for POST Requests in a Flask Blueprint

flask idempotency postgres
by codesnips 3 tabs
python
from django.db import models
from django.utils import timezone


class WebhookEvent(models.Model):
    class Status(models.TextChoices):

Idempotent Stripe Webhook Handling in Django with a Unique Event-ID Constraint

django webhooks idempotency
by codesnips 3 tabs
php
<?php

namespace App\Controller;

use App\Message\ProcessStripeEvent;
use App\Webhook\StripeSignatureVerifier;

Verifying and Processing Stripe-Style Webhooks Idempotently in Symfony

symfony webhooks stripe
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