Send a Link, Get Paid: Building Payment Links with the Afriex API
What if you could accept payments globally with just a link?
No checkout flows. No heavy integrations. Just a URL.
What This Guide Covers
This guide is about the Afriex API.
You’ll learn how to build a simple payment link system that allows you to:
- Generate shareable payment links
- Accept payments via bank transfer or crypto
- Track payment status
- Handle real payment confirmations
You do not need any specific framework. Your backend just needs to make secure HTTPS requests.
Afriex vs Your Application
Afriex provides the payment infrastructure.
You build the product layer.
| Responsibility | Who |
|---|---|
| Virtual accounts, crypto wallets, settlement rails | Afriex |
| Payment link (URL), amount, expiry, status tracking | Your App |
| Confirming payments securely | Afriex Webhooks |
System Architecture
Client → Backend → Afriex API → Payment Rails
- Your backend stores payment requests
- Afriex handles payment execution
- Your frontend displays payment instructions
Prerequisites
Before starting, you need:
- An Afriex account
- Your API key
- A customerId (Afriex identifier for the recipient)
Every payment instruction you generate should be tied to a customerId.
Authentication
All Afriex API calls are made server-side.
GET {BASE_URL}/... HTTP/1.1
x-api-key: YOUR_AFRIEX_API_KEY
Content-Type: application/json
Example:
curl -sS -G "{BASE_URL}/api/v1/payment-method/virtual-account" \
-H "x-api-key: YOUR_AFRIEX_API_KEY" \
--data-urlencode "currency=NGN" \
--data-urlencode "amount=5000" \
--data-urlencode "customerId=PAYEE_CUSTOMER_ID"
Step 1: Create a Payment Link (Your Backend)
Afriex does not create “payment links” for you — you implement this.
Store:
- amount
- currency
- description
- expiry
- customerId
- unique token
import crypto from "crypto";
const linkId = crypto.randomBytes(16).toString("hex");
await db.payment.create({
linkId,
amount: 5000,
currency: "NGN",
customerId,
expiresAt: new Date(Date.now() + 30 * 60 * 1000),
});
Then generate:
https://yourapp.com/pay/{linkId}
Step 2: Generate Payment Instructions
When a user opens the link:
- Load the payment request
- Call Afriex
- Return instructions
🇳🇬 Virtual Account (Bank Transfer)
curl -sS -G "{BASE_URL}/api/v1/payment-method/virtual-account" \
-H "x-api-key: YOUR_AFRIEX_API_KEY" \
--data-urlencode "currency=NGN" \
--data-urlencode "amount=5000" \
--data-urlencode "customerId=PAYEE_CUSTOMER_ID"
Display:
- Account number
- Account name
- Bank name
Crypto Wallet (USDC / USDT)
curl -sS -G "{BASE_URL}/api/v1/payment-method/crypto-wallet" \
-H "x-api-key: YOUR_AFRIEX_API_KEY" \
--data-urlencode "asset=USDC" \
--data-urlencode "customerId=PAYEE_CUSTOMER_ID"
Response:
{
"data": [
{
"address": "0x...",
"network": "ethereum"
}
]
}
If USDC is unavailable, fallback to USDT.
Step 3: Choosing Payment Method
In your backend:
- If currency = NGN → virtual account
- If currency = USD → crypto wallet
This logic is controlled by your application, not Afriex.
Step 4: Confirm Payment (Production)
Do NOT rely on:
- Button clicks
- User confirmation
Use Afriex webhooks:
- Receive event
- Verify signature
- Match to payment record
- Mark as paid
Always handle this idempotently.
Security Checklist
- Keep API keys server-side only
- Use HTTPS
- Use unguessable link tokens
- Expire links
- Verify webhooks
Why This Pattern Matters
This is the same pattern used by:
- Stripe
- Paystack
- Flutterwave
Payment links are one of the fastest ways to start accepting payments globally.
Summary
To build payment links with Afriex:
- Create a customer → get
customerId - Store a payment request in your database
- Generate a shareable link
- Fetch payment instructions via Afriex
- Confirm payments via webhooks
Next Steps
- Add webhook automation
- Support more currencies
- Build dashboards
- Add notifications
Final Note
Afriex gives you the rails.
You build the product.
Top comments (0)