Accepting Crypto Payments: A Developer's Integration Map
Custodial gateway or self-hosted node? Confirmation depths, webhook idempotency and the reconciliation details nobody warns you about.
Two architectures
A custodial gateway hands you a REST API and takes a cut. A self-hosted node hands you full control and full responsibility. Most businesses should start custodial and migrate only when volume justifies the ops burden.
Webhooks must be idempotent
Chains reorg. Gateways retry. Your handler will see the same payment event more than once.
const seen = await db.event.findUnique({ where: { id: event.id } });
if (seen) return new Response(class="text-code-string">"ok");
await db.event.create({ data: { id: event.id } });
await creditOrder(event.orderId, event.amount);Confirmation depth
Pick a depth per asset and per order value. One confirmation is fine for a $5 digital download; it is reckless for a $5,000 invoice.
Reconciliation
Price at time of quote, price at time of settlement, and network fee all differ. Store all three or your accountant will find you.
Paj Digital Labs
The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.