Callback URL

 

 

How Callback URLs Work in a Payment Integration

 

When a payment gateway detects a transaction event — such as a payment entering the mempool, reaching the required number of confirmations, expiring, or failing — it makes an HTTP POST request to the merchant's pre-configured callback URL. This request contains a structured payload (typically JSON) describing the event: the invoice ID, transaction status, amount, currency, TXID, timestamp, and any other relevant metadata.

The merchant's server receives this request, processes the event data — updating an order's status in the database, triggering fulfillment, sending a confirmation email — and returns an HTTP 200 response to acknowledge receipt. If the gateway does not receive a 200 response within a defined timeout period, it will retry the callback, typically with exponential backoff, for a set number of attempts.

 

Securing Callback Endpoints Against Spoofing

 

A callback URL is a publicly reachable HTTP endpoint. Without authentication, an attacker who discovers the URL could send fabricated payment confirmation events and trick the merchant's system into fulfilling orders that were never actually paid. Every production payment integration must validate that incoming callback requests originate from the legitimate gateway.

The standard method is HMAC signature verification: the gateway computes an HMAC of the request payload using a shared secret and includes the signature in a request header (e.g., X-Signature or X-Webhook-Secret). The merchant's callback handler recomputes the HMAC using the same shared secret and compares it to the received signature. If they match, the request is authentic.

Never trust a callback payload without signature validation. Fulfilling an order based on an unverified 'payment confirmed' callback is a common and costly integration error.

 

Callback URL vs. API Polling — Why Callbacks Are Preferred

 

Approach

How It Works

Latency

Server Load

Reliability

Callback (webhook)

Gateway pushes event to merchant

Near real-time

Low — only fires on events

Depends on retry logic

API polling

Merchant repeatedly queries gateway

Depends on poll interval

High — constant requests

Higher — not event-driven

 

Polling is simpler to implement but inefficient: a merchant checking payment status every 5 seconds generates 12 requests per minute per pending order, most of which return no change. Callback-driven architectures only exchange data when something meaningful happens. For high-volume merchants processing thousands of orders simultaneously, the difference in server load and API rate limit consumption is significant.

 

Common Callback Integration Errors

 

The most frequent callback implementation mistakes in crypto payment integrations include:

        Not validating the HMAC signature, leaving the endpoint open to spoofing.

        Returning a non-200 response from the callback handler, causing unnecessary retries.

        Processing the same event multiple times because the same callback is delivered more than once (always implement idempotency using the invoice ID as a deduplication key).

        Using the callback payload's amount field without cross-referencing it against the expected invoice amount, allowing underpayments to pass as confirmed.

        Failing to handle the 'expired' callback event, leaving the merchant's system in a perpetually 'pending' state for invoices that will never confirm.

 

Testing Callback Endpoints Before Going Live

 

Payment gateways provide sandbox environments where test transactions trigger real callback events to a specified URL. During development, tools like ngrok or similar tunnelling services expose a local development server to the internet so that sandbox callbacks can be received and inspected in real time. Merchants should test every possible payment event type — confirmed, expired, underpaid, overpaid — before going live, since edge cases in callback handling are a common source of production bugs.

 

Compliance Note: This glossary entry is provided for general educational purposes only and does not constitute financial, investment, legal, or tax advice. Industry terminology may vary across jurisdictions and providers; definitions herein may not directly reflect the specific features, terms, or specifications of Finassets' services. For details on Finassets' offerings, please refer to official product documentation or contact our team directly.