Skip to content

Build and operate

Sandbox testing

The full sandbox: test numbers and magic amounts for every outcome, the fixed OTP, webhooks, the trigger and reset endpoints, bulk and invoice behaviour, and a test plan.

What the sandbox is

The sandbox at https://sandbox.moolre.com runs the same API code as live, with a sandbox switch. The endpoints, request fields, response envelopes and codes are the same, so a working sandbox integration is a working live integration with different credentials and a different base URL.

Everything in the sandbox is simulated. No real money moves, no mobile money provider is called, and no SMS is sent to a test number. Pending transactions settle by themselves: a worker runs every minute, and reading a status endpoint also settles anything that is due.

Sandbox responses carry an extra sandbox block that names the scenario the simulator chose and what happens next. It is not part of the live API: do not depend on it in code that must also run live.

Your first sandbox calls

Follow these in order. Each step tells you what to send and what you should get back.

  1. Create a sandbox wallet with Create Account (sandbox only). It returns an account number. Keep it: it goes in accountnumber on every call. If your wallet already exists in production, it is copied into the sandbox the first time you use its account number (name only: its callback URL and secret are not copied).
  2. Send your username in X-API-USER. Keys are optional in the sandbox, but if you send X-API-KEY it must be your private key: a wrong key returns AIN05. The server may also be set to require the key on every request, exactly as live does, so send it from day one. Public keys signed by the live API are not accepted by the sandbox.
  3. Set a callback URL on the sandbox wallet with Update Account (callback). Sandbox events go only to this URL, never to your live callback.
  4. Make a collection to a test number such as 0240000111 (see the table below). Without skipotp the first call returns TP14: for a test number no SMS is sent and the OTP is always 123456.
  5. Check the result with Payment Status, or wait for the payment.succeeded webhook. A pending scenario settles on its own after the delay in the table.
  6. Reset your test data whenever you want a clean slate (see Reset below).

curl https://sandbox.moolre.com/open/transact/payment \  -H "Content-Type: application/json" \  -H "X-API-USER: $MOOLRE_USER" \  -d '{    "type": 1,    "channel": "MTN",    "currency": "GHS",    "payer": "0240000111",    "amount": "10.00",    "externalref": "SBX-ORDER-1",    "accountnumber": "1000000000001"  }'

How an outcome is chosen

The simulator picks the outcome from the first rule that matches, strongest first:

  1. The status field of the request (sandbox only): pending, success, failed, timeout, wrong_pin, insufficient_funds, declined, expired, provider_error, not_registered, limit_exceeded, pending_success, pending_failed or random. The numbers 0 (pending), 1 (success) and 2 (failed) also work. It applies to collections and payouts only.
  2. The last three digits of the payer (collections) or the receiver (payouts, bulk items and name validation; for BANK the account number). Any number works, and the recommended test numbers are <prefix>0000<code>, for example 0240000111.
  3. The cents of the amount, when the number is not a scenario number (see Magic amounts).
  4. Otherwise the default: random, with 85 percent success, 7 percent pending and 8 percent failed (or always success when the server is configured that way).

Number formats

Phones may be written 0240000111, 233240000111 or +233240000111. Network prefixes: MTN 24 25 53 54 55 59, Telecel 20 50, AT 26 27 56 57. The bank test account is 0000000111 (seven zeros and the code).

Test numbers (last three digits)

Use these to rehearse every outcome your code must handle. A failure always returns txstatus 2 with a reason, and a pending result keeps txstatus 0 until it settles.

Last 3 digitsScenarioCollectionPayout or bulk itemName validation
111SuccessSucceeds at onceSucceeds, code OBGH01 Pay out SuccessfulFound, holder name SANDBOX TEST SUCCESS
222Pending 60 s, then successPending, succeeds after 60 sAPY16 in progress, succeeds after 60 sFound
333Insufficient fundsFails, reason LOW_BALANCE_OR_PAYEE_LIMIT_REACHED_OR_NOT_ALLOWEDFails, OM14 insufficient balanceFound
444Timeout, then successPending, succeeds after 30 sSingle payout: pending, then succeeds after 30 s. Bulk item: first send times out (BLK30), returns to queued, then succeedsFound
555Outcome unknownStays pending for ever (settle it with the trigger endpoint or reset)Stays pending: a single payout answers APY16, a bulk item reports pending with BLK30. A batch containing it never completes by itselfLookup times out, AVD03
666Provider errorFails, reason NETWORK_UNAVAILABLEFails, OM16 could not be started, not charged (bulk: after 3 attempts)Found
777DeclinedFails, reason TRANSACTION_DECLINEDFails, PY05Found
888Not registeredPlain failureFails, OM06 not an MTN MoMo subscriberNot found, AVD02
999Wrong PINFails, reason WRONG_PINPlain failure, PY05Found
998Payer declinedFails, reason PAYER_DECLINEDPlain failure, PY05Found
997Prompt expiredFails, reason PROMPT_EXPIREDPlain failure, PY05Found
996Limit exceededFails, reason LIMIT_EXCEEDEDFails, PY05Found
1NN (not 111)Pending, success after NN seconds (01 to 99)As statedAPY16, then successFound
2NN (not 222)Pending, failure after NN secondsAs stated, reason TRANSACTION_DECLINEDAPY16, then failureFound
404Name not found (validate only)Not applicableNot applicableNot found, AVD02
408Lookup timeout (validate only)Not applicableNot applicableAVD03

Magic amounts

When the number is not a scenario number, the cents of the amount choose the outcome. For example 10.91 or 250.95:

CentsSame asResult
.91777Failed (declined)
.92333Insufficient funds
.93999Wrong PIN (collections)
.94998Declined by the payer (collections)
.95130Pending, success after 30 s
.96230Pending, failure after 30 s
.97555Stays pending
.98666Provider error
.99888 for payouts, 777 for collectionsReceiver not registered (payout) or plain failure (collection)

The one-time code in the sandbox

Without skipotp, the first collection call answers TP14. For a test number (<prefix>0000<code>) no SMS is sent and the OTP is always 123456; the sandbox.otp field of the TP14 reply says so. A real phone number receives a real SMS.

The OTP limits apply in the sandbox exactly as live: 3 sends per phone per 10 minutes, 10 per phone per day, 30 per IP per hour, and 5 wrong codes invalidate the code. The refusal is OTP429 (HTTP 429 in strict mode).

  1. Send the collection. You get TP14.
  2. Send the same request with "otpcode": "123456". You get TP17 (Phone number verification successful).
  3. Send the original request once more, without otpcode. You get the payment prompt reply (TR099) and the scenario starts.

Skip the OTP while building

In the sandbox you can send "skipotp": true to go straight to the payment prompt. Remove it before you go live: it is rejected by the live API.

What happens to the sandbox wallet

  • Collections: success credits the sandbox wallet (the starter balance is GHS 1,000.00). Failure and pending credit nothing; a pending one credits when it settles.
  • Payouts are charge-first like live: the amount plus the sandbox fee (1 percent) is reserved when the payout is accepted. A failure never takes the money, and a pending payout that later fails is refunded. APY21 (Insufficient wallet balance) appears when the balance is too low.
  • Pending transactions settle by themselves: a one-minute worker, and whenever you read Payment Status, Account Status (type 2), the account list or a bulk read.
  • Status returns txstatus 0 pending, 1 successful, 2 failed, plus reason on failures and created_at (ISO 8601 UTC).

Callbacks and webhooks in the sandbox

Callbacks go to the callback URL of the sandbox wallet and webhooks to its webhook_url, never to your live URLs, and both are signed with the sandbox wallet secret. Headers and bodies are the same as live. Verify the signature exactly as in the guides. A sandbox transaction webhook carries one hook (live can list up to 100); use bulk_payout.completed to test a list. Payouts and settlements have no callback.

Set the callback with Update Account (callback), and switch webhooks on with webhook 1 and webhook_url. A wallet copied from your live wallet starts without either. Local development needs a public HTTPS URL (a tunnel): callback URLs that point to private or loopback addresses are refused.

Failed deliveries are retried at 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 24 hours, 48 hours and 72 hours. Webhook deliveries, Resend webhook and Send test webhook work in the sandbox with the same contract as live.

EventCallbackWebhook
payment.succeededP01P01
payment.failedP02, data.reason says whyP02
payout.succeeded, payout.failed, payout.reversedNoneP11, P12, P13
settlement.succeeded, settlement.failed, settlement.reversedNoneP21, P22, P23 (fire them with the trigger endpoint)
bulk_payout.completedBatch summary, sent onceBLK40, with every payout
webhook.testWHT00, when the wallet has no webhook_urlWHT00

Trigger any event on demand

POST /open/sandbox/trigger (private key, sandbox only) sends any event to your sandbox wallet, as a webhook when webhooks are on and as a callback for the events that have one, so you can test every branch of your handler without waiting. With an id it acts on a real sandbox record: a pending payment settles that way and the balance, status and event all agree. Without an id it sends a sample event and does not touch the balance.

eventWith an idWithout an id
payment.succeeded, payment.failedexternalref or transactionid of a pending payment settles it that way. A finished payment re-sends the same outcome with a new event_id (SBX05 if you ask for the opposite)A sample event (amount optional). The balance is not touched
payout.succeeded, payout.failedSame, for a payout (a failure refunds the reserved amount)Sample
payout.reversedReverses a successful payout: the money goes back to the walletSample
settlement.succeeded, settlement.failed, settlement.reversedNot applicableSample
bulk_payout.completedbatchid finishes the batch: pending items settle as final "succeeded" (default) or "failed". The completion event is sent onceSample
webhook.testNot applicableA signed test event, one attempt
invoice.paid (an action: nothing is sent)invoiceid pays the invoice (amount pays part, then the invoice reads partially_paid)Not applicable

curl https://sandbox.moolre.com/open/sandbox/trigger \  -H "Content-Type: application/json" \  -H "X-API-USER: $MOOLRE_USER" \  -H "X-API-KEY: $MOOLRE_KEY" \  -d '{    "accountnumber": "1000000000001",    "event": "payment.succeeded",    "externalref": "SBX-ORDER-1"  }'

Trigger errors

SBX02 webhooks are off, and no callback URL for an event that has one (422), SBX03 bad event or parameter (400), SBX04 batch or invoice not found (404), SBX05 contradictory request (409), SBX06 cannot be settled (409), SBX10 wallet not found (404), SBX13 a public key was used (403).

Reset your test data

POST /open/sandbox/reset (private key, sandbox only) clears test data for one wallet that is yours. scope is all (default), transactions (also clears OTP and idempotency rows and restores the balance), balance, webhooks, bulk or invoices. After a reset an externalref can be used again.

curl https://sandbox.moolre.com/open/sandbox/reset \  -H "Content-Type: application/json" \  -H "X-API-USER: $MOOLRE_USER" \  -H "X-API-KEY: $MOOLRE_KEY" \  -d '{    "accountnumber": "1000000000001",    "scope": "all",    "balance": "1000.00"  }'

Reset errors

SBR03 bad scope, SBR04 bad balance, SBR10 wallet not found, SBR13 a public key was used.

The catalogue as JSON

POST /open/sandbox/scenarios is public and read-only. It returns the same catalogue as this page as JSON, so a test suite can read the scenarios instead of hard-coding them.

Bulk payouts in the sandbox

Bulk payouts have the same contract, codes and limits as live (BLK01 queued, BLK02 replay, BLK09 batchref conflict, BLKR01 to BLKR13 row codes, 500 items, 20 active batches, atomic). A simulated worker moves each item from queued to submitted (about 3 seconds) and then to the outcome the receiver's last three digits choose (payout column above), and, when every item is final, sends bulk_payout.completed. With webhooks on, each payout also sends payout.succeeded or payout.failed.

Reading Bulk payout status or List bulk payouts advances the batch, so polling is enough. Items that match no scenario succeed. A batch that contains a 555 receiver stays processing until you trigger bulk_payout.completed with its batchid.

Invoices in the sandbox

Invoices have the same fields, validation and codes as live (INV01 created, INV02 replay, INV07 reference conflict, INV12 not found, INV17 cancelled, INV18 has payments). The invoice id is {wallet id}-{n}, payment_link is https://sandbox-invoice.moolre.com/{service_id}-{id} and payment_code is *203*062{n}#. The wallet is the single service, so service_id is optional and must equal the wallet id when sent.

Pay an invoice with the trigger endpoint: event invoice.paid with invoiceid, and an optional amount for a part payment. Nothing is sent. A past due date while unpaid reads overdue.

Other sandbox behaviour

  • Validate Name is simulated and never asks a provider: it uses the last column of the test number table. Unknown numbers are found with a stable fake holder name, so the same number always gets the same name.
  • Channel names MTN, TELECEL, AT, BANK and GHQR work everywhere. Numeric ids still work and add a DEPRECATED_NUMERIC_CHANNEL notice.
  • Idempotency-Key works on payment, transfer, bulk and invoice create: the same key and body replays the answer with meta.replayed true; another body is IDEM01.
  • sendername on transfers is validated: 2 to 30 characters, letters, spaces, full stop, apostrophe and hyphen, starting with a letter, otherwise APY22 (the sandbox is a little more lenient: it also accepts digits and up to 40 characters, but write for the live rule)
  • Account Status (type 2) and the account list return sandbox transactions with from, to, starting_after, limit and status, and rows carry created_at. Payment Status types 2 and 3 cover payment IDs.
  • Send X-Moolre-Http-Status: strict to get real HTTP status codes (400, 401, 403, 404, 409, 422, 429, 5xx) instead of always 200.
  • Wallets belong to their account: another account's wallet number is reported as not found.

A sandbox test plan for your integration

Run each of these before you go live. They cover the outcomes that cause most production incidents.

  • Collection succeeds (…111) and you fulfil the order exactly once, even if the webhook arrives twice.
  • Collection fails with wrong PIN (…999) and insufficient funds (…333): you show the reason and let the customer retry with a new externalref.
  • Collection pending 60 s (…222): your order stays pending, then completes from the webhook.
  • Collection stays pending (…555): your reconciliation job finds it with Payment Status and does not release goods.
  • Wrong OTP five times: you handle OTP429 and tell the customer to wait.
  • Payout succeeds (…111), fails (…333, …666, …777, …888) and is pending (…222, …555): a pending payout is never resent.
  • A timeout is simulated by dropping your own connection: the retry with the same Idempotency-Key replays the answer.
  • Callback and webhook endpoints: wrong signature is rejected, an old timestamp is rejected, a repeated event_id is ignored, and Send test webhook returns delivered true.
  • Bulk batch with a bad row: the rejected rows are reported and the rest complete.
  • Invoice: create, pay with the trigger endpoint, see it paid with Invoice status; cancel an unpaid one.