Accept Bitcoin on Your Own Website — Crypto Payment API Guide
If you control the codebase, the API route gives you the most control and the least surface area: create an invoice, redirect or embed, then trust a signed webhook for state. Nothing about the flow depends on a plugin keeping pace with a platform upgrade.
- Integration method
- REST API
- Time needed
- About 30 minutes for a developer
- Skill level
- Developer
Before you start
- •A free PayCryptoHost account.
- •Your Bitcoin extended public key (xPub / zPub) from a wallet you control — Sparrow, Electrum, BlueWallet, Trezor or Ledger all export one.
- •Admin access to your store or billing panel.
- •A server-side environment where you can keep an API key secret.
An extended public key only lets software watch addresses and derive new ones — it can never move funds. Never paste a private key or seed phrase anywhere, including here.
Step-by-step setup
- 1
Create a server-side API key
Keep it in an environment variable. Never ship it to the browser — invoice creation must happen on your server.
- 2
Create an invoice
POST the amount, currency, description and customer email to the invoice endpoint. You get back a payment ID and a hosted payment URL.
- 3
Send the customer to the invoice
Redirect, or open the URL in a new tab. The page shows the address, QR code, locked quote and a live confirmation counter.
- 4
Verify the webhook
Compute the HMAC over the raw request body and compare it in constant time before trusting any field.
- 5
Be idempotent
Webhooks can retry. Key your handler on the payment ID and transaction ID so a repeat delivery cannot double-fulfil an order.
- 6
Poll as a backstop
For critical fulfilment, also poll the invoice status endpoint on a schedule so a missed webhook never strands an order.
What you get
- •No plugin to maintain across platform upgrades.
- •Works identically for web, mobile and backend billing jobs.
- •Signed webhooks plus a status endpoint make reconciliation exact.
- •Self-custodial by construction — addresses derive from your xPub.
Troubleshooting
Signature mismatch on every webhook
Almost always caused by verifying a re-serialised body. Capture the raw bytes before your JSON body parser runs.
Duplicate fulfilment
Add a unique constraint on the payment ID in your orders table so retried webhooks fail closed instead of firing twice.
Frequently asked questions
Is there a sandbox?
Yes — you can create test invoices from the dashboard, and small real amounts are the most faithful final check before going live.
What does the webhook contain?
The payment ID, status, amounts in fiat and crypto, the coin, and the transaction ID once seen on-chain.
Can I use it for recurring billing?
Yes. Create a new invoice each cycle; each one derives its own address, so nothing is reused between periods.
Ready to take your first crypto payment?
Create an account, add your xPub, and send a test invoice — most merchants are live the same day.
Other platform guides
See all platform integrations, browse industry guides, or compare us against other gateways.