RADOK

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 merchantFee you 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.

POST/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

FieldTypeDescription
virtualAccountReferencerequiredstringThe reference returned when you minted the account. Must be a test-environment account belonging to you.
amountobject{ "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
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" }'
200 OK
{
  "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.

POST/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

FieldTypeDescription
referencerequiredstringThe crypto collection reference.
chainstringethereum, polygon, bsc, or tron. Defaults to polygon.
tokenstringUSDT or USDC. Defaults to USDC.
confirmNowbooleanWhen 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.

POST/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

FieldTypeDescription
purseIdrequiredstringThe purse id (purse_…) from the yard endpoints.
curl
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" }'
200 OK
{
  "data": {
    "simulated": true,
    "settlements": [
      {
        "reference": "pst_6f2c9a4e1b7d3058",
        "purseId": "purse_7a1d3e9c5b2f4068",
        "amount": { "value": 4000000, "currency": "NGN" },
        "status": "succeeded",
        "lineCount": 1
      }
    ]
  }
}
  • settlements is empty when the purse has nothing in flight. status is succeeded, sending, or failed.
  • Like test payouts, the outcome is keyed off the transfer total’s kobo remainder: a total ending in .01 fails (and is scheduled for retry, firing purse.settlement.failed), and one ending in .02 stays sending. 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 a purse.settlement.failed followed by a purse.settlement.succeeded for the same reference is the expected sequence.

An end-to-end test

Node.js
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

  1. Expose your local server with a tunnel. A localhost URL is rejected — private and loopback addresses are blocked, and the check is repeated at delivery time.
  2. Save the tunnel URL as your TEST webhook endpoint and generate a test signing secret.
  3. Press Send test event. Your endpoint gets a real signed request, and the dashboard shows you the status it returned.
  4. Then run the simulation above to exercise a real collection.success payload rather than the test stub.
  5. 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

Signing is identical in both environments, but the secret is not shared. A verifier hard-coded to one environment’s secret will reject every delivery in the other.

Going live

  1. Get KYB approved. Live keys cannot be created until it is.
  2. Create a live secret key and deploy it. Keep the test key working in staging.
  3. Configure the LIVE webhook endpoint and generate its own signing secret — none of this carries over from test.
  4. Add a live payout account and set it as the default.
  5. Re-check your fee assumptions. Test mode charged you nothing.
  6. Send one small real payment end to end before pointing customers at it.