settlematic
Developers··7 min read·By Keshav Sharma

Crypto Payment Webhooks: Implementation and Automated Reconciliation

Discover how crypto payment webhooks detect on-chain confirmations, verify cryptographic signatures, and automate accounting reconciliation without custodial risk.

Do this next

Create a crypto invoice

  1. Quote the invoice in fiat.
  2. Client pays USDC, USDT, or EURC.
  3. Funds settle to a wallet you already control.

TL;DR

Crypto payment webhooks notify backend systems when an on-chain deposit reaches a designated confirmation threshold. A non-custodial gateway monitors block headers, matches transaction hashes to issued invoice IDs, computes HMAC-SHA256 signatures for payload integrity, and dispatches real-time event notifications to automate accounting reconciliation.

Settlematic webhook endpoint setup subscribing to invoice and payment events for automation

Crypto payment webhooks notify backend systems when an on-chain deposit reaches a designated confirmation threshold. A non-custodial gateway monitors block headers, matches transaction hashes to issued invoice IDs, computes HMAC-SHA256 signatures for payload integrity, and dispatches real-time event notifications to automate accounting reconciliation.

Integrating automated payments requires moving beyond polling block explorers. For modern engineering teams building financial applications, real-time webhooks form the primary interface between distributed blockchain networks and traditional accounting systems. When customer funds settle directly into merchant wallets, event-driven webhooks guarantee instant order fulfillment and accurate ledger entries. Explore technical setup options in our developer documentation.

How do crypto payment webhooks fire on-chain?

Unlike traditional payment processors that update internal databases during centralized ledger transfers, a crypto payment gateway operates continuous chain-indexing watchers. These infrastructure nodes monitor unconfirmed transactions in the mempool and validated transactions in new block headers across supported networks including Ethereum, Polygon, Solana, Bitcoin, BSC, and Tron.

The event lifecycle follows a deterministic sequence from transaction broadcast to accounting settlement:

  • Address Generation: An invoice or checkout session creates a deposit address cryptographically bound to the merchant's receiving wallet.
  • Mempool Detection: Indexers detect an incoming transaction matching the deposit address and issue an initial invoice.payment_detected event.
  • Block Finality Verification: The system tracks block confirmations until reaching chain-specific finality thresholds, detailed in our guide to on-chain payment confirmation.
  • Payload Construction & Signing: Upon reaching full confirmation, the gateway constructs a structured JSON payload, signs it using HMAC-SHA256, and dispatches an HTTP POST request to the merchant's registered endpoint.
  • Reconciliation Trigger: The merchant backend validates the request signature, processes the invoice state change, updates ledger balances, and returns an HTTP 200 OK response.

Securing webhook endpoints with cryptographic signatures

Exposing a public HTTP endpoint to receive payment state changes introduces security risks if requests are not verified. Malicious actors could send forged POST payloads pretending an invoice has been paid. Webhook signature verification guarantees message authenticity, data integrity, and protection against replay attacks.

Following cryptographic standards like RFC 2104, secure webhook verification relies on symmetric HMAC-SHA256 signatures. When setting up endpoints, follow these security practices:

  • Timestamp Inclusion: Include a UNIX timestamp in the custom signature header to prevent replay attacks. Reject payloads older than 5 minutes.
  • Raw Body Parsing: Compute the HMAC digest using the exact raw string body before any JSON deserialization alters spacing or key ordering.
  • Constant-Time Comparison: Use constant-time comparison functions to evaluate signature matches, preventing timing side-channel attacks, as highlighted in crypto payment security best practices.
  • Secret Key Rotation: Store webhook signing secrets in enterprise vault infrastructure and support seamless key rotation without downtime.

Comparing crypto webhook event states and reconciliation flows

Event TypeOn-Chain ConditionPayload ParametersBackend Reconciliation Action
invoice.createdInvoice issued; deposit address assignedinvoice_id, amount_fiat, deposit_address, expires_atCreate pending receivable in accounting system
invoice.payment_detectedTransaction spotted in mempool / 0-conftx_hash, chain, raw_amount, sender_addressMark order as processing; display pending alert
invoice.confirmedRequired block confirmations achievedtx_hash, block_number, fee_paid, confirmed_atMark invoice paid; trigger product release & book GL entry
invoice.underpaidPayment received is less than total duereceived_amount, remaining_due, tx_hashRecord partial payment ledger entry; notify customer
invoice.expiredExpiration window reached with zero depositsinvoice_id, status: expiredCancel pending invoice; release reserved inventory
Standard webhook event types, triggered condition triggers, and recommended merchant reconciliation actions for non-custodial gateways.

Automating accounting reconciliation for crypto invoices

Automated reconciliation is the process of matching bank or wallet deposits against accounts receivable ledgers. In crypto invoicing, manual matching of hexadecimal hashes and variable gas fees quickly becomes inefficient for growing enterprises.

A structured webhook integration automates three core reconciliation challenges:

  • Fiat-Quoted Exchange Rate Locking: When invoicing in USD or EUR and collecting in USDC, USDT, or BTC, the webhook delivers both the target fiat value and the converted crypto value. This provides audit trails for gain/loss accounting.
  • Metadata Mapping: Payloads transmit internal customer IDs, order numbers, and project codes alongside blockchain hashes, allowing direct posting into ERP platforms like QuickBooks, Xero, or SAP.
  • Gas & Network Fee Attribution: Settlematic's non-custodial design ensures customers pay network transfer fees on-chain. Webhook data isolates net receiving amounts so accounting ledgers accurately balance to the penny.

Handling edge cases: retries, idempotency, and reorgs

Reliable webhook consumers must handle network outages, transient server errors, and rare blockchain chain reorganizations. Engineering resilient webhook processing requires building for idempotency and defensive event handling.

If your backend fails to return a 2xx HTTP status code within 5 seconds, the gateway initiates exponential backoff retries over 24 hours. To prevent duplicate processing of retried events, store processed message IDs or transaction hashes in a cache and drop already-handled requests.

Furthermore, deep chain reorganizations on PoW or PoS networks can temporarily reverse unfinalized blocks. Waiting for recommended confirmation thresholds before firing final invoice.confirmed webhooks mitigates reorg risk completely. Integrators using our embedded payment tools via Gateway gain out-of-the-box protection against partial state drops.

Build reliable crypto workflows with Settlematic

Automating your payment reconciliation eliminate administrative overhead while ensuring complete control over revenue. Settlematic delivers real-time signed webhooks, dynamic fiat-quoted invoices, and instant non-custodial settlement directly to your business wallets.

Ready to test automated webhook processing in a risk-free environment? Launch your integration in seconds with our developer sandbox or explore our live demo.

Sources

Frequently asked questions

What is a crypto payment webhook?
A crypto payment webhook is an automated HTTP POST notification sent by an engine or gateway to your application server whenever an on-chain event—such as a transaction detection, confirmation threshold achievement, or invoice expiration—occurs for an invoice or deposit address.
How do you verify the cryptographic signature of a crypto webhook?
Your server retrieves the raw request body and timestamp header, concatenates them with a shared secret key, and computes an HMAC-SHA256 digest. You then perform a constant-time equality check against the signature provided in the request header to prevent tampering and replay attacks.
How does automated crypto accounting reconciliation handle exchange rate changes?
In fiat-quoted crypto invoicing, the payment gateway captures the exact fiat equivalent at invoice creation or transaction detection time. Webhook payloads deliver both the raw crypto unit amount and the locked fiat valuation, allowing ERP systems to book revenue accurately while recording exchange gains or losses automatically.
What happens if a customer underpays or sends funds after invoice expiration?
The gateway fires a distinct webhook event (such as invoice.partial_payment or invoice.overpaid). Your backend receives the event payload detailing the expected amount versus received amount, enabling automated partial ledger posting or customer notification workflows.
Why are webhooks essential for non-custodial payment gateways?
Because non-custodial gateways like Settlematic never hold merchant funds, your backend relies on real-time webhooks to confirm that funds landed directly in your cold or hot wallet, triggering order fulfillment without manual block explorer checks.

Continue reading

Start invoicing and accepting crypto payments

Collect and Gateway on one non-custodial platform - funds always sweep to wallets you control.