Create a destination

POST/webhooks.php
Terminal
curl "https://circus-pay.com/api/webhooks.php" \
  -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "url": "https://example.com/webhooks/circuspay",
  "events": [
    "payment.succeeded",
    "payment.failed",
    "payment.refunded"
  ],
  "description": "Boutique principale"
}'

Store the webhook.secret returned at creation in CIRCUSPAY_WEBHOOK_SECRET. It verifies signatures and is distinct from your API key.

Verify the signature

X-ONIPAY-Signature contains the hexadecimal HMAC-SHA256 of the raw HTTP body, computed with the webhook secret. Verify the exact received body before re-encoding JSON.

PHP · signature verification
<?php
$raw = file_get_contents('php://input');
$received = $_SERVER['HTTP_X_ONIPAY_SIGNATURE'] ?? '';
$secret = getenv('CIRCUSPAY_WEBHOOK_SECRET');
if (!$secret || !preg_match('/^[a-f0-9]{64}$/', $received)) {
    http_response_code(400); exit;
}
$expected = hash_hmac('sha256', $raw, $secret);
if (!hash_equals($expected, $received)) {
    http_response_code(400); exit;
}
$event = json_decode($raw, true);
if (!is_array($event)) { http_response_code(400); exit; }
// Persist the event durably before returning 2xx.
// Deduplicate fulfilment by your order + transaction reference.
// Verify order, amount, currency and final status server-side.
// Return 5xx if durable processing/queuing fails.

Process events

ParameterDescription
payment.succeededVerify the payment, then confirm the order exactly once.
payment.failedRecord the failed attempt without confirming the order.
payment.refundedSynchronize refund status.
webhook.testTechnical test of your destination. Does not trigger order fulfilment.

Payment events use an envelope with type, created and data. The contents of data depend on the flow. Do not assume every event shares the same schema; reconcile references with your transactions.

Test reception

POST/webhooks.php?action=test
Terminal
curl "https://circus-pay.com/api/webhooks.php?action=test" \
  -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "id": 123
}'

Inspect deliveries

GET/webhooks.php?id=123&logs=1
Terminal
curl "https://circus-pay.com/api/webhooks.php?id=123&logs=1" \
  -H "Authorization: Bearer $CIRCUSPAY_SECRET_KEY"

Replace 123 with your webhook ID. The logs response contains the last 50 deliveries, including HTTP status, duration and any error.