Payments
Crypto Payments — Hosted checkout & API for 110+ coins White Label — Your brand on the entire payment flow Processing — Auto-convert, withdrawals & controls Payouts — Mass crypto payouts by API or file Platform — Marketplace payments & commissions
Swap Plugins Affiliate Pricing Blog Docs Contact
Language
Sign in
All articles

Webhooks and Idempotency: Building a Reliable Crypto Integration

A short, practical guide for developers: how to verify CryptoPayr webhooks, handle retries safely with idempotency, and never double-fulfil an order.

CryptoPayr Jul 8, 2026 2.00 min read

If you are integrating CryptoPayr yourself, two concepts will make your checkout bulletproof: signed webhooks and idempotency. Get these right and you will never double-ship an order or trust a forged callback.

Verify every webhook

When a payment changes state, CryptoPayr POSTs your webhook_url a JSON body and signs it with your API key using HMAC-SHA256, in the X-CryptoPayr-Signature header. Recompute it and compare before you trust anything:

$sig = hash_hmac('sha256', $rawBody, $YOUR_API_KEY);
if (!hash_equals($sig, $_SERVER['HTTP_X_CRYPTOPAYR_SIGNATURE'])) { http_response_code(401); exit; }

Only act on the payload once the signature matches and the status is COMPLETED.

Make fulfilment idempotent

Networks retry. You may receive the same webhook more than once, so fulfilment must be safe to run repeatedly. The pattern:

  1. Look up the order by its tid.
  2. If it is already marked fulfilled, return 200 and stop.
  3. Otherwise, fulfil it and mark it fulfilled in the same transaction.

On the create side, send an Idempotency-Key header with POST /api/v1/payment/create so a retried create returns the original payment instead of making a second one.

Respond fast, do work async

Acknowledge the webhook quickly with a 200, then do any slow fulfilment work in a background job. Slow webhook responses invite more retries.

Test before you ship

Run a small real payment end to end and confirm your handler marks the order paid exactly once. The full reference lives in the API docs.

Grab an API key and build a checkout you can trust.

Start accepting crypto today

Open a free CryptoPayr account and take your first crypto payment the same day.

Get started for free

Keep reading

📝 Guides

How to Invoice in Crypto: A Practical Guide for Businesses

Learn how to create efficient invoices in cryptocurrency with clear steps. Streamline your billing process and embrace digital payments today!

Aug 13, 2026 · 18.00 min Read →
📝 Guides

Marketplace Split Payments: A Complete Builder's Guide

Learn how marketplace split payments work, optimize transactions, and ensure timely payouts for vendors with this comprehensive builder's guide.

Aug 12, 2026 · 20.00 min Read →
📝 Guides

How to Accept Stablecoin Payments: A U.S. Guide

Learn how to accept stablecoin payments easily and quickly with hosted checkouts or integrated payment gateways in this U.S. guide.

Aug 11, 2026 · 17.00 min Read →