Webhooks — PHP
Receive and process DigetPay payment notifications in PHP.
DigetPay sends HTTP POST notifications to your configured webhook URL when payment events occur. This stub shows the minimum PHP handler pattern.
Full guide: Handle Webhooks. Configure URLs via Webhook Configuration.
DigetPay may deliver the same event more than once. Always deduplicate by
transactionId+type.
Critical: Return
200 OKwithin a few seconds. Slow handlers cause retries and duplicate processing.
Flow
sequenceDiagram participant DigetPay as DigetPay participant Shop as Your PHP Server DigetPay->>Shop: POST JSON payload Shop-->>DigetPay: 200 OK Note over Shop: Process async — mark order paid
Handler stub
public/webhooks/digetpay.php:
<?php
declare(strict_types=1);
$raw = file_get_contents('php://input');
if ($raw === false) {
http_response_code(400);
exit;
}
$payload = json_decode($raw, true);
if (!is_array($payload)) {
http_response_code(400);
exit;
}
// Respond quickly — process async if heavy
http_response_code(200);
echo 'OK';
$transactionId = $payload['transactionId'] ?? null;
$orderId = $payload['orderId'] ?? null;
$status = $payload['status'] ?? null;
$type = $payload['type'] ?? null;
// TODO: Idempotent update — skip if transactionId already processed
// if ($status === 'Approved' && $type === 'Sale') { markOrderPaid($orderId, $transactionId); }
error_log('DigetPay webhook: ' . $raw);Example payload
{
"transactionId": "2232e99b-0257-47d5-bbfd-022c8951767f",
"orderId": "PAY-1781872369616",
"amount": 0.2,
"currencyCode": "682",
"status": "Approved",
"type": "Sale",
"cardScheme": "Mada",
"channel": "Payment Gateway"
}See Webhook Events and Webhook Security for signature verification.
Next steps
Updated about 1 month ago
Did this page help you?
