Skip to main content

Why Verify Webhooks?

Anyone can send a POST request to your webhook endpoint. Without verification, a malicious actor could send fake payment notifications to your server. HMAC signatures ensure that webhooks are genuinely from Card2Crypto and haven’t been tampered with.

How Signature Verification Works

When Card2Crypto sends a webhook, we include an HMAC-SHA256 signature in the X-Card2Crypto-Signature header. This signature is generated using:
  1. Your webhook secret (from your shop settings)
  2. The complete webhook payload
  3. HMAC-SHA256 algorithm
You can recreate this signature on your server and compare it to verify authenticity.

Verification Implementation

Node.js / JavaScript

PHP

Python

Common Mistakes

Mistake 1: Not Using Raw Body

Mistake 2: Using Wrong Secret

Mistake 3: Modifying Payload Before Verification

Security Best Practices

1. Always Verify Signatures

Never skip signature verification, even in development:

2. Use HTTPS Only

Always use HTTPS for your webhook endpoint. HTTP traffic can be intercepted and modified.

3. Keep Secrets Secure

Never commit webhook secrets to version control:

4. Use Timing-Safe Comparison

Always use timing-safe comparison to prevent timing attacks:

5. Limit Request Size

Prevent memory exhaustion attacks by limiting webhook payload size:

Webhook Replay Protection

Implement timestamp verification to prevent replay attacks:

Testing Signature Verification

Test your implementation using the “Test Webhook” button in your shop settings. Expected test payload:
Your verification should succeed if:
  • You’re using the correct webhook secret
  • You’re properly generating the HMAC-SHA256 signature
  • You’re not modifying the payload before verification

Troubleshooting

Signature Always Fails

Problem: Verification always returns false, even for valid webhooks. Solutions:
  1. Check you’re using the webhook secret (not API key):
  1. Ensure you’re not modifying the payload:
  1. Verify you’re using HMAC-SHA256:

Webhook Secret Not Working

Problem: Can’t find webhook secret or it doesn’t work. Solutions:
  1. Go to Dashboard > Shops
  2. Click your shop settings
  3. Find “Webhook Secret” section
  4. Click “Regenerate Secret” if needed
  5. Copy the new secret and update your environment variables

Test Webhook Fails

Problem: Test webhook button shows verification failed. Solutions:
  1. Check your server logs for the actual error
  2. Ensure your endpoint is publicly accessible
  3. Verify you’re returning 200 OK status
  4. Test with a tool like ngrok if developing locally

Next Steps

Webhook Events

Complete list of webhook event types

Testing Webhooks

How to test webhooks in development