Skip to main content

Why Verify Signatures?

Anyone can send a POST request to your webhook URL. Without signature verification, an attacker could send fake payment.success events to your endpoint — causing you to fulfill orders that were never actually paid. CWMPay signs every webhook request using HMAC-SHA256. Always verify this signature before processing.

How It Works

  1. CWMPay generates a signature by running HMAC-SHA256 on the request payload using your Webhook Secret
  2. The signature is sent in the X-CWMPay-Signature header
  3. Your server generates the same signature using the same secret
  4. If both signatures match — the request is genuine

Getting Your Webhook Secret

  1. Login to app.cwmpay.in
  2. Go to Webhooks section
  3. Set your webhook URL and save
  4. Your Webhook Secret will be displayed once — copy and store it safely
Your webhook secret is shown only once when you first set your webhook URL. Store it in an environment variable immediately. If lost, you’ll need to reset your webhook URL to get a new secret.

Verification Examples

Important Notes

Always use crypto.timingSafeEqual() (Node.js) or hmac.compare_digest() (Python) instead of === for signature comparison. Regular string comparison is vulnerable to timing attacks.
Verify the signature against the raw JSON string — not a parsed and re-serialized object. JSON key ordering may differ and cause signature mismatch.
Never hardcode the secret in your source code.

Next Steps

Webhooks Overview

Learn about webhook events and payload

Error Reference

View all error codes