Receiving Payments
Unified API to accept crypto payments on your website. One crypto-agnostic interface, built for both humans and AI agents.
Payment Intents API works on orders level using fiat amounts. It abstracts crypto payment processing so that you can accept multiple crypto by just implementing a single API. If your integration needs fine grain control of crypto payments, use Raw Payments API.
How It Works
- Create an intent. Your server creates a payment intent for the order amount with your API key.
- Pass the ID. Your server sends the intent ID to your checkout page. The page needs nothing else.
- Get a quote. The checkout page asks Blockonomics for the status and a quote: address, amount and a 5-minute price lock.
- Customer pays. The customer sends the amount. The page shows a receipt once the payment is detected.
- Callback. Blockonomics calls your callback URL with status
paidonce the payment confirms. - Get payment quotes (optional). Your server gets the intent's payment_quotes to get the crypto payment details: crypto txid and crypto amount.
- Fulfil the order. Your server fulfils the order.
Setup
1. Get Your API Key
Register on Blockonomics and get APIKey from Stores.
2. Add a Wallet
- Go to Wallets and click Add a wallet
- Select the cryptocurrency (BTC or USDT), fill out the form and click Create wallet. Add one wallet per crypto you accept.
3. Add a Store
- Go to Stores and click Add a store
- Fill out the form and click Create Store
- Enable each crypto and select its wallet
- Set the callback URL as indicated below
- The store's callback URL must be reachable from the internet.
- For production/remote site use its domain as DOMAIN. For local deployment, use a tunnel such as ngrok (
ngrok http 3000) or localhost.run - Use a high entry random string as SECRET
- Set store callback as
https://DOMAIN/callback_endpoint?secret=SECRET.

To add/modify wallets and stores programmatically refer to wallets and stores API endpoints
Frontend Implementation
Option 1: Use checkout.js (Recommended)
checkout.js handles crypto selection, QR code, price refresh, EVM wallet connect, underpayment top-ups and the receipt.
1. Create the intent on your server and return only its ID:
// Express.js example
app.post('/api/checkout', async (req, res) => {
const order = await createOrder(req.body) // your code
const response = await fetch('https://www.blockonomics.co/api/v2/payment_intents', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BLOCKONOMICS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ amount: order.total.toFixed(2), currency: 'USD', extra_data: order.id }),
})
const { data: intent } = await response.json()
await saveIntentId(order.id, intent.id) // your code
res.json({ intent_id: intent.id })
})2. Mount the widget:
<script src="https://www.blockonomics.co/js/checkout.js"></script>
<button id="pay">Pay with crypto</button>
<div id="payment_area"></div>
<script>
document.getElementById('pay').addEventListener('click', async () => {
const { intent_id } = await fetch('/api/checkout', { method: 'POST' }).then((r) => r.json())
Blockonomics.checkout({ msg_area: 'payment_area', intent_id })
})
</script>| Option | Required | Description |
|---|---|---|
msg_area | Yes | id of the element to render into |
intent_id | Yes | The payment intent ID |
onPaymentDetected | No | Called when a payment covering the full amount is seen, before it confirms. Receives { txid, value, expected, crypto, intentId }. Use it to move the customer on, not to fulfil. |
- Closing: the widget hides itself and dispatches a bubbling
closeevent on the container. Listen for it to close your modal. - Styling: set
--bk-bg,--bk-fg,--bk-muted,--bk-accent,--bk-accent-fg,--bk-border,--bk-danger,--bk-font,--bk-radius,--bk-gapor--bk-widthon theblockonomics-checkoutelement. - React / Next.js: load the script once (such as with
next/script) and callBlockonomics.checkout()in auseEffectkeyed on the intent ID.
Option 2: Use a Custom UX
Build your own screens when you need full control.
1. Crypto selection. Get payment status returns accepted_cryptos, due_amount and testmode. On selection, create a quote:
const API = 'https://www.blockonomics.co/api'
const { data: status } = await fetch(`${API}/v2/pay_stat/${intentId}`).then((r) => r.json())
async function getQuote(crypto) {
const res = await fetch(`${API}/v2/pay/${intentId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ crypto }),
})
return (await res.json()).data // { address, crypto_amount, expires_timestamp, ... }
}crypto_amount is a string in base units: satoshi for BTC ("12966" = 0.00012966 BTC), 6 decimals for USDT ("10013511" = 10.013511 USDT).
2. BTC screen. Show address, the BTC amount, a QR code of bitcoin:<address>?amount=<btc> and a countdown to expires_timestamp. Each BTC quote has its own address, so detection is automatic. For instant feedback, optionally open a WebSocket on the address.
3. USDT screen with wallet connection. Embed the Web3 USDT Component and submit the transaction hash it returns:
<script src="https://www.blockonomics.co/js/web3-payment.js"></script>
<web3-payment id="web3_payment"></web3-payment>const quote = await getQuote('USDT')
const web3 = document.getElementById('web3_payment')
web3.receive_address = quote.address
web3.order_amount = Number(quote.crypto_amount) / 1e6
web3.testmode = status.testmode
web3.onTxnSubmitted = ({ txhash }) =>
fetch(`${API}/v2/pay/${intentId}/submit`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ crypto: 'USDT', txhash }),
})A USDT payment whose hash is never submitted is not detected. All USDT quotes share the store's address, so the hash is what links a transfer to the intent.
4. Price refresh. On countdown expiry or a refresh click, call getQuote() with the same crypto. You get the same address with a new crypto_amount and expires_timestamp.
5. Check payment status. Poll Get payment status and loop while due_amount > 0.
Option 3: No UX / Agentic Payments
AI agents can pay an intent with the Payer API alone.
1. Return the payment intent ID at checkout.
2. Add payment instructions to your llms.txt. Adapt step 1 to your site:
## Paying for an order
1. Place the order: `POST https://yoursite.com/api/orders`. The response contains `payment_intent_id`.
2. Check what is due: `GET https://www.blockonomics.co/api/v2/pay_stat/{payment_intent_id}` → `due_amount`, `accepted_cryptos`.
3. Get a quote: `POST https://www.blockonomics.co/api/v2/pay/{payment_intent_id}` with `{"crypto": "BTC"}` or `{"crypto": "USDT"}`. Send exactly `crypto_amount` (satoshi for BTC, 6 decimals for USDT on Ethereum) to `address` before `expires_timestamp`. Call again to refresh the price.
4. USDT only: `POST https://www.blockonomics.co/api/v2/pay/{payment_intent_id}/submit` with `{"crypto": "USDT", "txhash": "0x..."}`. Unsubmitted USDT payments are never detected.
5. Poll step 2 every 10 seconds. While `due_amount` is above 0, pay the rest with a new quote.
Docs: https://developers.blockonomics.co/docs/payer-apiAnyone with the intent ID can pay it, so return it only to the payer.
Backend Implementation
Create a Payment Intent
curl -X POST https://www.blockonomics.co/api/v2/payment_intents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": "10.00", "currency": "USD", "extra_data": "order-1234"}'Returns the payment intent with its id (pi_…), status: "unpaid" and due_amount. Store the id with your order.
amountis a decimal string with 2 decimals.extra_datais your reference (up to 2048 characters), such as the order ID. The payer never sees it.match_callbackpicks the store if you have several: part of its callback URL, such as"example.com".
Handling Callbacks
Blockonomics sends a GET to your callback URL each time a payment moves an intent to processing, underpaid or paid:
GET https://example.com/blockonomics/callback?secret=YOUR_SECRET&id=pi_5GfD5m1b8khzFSLza91VR6&status=paid&due_amount=0.00&extra_data=b3JkZXItMTIzNA%3D%3D
extra_data is base64-encoded. Callbacks are not signed, so check the secret, then read the status from the API:
// Express.js example
app.get('/blockonomics/callback', async (req, res) => {
if (req.query.secret !== process.env.BLOCKONOMICS_CALLBACK_SECRET) {
return res.status(403).send('Forbidden')
}
const response = await fetch(
`https://www.blockonomics.co/api/v2/payment_intents/${encodeURIComponent(req.query.id)}`,
{ headers: { Authorization: `Bearer ${process.env.BLOCKONOMICS_API_KEY}` } }
)
const { data: intent } = await response.json()
if (intent.status === 'paid') {
await fulfilOrder(intent.extra_data, intent) // must be idempotent
}
res.send('OK')
})- Fulfil only on
status: "paid", never ondue_amountor a frontend event.due_amountdrops as soon as a payment is detected;statuschanges only on confirmation. The same status can arrive more than once. - Return
200HTTP status. If Blockonomics doesn't get a200, it retries the callback up to 7 times with exponential backoff.
Testing Notes
After implementation it is recommended to do E2E testing to verify the complete flow. Store can be put in test mode and toggled back after testing. Refer to Testing
Test these on a 10.00 USD intent:
- Correct amount:
processingcallback, thenpaid. The order is fulfilled once. - Underpaid BTC: pay half.
due_amountis about5.00, Pay remaining shows, and after confirmation you getunderpaid. - Underpaid BTC, completed with USDT: quote USDT for the remainder and pay its
crypto_amount. You getpaidonce both confirm. - Price refresh: let the countdown expire or click refresh. Same address, new amount and
expires_timestamp.