Skip to main content

What are Webhooks?

Webhooks are HTTP POST requests that Card2Crypto sends to your server when important events occur, such as when a payment is completed, fails, or is refunded. Instead of repeatedly polling the API to check payment status, webhooks push notifications to you in real-time.

Why Use Webhooks?

Real-Time Updates

Get instant notifications the moment a payment completes

Reliable

Automatic retries ensure you don’t miss critical events

Efficient

No need to poll the API - we push updates to you

Secure

HMAC signatures verify webhooks are authentic

How Webhooks Work

Setting Up Webhooks

1. Create an Endpoint

Create an HTTP endpoint on your server that accepts POST requests:

2. Configure in Dashboard

  1. Go to Dashboard > API Keys
  2. Click on your shop settings
  3. Enter your webhook URL
  4. Copy your webhook secret
  5. Save settings
Use the “Test Webhook” button to verify your endpoint is working correctly.

3. Verify Signatures

Always verify the webhook signature to ensure it’s from Card2Crypto:
See Webhook Security for complete implementation.

Webhook Events

Card2Crypto sends webhooks for these events: Learn more in Webhook Events.

Webhook Payload

All webhooks include:

Retry Behavior

If your endpoint doesn’t respond with 200 OK, Card2Crypto automatically retries:
  • Retry 1: After 2 seconds
  • Retry 2: After 4 seconds
  • Retry 3: After 8 seconds (final attempt)
After 3 failed attempts, the webhook is marked as failed and logged in your dashboard.
Your endpoint must respond within 10 seconds, or the request will timeout.

Best Practices

Process webhooks asynchronously. Return 200 OK immediately, then handle the event in the background.Good:
Bad:
You might receive the same webhook multiple times. Implement idempotency:
Keep detailed logs of all webhooks for debugging:
Check your Dashboard > Webhook Logs regularly for failed deliveries.

Testing Webhooks

Local Development

Use tools like ngrok to expose your local server:

Test Webhook Button

Use the “Test Webhook” button in your shop settings to send a test event:

Troubleshooting

Check:
  • Is your webhook URL correct and publicly accessible?
  • Is your server running and accepting POST requests?
  • Check your firewall settings
  • Look for errors in Dashboard > Webhook Logs
Check:
  • Are you using the correct webhook secret?
  • Are you JSON.stringify-ing the payload exactly as received?
  • Are you using HMAC-SHA256 (not SHA256)?
  • Check for middleware that modifies req.body
Fix:
  • Return 200 OK immediately
  • Process webhooks asynchronously
  • Optimize slow database queries
  • Remove external API calls from webhook handler

Next Steps

Webhook Security

Learn how to verify webhook signatures

Webhook Events

Complete list of webhook event types