Skip to main content
Webhooks in meCash are signed with HMAC-SHA256 to ensure authenticity and integrity. This guide shows you how to verify webhook signatures in different programming languages.

Overview

Each webhook request includes a signature in the X-meCash-Signature header. You must verify this signature to ensure the webhook came from meCash and wasn’t tampered with.

Signature Format

Getting Your Webhook Secret

  1. Log into your meCash dashboard
  2. Navigate to DeveloperWebhooks
  3. Find your webhook endpoint
  4. Copy the webhook secret
Keep your webhook secret secure and never expose it in client-side code.

Verification Process

  1. Extract the signature from the X-meCash-Signature header
  2. Create a payload string from the request body
  3. Generate HMAC-SHA256 using your webhook secret
  4. Compare signatures using a constant-time comparison

Code Examples

Node.js

Python

PHP

Ruby

Go

Testing Webhook Verification

Test Your Implementation

Expected Responses

  • Missing signature: 400 Bad Request.
  • Invalid signature: 401 Unauthorized.
  • Valid signature: 200 OK.

Security Best Practices

1. Always Verify Signatures

Never process webhooks without signature verification:

2. Use Constant-Time Comparison

Always use constant-time comparison to prevent timing attacks:

3. Store Secrets Securely

4. Handle Raw Request Body

Make sure to use the raw request body for signature verification:

Common Issues

Issue 1: Signature Mismatch

Problem: Signature verification always fails. Solutions:
  • Check that you’re using the raw request body.
  • Verify the webhook secret is correct.
  • Ensure you’re removing the ‘sha256=’ prefix.

Issue 2: Missing Signature Header

Problem: X-meCash-Signature header is missing. Solutions:
  • Check your webhook endpoint configuration.
  • Verify the header name is correct (case-sensitive).
  • Ensure your server is receiving all headers.

Issue 3: Body Parsing Issues

Problem: Request body is modified before verification. Solutions:
  • Use raw body parsing for webhook endpoints.
  • Don’t use JSON middleware before signature verification.
  • Parse JSON after signature verification.

Monitoring & Debugging

Log Signature Verification

Webhook Testing Tool

Create a simple test endpoint: