Stablecoins are becoming core infrastructure for global payments.
But building with them usually means:
- managing private keys
- running indexers
- tracking on-chain activity
That’s a lot of overhead.
In this guide, you’ll learn how to accept USDC / USDT without running your own custody infrastructure, using the Afriex API.
What You’ll Build
- A backend endpoint that returns deposit instructions (address + network)
- A webhook system to confirm payments reliably
- A production-ready flow using idempotency and retries-safe logic
The Mental Model
Stop thinking:
“I need to manage wallets”
Start thinking:
“I’m building on payment rails”
With Afriex:
- You don’t generate private keys
- You don’t run blockchain infrastructure
-
You rely on Afriex for:
- deposit attribution
- transaction state
- settlement
Your job is to:
- create a payment / invoice object
- show deposit instructions
- confirm payments via webhooks
Step 0 — Setup API Access
Base URLs
- Sandbox:
https://sandbox.api.afriex.com - Production:
https://api.afriex.com
Environment Variables
AFRIEX_API_BASE_URL="https://api.afriex.com"
AFRIEX_API_KEY="your-api-key"
AFRIEX_WEBHOOK_PUBLIC_KEY="your-public-key"
Example Request
curl -sS -G "https://api.afriex.com/api/v1/org/balance" \
-H "x-api-key: YOUR_AFRIEX_API_KEY"
Step 1 — Create Your Payment Object
Afriex does not create payment links for you.
You define your own invoice / payment intent:
{
id: "internal_id",
reference: "unique_reference",
asset: "USDC",
amount: 100,
status: "pending",
expiresAt: Date
}
Tip: Make reference globally unique and reuse it across retries.
Step 2 — Get Deposit Address
Endpoint
GET /api/v1/payment-method/crypto-wallet
Example
curl -sS -G "https://api.afriex.com/api/v1/payment-method/crypto-wallet" \
-H "x-api-key: YOUR_API_KEY" \
--data-urlencode "asset=USDC"
Response
{
"data": [
{ "address": "0x...", "network": "ETHEREUM_MAINNET" },
{ "address": "TY...", "network": "TRON_MAINNET" }
]
}
Backend Example
const wallet = await fetch(url).then(res => res.json())
const preferred =
wallet.data.find(w => w.network === "ETHEREUM_MAINNET") ??
wallet.data[0]
return {
address: preferred.address,
network: preferred.network,
asset: "USDC"
}
Important Note
This endpoint is:
Production only
It does not work in sandbox.
Step 3 — Display Payment Instructions
Your UI should show:
- Asset (USDC / USDT)
- Network
- Address (copy + QR)
Also include:
Sending on the wrong network may result in lost funds
Step 4 — Confirm Payments (Webhooks)
This is the most important part.
Do NOT:
- rely on user confirmation
- rely on block explorers
Use Afriex webhooks.
Webhook Setup
- Configure your webhook URL in the dashboard
- Copy your webhook public key
- Allowlist Afriex IPs
Signature Verification
import crypto from "crypto"
function verifySignature(signature, rawBody, publicKey) {
const verifier = crypto.createVerify("RSA-SHA256")
verifier.update(rawBody)
return verifier.verify(publicKey, signature, "base64")
}
Important: verify the raw request body, not parsed JSON.
Events
TRANSACTION.CREATEDTRANSACTION.UPDATED
Logic
if (event === "TRANSACTION.UPDATED" && status === "SUCCESS") {
markInvoiceAsPaid()
}
Ensure this operation is idempotent.
Step 5 — Idempotency
Outbound
Use:
{
"meta": {
"reference": "invoice_123",
"idempotencyKey": "idem_invoice_123"
}
}
Inbound
Webhooks may retry.
Ensure:
- no duplicate credits
- safe re-processing
Use database constraints or “update-if-not-paid” logic.
Step 6 — Reconciliation
Use Afriex APIs for support and debugging:
- Get transaction
- List transactions
- Get balance
⚠️ Common Pitfalls
1. Crypto Wallet Not Working in Dev
→ It’s production only
2. Wrong Network Deposits
→ Only present one supported network
3. Webhook Verification Fails
→ Use raw body + correct public key
4. Duplicate Credits
→ Fix with idempotency
Why This Matters
Stablecoins are becoming:
Core rails for global payments
The real opportunity isn’t just using them.
It’s building systems on top of them.
Summary
With Afriex, you can:
- Accept USDC / USDT
- Avoid custody complexity
- Use webhooks for reliable confirmation
- Build production-ready payment systems
Final Thought
Afriex gives you the rails.
You build the product.












