# Callbacks Callbacks are **mandatory** for asynchronous finalization. When a payment reaches a final state, GoDigital sends a `POST` to your `callbackUrl` (or the callback URL configured on your merchant profile). ## Endpoint requirements | Requirement | Description | | ---------------- | ------------------------------------------------------------------- | | Protocol | HTTPS only | | Method | `POST` | | Content type | `application/json` | | Response | Return HTTP `200` as soon as the callback is accepted for processing | | Idempotency | Safely handle duplicate callbacks for the same `transactionId` | | Timeout handling | GoDigital retries on timeouts and non-2xx responses | ## Payload ```json { "status": "SUCCESS", "code": "PGW-0000", "message": "Request processed successfully", "timestamp": "2026-04-19T21:15:33+03:00", "data": { "transactionId": "TXN-20260419-000022", "requestId": "3cf73c52-d6b0-4906-8b5d-f9a4f82b5011", "providerCode": "VODACOM", "operation": "C2B_USSD_PUSH", "transactionStatus": "SUCCESS", "amount": 10000.00, "currency": "TZS", "msisdn": "255754123456", "reference": "INV-1001", "providerTransactionId": "919994765", "providerReceiptNo": "5HN31LXJQAX", "message": "Transaction finalized successfully" } } ``` :::danger{title="Read data.transactionStatus, not status"} The top-level `status` and `code` describe the **callback delivery** and are `SUCCESS` / `PGW-0000` even when the payment **failed**. The payment result is in **`data.transactionStatus`** (`SUCCESS`, `FAILED` or `REVERSED`), with the reason in `data.message`. ::: ## Signature headers | Header | Description | | ---------------------------------------- | ------------------------------------------------------------- | | `X-Callback-Id` | Unique callback delivery identifier. | | `X-Callback-Timestamp` | Callback creation timestamp. | | `X-Callback-Content-SHA256` _(optional)_ | SHA-256 of the raw body, Base64-encoded. | | `X-Callback-Signature` _(optional)_ | Base64 HMAC-SHA256 signature using your callback secret. | Signature validation is optional and enabled per merchant during onboarding. ## Acknowledge the callback ```http HTTP/1.1 200 OK Content-Type: application/json { "status": "RECEIVED", "message": "Callback accepted" } ``` Acknowledge first, then process in the background. Slow handlers cause timeouts and retries. ## Retry policy If your endpoint does not return HTTP `200` within the configured timeout, or returns a non-2xx status, GoDigital schedules retries. Repeated failures are visible in the callback logs available to you and to GoDigital administrators. ## Example handler ```js title="Express.js" app.post("/api/payment-result", express.json(), async (req, res) => { res.status(200).json({ status: "RECEIVED", message: "Callback accepted" }); const { transactionId, transactionStatus, reference, message } = req.body.data; if (await alreadyProcessed(transactionId)) return; // duplicates are expected if (transactionStatus === "SUCCESS") await markPaid(reference); else if (transactionStatus === "FAILED") await markFailed(reference, message); else if (transactionStatus === "REVERSED") await markReversed(reference); }); ```