Works with the AI Agents you already use

    Webhook Security & Idempotency Review (Stripe and more)

    by Hayder Al-Hwaidi

    1

    A missing signature check lets anyone spoof a payment, while a slow handler causes timeouts and duplicate orders.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Webhook Security & Idempotency Review (Stripe and more)

    Webhook Security & Idempotency Review (Stripe and more)

    Example session with this skill installed

    Customers sometimes get credits twice after paying. Review our Stripe webhook in Next.js.

    • Read your context and instructions
    • Compiled the webhook security

    Webhook review: app/api/stripe/route.ts

    #CheckStatusEvidenceFix
    1Signature verifiedFAILconst body = await req.json() then constructEvent(JSON.stringify(body), ...), wrapped in try/catch that only logsVerify on await req.text() and return 400 on failure
    2Raw bodyFAILRe-serialised JSON never matches the signatureSame as above
    4Replay windowPASS once #1 is fixedconstructEvent enforces 300 snone
    5IdempotencyFAILNo event ID stored; Stripe retries after a timeout and credits are added againwebhook_events (provider, event_id) primary key, insert first
    6Fast 2xxFAILHandler sends 2 emails and calls OpenAI before responding (8-12 s)Respond 200 after storing the event, do the work in a queue
    7Trust payloadFAILCredits = session.amount_total / 100 from the eventLook up the order by client_reference_id, credit the purchased pack
    8Out of orderPASSOnly checkout.session.completed handlednone

    Root cause of double credits: the slow handler (#6) times out, Stripe retries, and nothing de-duplicates (#5).

    Rewritten handler

    Raw-body verification, recordEvent('stripe', event.id) returning early on duplicates, enqueue, 200 in under 1 s. Includes the SQL migration for webhook_events.

    Repair

    A one-off script lists checkout.session.completed events for the last 30 days and finds users credited more than once. A nightly reconciliation job compares Stripe sessions with granted credits.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Webhook bugs are silent and expensive. A missing signature check lets anyone spoof a payment, while a slow handler causes timeouts and duplicate orders. This skill audits your webhook routes to ensure they are secure, idempotent, and resilient against provider retries.

    What it does

    • Signature verification ensures the handler validates provider secrets before triggering any side effects.
    • Raw body handling fixes verification failures caused by pre-parsed JSON middleware.
    • Idempotency implementation prevents duplicate processing of retried events using unique constraints.
    • Timing-safe comparison adds constant-time HMAC checks to prevent sensitive data leaks.
    • Asynchronous processing refactors slow handlers to acknowledge events quickly before performing heavy tasks.
    • State reconciliation drafts scheduled jobs to recover from missed events or provider outages.

    How it works

    1. Inventory endpoints by searching the codebase for provider SDK calls, signature headers, and callback routes.
    2. Audit handlers against eight critical failure points including timestamp tolerance, out-of-order safety, and payload trust.
    3. Rewrite code using verified patterns for your specific framework and provider.
    4. Generate migrations for the idempotency tables required to track processed event IDs.

    Frameworks & tools

    This skill works with Next.js, Express, Fastify, Supabase Edge Functions, and Django. It identifies issues with Stripe, Paddle, PayPal, GitHub, Shopify, WhatsApp/Meta, and Twilio SDKs.

    Why this beats prompting it yourself

    Generic prompts often miss the "raw body" requirement in frameworks like Next.js, leading to broken signatures. This skill follows a strict 8-point checklist that covers edge cases like event replay attacks and out-of-order state updates that manual prompting usually ignores.

    Use cases

    • Audit Stripe webhook routes in Next.js for signature and duplicate handling.
    • Fix orders being created twice when a payment provider retries a request.
    • Add HMAC verification to a custom payment gateway callback.
    • Refactor a slow webhook that times out under heavy load.

    Known limitations

    Requires access to the backend route handlers and database schema. It cannot fix issues residing solely within third-party provider dashboards.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 4 days ago

    Software
    Backend with webhook endpoints
    Optional
    Stripe CLI (for replay tests)

    Permissions

    Terminal / Shell
    Network Access
    Environment Variables
    Read Files
    Write Files
    Listed4 days ago

    What's inside

    Frequently Asked Questions

    This skill audits your webhook endpoints against eight critical failure points including signature verification, raw body handling, and idempotency to prevent silent errors like duplicate orders or security spoofs.

    You need to provide your AI agent with access to your backend route handlers and database schema, as the skill needs to review your code and generate migrations for idempotency tables.

    For each endpoint, you will receive a table detailing checks and failures with code references, followed by rewritten handler code and necessary database migrations to track processed event IDs.

    This skill cannot fix issues that reside solely within third-party provider dashboards, such as Stripe or PayPal settings, and it requires direct access to your codebase to function.

    You can ask your agent to audit specific routes like your Stripe webhook in Next.js for duplicate handling, or request it to add HMAC verification to a custom payment gateway callback.

    New in APIs & Backend

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.