Skip to content

Development & Engineering

Webhook Verification

Free

Accept a payment or provider webhook only after the signature is checked on the server.

Difficulty advanced
Version v1.1

Purpose

Prevent a browser or a stranger from posting {paid: true} and unlocking Premium.

Procedure

--- name: webhook-verify description: Accept a payment or provider webhook only after the signature is checked on the server. ---

Webhook Verification

Purpose

Prevent a browser or a stranger from posting {paid: true} and unlocking Premium.

Procedure

A webhook is an untrusted HTTP request until the signature matches.

Required:

  • Read the raw body the provider signed. Do not verify a re-serialized object.
  • Compare the signature to an HMAC or the provider's documented scheme using the server-side secret. Use a constant-time comparison if you implement it yourself; otherwise use the provider's library.
  • If the secret is absent, reject the request. Do not skip verification in development by granting the entitlement.
  • Reject stale timestamps if the provider sends them.
  • Store the event id and ignore duplicates. Granting Premium twice must not extend or corrupt the subscription.
  • Only after the signature, the amount, the currency, and the reference match a pending payment do you mark it verified and activate the subscription.
  • Underpayment does not activate. Overpayment does not activate automatically; record it for review.

The browser's success URL is not proof. It may show a pending state and then read the subscription from your database.

Never log the signing secret. Never echo the raw payload back to the client.

Example requests

1. Is checkout done

Request: Review the billing webhook using Webhook Verification. The provider secret is not set. Expected: A rejection when the secret is missing. Premium is not granted.

Dependencies

None. Work in the repository that is already open. Do not add packages unless the procedure names one.

Compatibility

This document follows the Agent Skills layout (a folder named webhook-verify containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it.

Example prompts

Is checkout done

Review the billing webhook using Webhook Verification. The provider secret is not set.

Expected: A rejection when the secret is missing. Premium is not granted.

Choose the agent

This skill is installed for one agent at a time. Pick the section you are using.

Related

  • Secrets Handling

    Keep credentials on the server, out of the client bundle, and out of the repository.

  • Threat Model a Change

    Walk a change for spoofing, tampering, and data exposure before it ships.

  • Schema Contracts

    Validate input at the server boundary and return a stable error shape.

Reviews

No reviews yet.

    Sign in to review.

    Report a problem

    Inaccurate steps, an unsafe instruction, or a licensing concern.

    Sign in to report.