Account top-ups
Let customers fund their account balance with stablecoins through WalletConnect Pay, and credit each top-up automatically.
This guide shows you how to build account top-ups on WalletConnect Pay. Your customers add funds to a balance on your platform, such as a neobank account, a card, a brokerage or a gaming wallet, by paying with stablecoins:
- Consumers paying from a self-custody wallet or an exchange account.
- Businesses funding a treasury or operating balance.
- Institutions sending from a custody platform behind approval rules.
Every top-up is a WalletConnect Pay payment for an exact amount. The customer pays on the WalletConnect Pay payment page, usually by connecting one of 700+ supported wallets, and the funds settle to your address. You credit the customer's balance when the payment succeeds.
For customers who can't connect a wallet, such as those paying from an exchange or a custody platform, use Direct Deposits. The same payment also has a one-time deposit address, so the customer can send the exact amount from anywhere without connecting anything.
How a top-up works
Choose a flow for each customer
The payment flow is the same for every customer. The only choices are which link you send and how long the top-up stays open.
| Customer | Where the funds are | Link to send | Expiry |
|---|---|---|---|
| Consumer, self-custody | A self-custody wallet | gatewayUrl: the customer connects a wallet and pays | Default (15 minutes) |
| Consumer, exchange | An exchange account | Deposit page (Direct Deposits) | Default, or longer for exchanges with withdrawal checks |
| Business | A company wallet or exchange account | gatewayUrl, or the deposit page if the funds are on an exchange | Long enough for internal sign-off |
| Institution | A custody platform | Deposit page (Direct Deposits) | Long enough for the custody approval policy |
Custody platforms and exchanges send to an address but can't scan a QR code or connect a wallet. To reach them, use Direct Deposits and give institutions' operations teams time to approve the transfer.
Prerequisites
- A WalletConnect Pay account with an API key. Start with a test key (
wcp_test_…); see Test mode. - A backend server. Every API call in this guide is server-side so your API key stays secret.
- An HTTPS endpoint for webhooks.
Build the top-up flow
Set up a merchant and settlement
Do this once. Create a merchant that represents your platform, then register the token and address you want top-ups to settle to, for example USDC on Base. Follow steps 1 to 4 of the Merchant API quickstart.
export WCP_API_KEY="wcp_test_…"
export WCP_MERCHANT_ID="mrch_…"Record the top-up
When a customer asks to top up, save the request in your database before you call the API. Its ID becomes the payment's referenceId, so every webhook points straight back to the customer to credit.
const topUp = await db.topUps.insert({
id: crypto.randomUUID(),
customerId: customer.id,
amountCents: 5000, // $50.00
status: 'pending',
});Create the payment
Create one payment per top-up. amount.value is in minor units, so "5000" is $50.00. Set expiresAt (Unix seconds) when the sender needs more than the default 15 minutes, for example a business or a custody platform with approvals.
const ONE_HOUR = 60 * 60;
const response = await fetch('https://api.pay.walletconnect.com/v1/payments', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Api-Key': process.env.WCP_API_KEY,
'Merchant-Id': process.env.WCP_MERCHANT_ID,
},
body: JSON.stringify({
referenceId: topUp.id,
amount: { unit: 'iso4217/USD', value: String(topUp.amountCents) },
// Omit for consumers paying from a wallet; the default is 15 minutes.
expiresAt: Math.floor(Date.now() / 1000) + ONE_HOUR,
}),
});
const { paymentId, gatewayUrl, expiresAt } = await response.json();
await db.topUps.update(topUp.id, { paymentId, expiresAt });See Create a payment for every field.
Send the customer to the payment page
Send the customer to gatewayUrl, the WalletConnect Pay payment page. It shows the exact amount and a timer, and lets the customer connect a wallet to pay.
- In your app or website: redirect or open the link when the customer confirms the top-up.
- Businesses: send the link by email or show it in your dashboard, so whoever approves the transfer sees the amount in one place.
Option: send exchange and custody customers to the deposit page
Customers paying from an exchange or a custody platform can't connect a wallet. With Direct Deposits, the payment page also offers a one-time deposit address. To skip wallet connection entirely, build the deposit page URL from the paymentId. It shows the deposit address, the exact amount and a timer.
const depositUrl = `https://pay.walletconnect.com/deposit/?pid=${paymentId}`;Send this link to institutions and to customers who told you their funds are on an exchange.
Each deposit address belongs to one top-up. Tell customers not to save it or send to it again, and create a new top-up every time. Some exchanges subtract their withdrawal fee from the amount sent, so remind customers to make sure the exact amount arrives.
Credit the balance
Subscribe your endpoint to payment events in the dashboard. Credit the customer when data.status first becomes succeeded, whatever the event type: a payment.settled can arrive before the payment.succeeded it supersedes.
export async function handlePaymentEvent(event: PaymentEvent) {
// Verify the signature first; see /payments/webhooks.
if (await db.processedEvents.has(event.id)) return; // at-least-once delivery
const payment = event.data;
const topUp = await db.topUps.findById(payment.reference_id);
if (!topUp) return;
// Drop stale events. A top-up with no version yet has lastVersion === null.
if (topUp.lastVersion !== null && payment.payment_state_version <= topUp.lastVersion) return;
await db.transaction(async (tx) => {
await tx.topUps.update(topUp.id, { lastVersion: payment.payment_state_version });
if (payment.status === 'processing') {
await tx.topUps.update(topUp.id, { status: 'confirming' });
}
// payment.live is false for test payments: credit a sandbox balance there, never a real one.
if (payment.status === 'succeeded' && payment.live && topUp.status !== 'credited') {
await tx.balances.credit(topUp.customerId, topUp.amountCents);
await tx.topUps.update(topUp.id, {
status: 'credited',
txId: payment.success.tx_id,
sender: payment.processing.buyer_caip10,
});
}
if (['failed', 'expired', 'cancelled'].includes(payment.status)) {
await tx.topUps.update(topUp.id, { status: payment.status });
}
});
await db.processedEvents.add(event.id);
}processingmeans the transfer is on-chain but not final. Show it as "Confirming" so the customer knows it arrived, but don't credit yet.succeededmeans the payment for the top-up is complete. Credit once.expiredmeans nothing arrived before the timer ended. Offer the customer a new top-up.
As a fallback for missed webhooks, poll GET /v1/payments/{id}/status for top-ups that are still pending, and stop when isFinal is true. Read Webhooks for signature verification, retries and the version guard.
Test, then go live
Run the whole flow with your test key. Test payments go through created, processing and succeeded without moving funds, and their txId is test:{paymentId}. When the flow works, switch to a live key (wcp_…) and create your merchant and settlement again in live mode.
Reconcile top-ups
Every top-up appears in the Merchant Dashboard as a payment, labeled with the route it took: a wallet connection or a deposit address. For every top-up you get:
- The sender address (
buyer_caip10in webhooks) - The transaction hash (
tx_id) - The amount sent and the amount settled after fees
Top-ups paid through Direct Deposits also include the sender's sanctions screening result (OFAC, EU, UK and UN lists).
Because your top-up ID is the referenceId, you can match each payment to a customer and a balance change without comparing amounts or timestamps.
FAQ
No. Most customers connect a wallet on the payment page, but those paying from an exchange or a custody platform can send the exact amount to a one-time deposit address with Direct Deposits.
No. Each address belongs to one payment. Create a new top-up, and a new payment, every time.
No. Funds settle straight to the address you registered for your merchant.
When the payment status is succeeded. Don't credit on processing: the transfer is on-chain but not final yet.