Aller au contenu principal
Version: 1.0.1

Webhooks

Webhooks allow you to receive real-time notifications when events occur in your Dimebia account.

Overview

Webhooks are HTTP callbacks triggered by events. Dimebia sends a POST request to your configured endpoint when specific events occur.

Supported Events

Transaction Events

EventDescription
transaction.createdA new transaction was created
transaction.processingTransaction is being processed
transaction.succeededPayment completed successfully
transaction.failedPayment failed
transaction.refundedTransaction was refunded
transaction.cancelledTransaction was cancelled

Subscription Events

EventDescription
subscription.createdNew subscription created
subscription.updatedSubscription was modified
subscription.cancelledSubscription was cancelled
subscription.expiredSubscription expired
invoice.paidInvoice was paid
invoice.payment_failedInvoice payment failed

Configure Webhooks

POST /api/webhook/register
{
"url": "https://your-domain.com/webhooks/dimebia",
"events": [
"transaction.succeeded",
"transaction.failed",
"invoice.paid"
],
"secret": "your-webhook-secret"
}

Webhook Payload

{
"id": "evt_1234567890",
"type": "transaction.succeeded",
"created": 1724000000,
"data": {
"object": {
"id": "TXN2026081800001",
"amount": 100000,
"currency": "USD",
"status": "SUCCESS",
"createdTime": "2026-08-18T10:00:00Z"
}
}
}

Webhook Headers

HeaderDescription
X-Dimebia-SignatureHMAC-SHA256 signature for verification
X-Dimebia-EventEvent type
X-Dimebia-DeliveryUnique delivery ID
Content-Typeapplication/json

Verify Webhook Signatures

Always verify webhook signatures:

import crypto from 'crypto';

function verifyWebhook(payload: string, signature: string, secret: string): boolean {
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}

Retry Policy

  • Retry count: 3 attempts
  • Retry interval: 1 minute, 5 minutes, 30 minutes
  • Timeout: 10 seconds per attempt

Best Practices

  1. Respond quickly: Return 200 OK within 10 seconds
  2. Queue processing: Process webhooks asynchronously
  3. Handle duplicates: Use the delivery ID to deduplicate
  4. Verify signatures: Always verify webhook signatures