Testing
Simulate an inbound payment without moving real money.
Contents
What test mode gives you
A test key exercises the same routes, the same validation, the same ledger, and the same webhook signing as a live key. The only difference is the gateway behind it: test always routes through a stub that never contacts a bank, never moves money, and never charges a fee.
- Virtual accounts are minted with plausible-looking numbers that nobody can pay into.
- Payouts are accepted and settled without a transfer ever leaving.
- Name enquiry resolves through the stub, so it costs nothing and is always available.
- Ordinary collections, payouts, and KYC checks are fee-free. A yard split is the exception: test quotes the real collection fee and transfer fees, and the
merchantFeeyou pass is credited the same way it will be in live.
Simulating an inbound payment
Nobody is going to transfer into a test virtual account, so a collection would sit in awaiting_payment forever. This endpoint drives the same settlement path a real gateway webhook would: the ledger is posted, the collection is marked succeeded, the account is closed, and a real collection.success webhook is delivered to your endpoint.
/v1/sandbox/simulate/collection-success- Auth
- Secret key or dashboard session
Test keys only: a live key is rejected with 403 SANDBOX_TEST_KEY_REQUIRED before the handler runs. A dashboard session needs the collections:write:sandbox permission and ?environment=test. A live virtual account returns 400 SANDBOX_TEST_ONLY.
Body
| Field | Type | Description |
|---|---|---|
| virtualAccountReferencerequired | string | The reference returned when you minted the account. Must be a test-environment account belonging to you. |
| amount | object | { "value": integer, "currency": "NGN" }. What the simulated customer sent. Defaults to the amount the account expects. Override it to test an overpayment or underpayment. |
curl -X POST https://api.radokpay.com/v1/sandbox/simulate/collection-success \
-H "Authorization: Bearer $RADOK_TEST_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "virtualAccountReference": "va_9f4c1b8e2d7a6c05" }'{
"data": { "simulated": true }
}The simulated payment is for the exact amount the account expects. Calling it twice for the same account returns 409 SANDBOX_SIMULATION_FAILED — the collection has already settled, and settlement is idempotent by design.
A crypto checkout has no broadcast in test mode. Post the collection reference to settle it on the same path a confirmed USDC transfer would, including the USD ledger credit and collection.success.
/v1/sandbox/simulate/crypto-payment- Auth
- Secret key or dashboard session
Test keys only. A dashboard session needs the collections:write:sandbox permission and ?environment=test.
Body
| Field | Type | Description |
|---|---|---|
| referencerequired | string | The crypto collection reference. |
| chain | string | ethereum, polygon, bsc, or tron. Defaults to polygon. |
| token | string | USDT or USDC. Defaults to USDC. |
| confirmNow | boolean | When false, the collection stays confirming and nothing is credited yet. |
Testing yards and split settlement
A split (yard) account is funded with the same collection-success simulation. Paying the exact total puts every share in flight and sends collection.success with the split. Pass a different amount to exercise the other paths: more than the total funds the split and holds the excess, less than the total holds all of it — both fire yard.unallocated.
In-flight money would otherwise wait for its real settlement date. This endpoint sends a purse’s waiting transfers now, whatever their due date, through the real settlement path — the same batching into one transfer per purse account, the same ledger postings, and real purse.settlement.succeeded or purse.settlement.failed webhooks.
/v1/sandbox/simulate/purse-settlement- Auth
- Secret key or dashboard session
Test keys only: a live key is rejected with 403 SANDBOX_TEST_KEY_REQUIRED. A dashboard session needs the collections:write:sandbox permission and ?environment=test. A live purse returns 400 SANDBOX_TEST_ONLY, and an unknown one 404 PURSE_NOT_FOUND.
Body
| Field | Type | Description |
|---|---|---|
| purseIdrequired | string | The purse id (purse_…) from the yard endpoints. |
curl -X POST https://api.radokpay.com/v1/sandbox/simulate/purse-settlement \
-H "Authorization: Bearer $RADOK_TEST_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{ "purseId": "purse_7a1d3e9c5b2f4068" }'{
"data": {
"simulated": true,
"settlements": [
{
"reference": "pst_6f2c9a4e1b7d3058",
"purseId": "purse_7a1d3e9c5b2f4068",
"amount": { "value": 4000000, "currency": "NGN" },
"status": "succeeded",
"lineCount": 1
}
]
}
}settlementsis empty when the purse has nothing in flight.statusissucceeded,sending, orfailed.- Like test payouts, the outcome is keyed off the transfer total’s kobo remainder: a total ending in
.01fails (and is scheduled for retry, firingpurse.settlement.failed), and one ending in.02stayssending. Every other total succeeds. Test mode charges no fee, so the transfer total is the sum of the gross amounts you split. - Calling it again for the same purse retries a failed transfer immediately rather than waiting for its next attempt time.
- Test-mode shares also settle on their own on the due date, exactly as live ones do.
- A retry keeps the settlement’s
pst_reference, so apurse.settlement.failedfollowed by apurse.settlement.succeededfor the same reference is the expected sequence.
An end-to-end test
const BASE = "https://api.radokpay.com/v1";
const headers = {
Authorization: `Bearer ${process.env.RADOK_TEST_SECRET_KEY}`,
"Content-Type": "application/json",
};
// 1. Mint an account for ₦5,000.00
const mint = await fetch(`${BASE}/virtual-accounts`, {
method: "POST",
headers,
body: JSON.stringify({
customerEmail: "ada@example.com",
amount: { value: 500_000, currency: "NGN" },
expiresInMinutes: 60,
}),
});
const { data: account } = await mint.json();
// 2. Stand in for the customer's bank transfer.
await fetch(`${BASE}/sandbox/simulate/collection-success`, {
method: "POST",
headers,
body: JSON.stringify({ virtualAccountReference: account.reference }),
});
// 3. The collection has settled and your webhook has already been delivered.
const check = await fetch(
`${BASE}/collections/${account.collection.reference}`,
{ headers },
);
const { data: collection } = await check.json();
console.assert(collection.status === "succeeded");Testing your webhook handler
- Expose your local server with a tunnel. A
localhostURL is rejected — private and loopback addresses are blocked, and the check is repeated at delivery time. - Save the tunnel URL as your TEST webhook endpoint and generate a test signing secret.
- Press Send test event. Your endpoint gets a real signed request, and the dashboard shows you the status it returned.
- Then run the simulation above to exercise a real
collection.successpayload rather than the test stub. - When something fails, open the delivery to see the exact bytes we sent and the body you returned. Use Replay to retry after a fix — see Inspecting and replaying deliveries.
Test secrets differ from live secrets
Going live
- Get KYB approved. Live keys cannot be created until it is.
- Create a live secret key and deploy it. Keep the test key working in staging.
- Configure the LIVE webhook endpoint and generate its own signing secret — none of this carries over from test.
- Add a live payout account and set it as the default.
- Re-check your fee assumptions. Test mode charged you nothing.
- Send one small real payment end to end before pointing customers at it.