Skip to content

Testing ​

A test payment is paid with one of four test numbers. No prompt goes to a phone, no money moves and nothing is booked, but the payment goes through the same states, and sends the same webhooks, as a real one.

Only two things make a test payment: a hosted checkout opened by a Pay Button test key, and a direct charge made with an mkp_test_ secret key. Everything else on staging is real.

Test keys ​

KeyWhere it comes fromWhat it makes
pk_test_…Pay Button, Test mode, in the hubTest checkouts, paid only by the test numbers
pk_live_…Pay Button, Live modeReal checkouts
mkp_test_…Any secret key issued by stagingTest direct charges (mobile_money only). Real hosted checkouts
mkp_live_…Any secret key issued by productionReal checkouts and real charges

There is no switch that turns a secret key into a test key. Staging issues only mkp_test_ keys and production only mkp_live_ keys. See Environments.

To get a Pay Button test key: open the hub, then API Integrations, then Pay Button. Set the switch to Test, make a key and enter your PIN. The hub lists the test numbers under the snippet.

The test numbers ​

Type the number in the country's own format. On the API, that is 254 or 256 in place of the leading 0: 254700000000 in Kenya, 256700000000 in Uganda. A direct charge also takes a leading +.

NumberWhat it simulatesAnswers after
0700 000 000The payer approves the prompt3 seconds
0700 000 001Declined for insufficient funds3 seconds
0700 000 002The prompt is never answered and times out60 seconds
0700 000 003The payer cancels the prompt3 seconds

Each number gives the same result every time. The waits are MOOKHPay's defaults; a deployment can set others.

What each number does to a test checkout ​

NumberPayment attempt endsCheckoutWebhook
0700 000 000completedcompletedpayment.succeeded
0700 000 001failedStays open, so the payer can try again until it expirespayment.failed
0700 000 002failedStays openpayment.failed
0700 000 003failedStays openpayment.failed

The attempt's state is payment.status on GET /checkouts/:id.

What each number does to a test charge ​

NumberCharge endsfailure.codeWebhook
0700 000 000succeedednullpayment.succeeded, with charge
0700 000 001failedinsufficient_fundspayment.failed, with charge and failure
0700 000 002failedprompt_timed_outpayment.failed
0700 000 003failedpayer_cancelledpayment.failed

A charge moves when you read it and when MOOKHPay's sweep runs (once a minute by default), so a poll every two seconds sees the result within moments of the times above. The other failure codes (wrong_pin, phone_unreachable, limit_exceeded, rail_unavailable, declined) cannot be produced on a test key. See Direct charges for what each means.

What a test payment does and does not do ​

A test payment
Sends a promptNo. No phone is needed
Moves money or changes a balanceNo
Is booked in the ledgerNo. It never appears in balances or transactions
Goes through the same states as a real oneYes
Sends webhooksYes, to your real endpoints, with "test": true in the body
Has a receiptYes: TEST followed by six characters
Can be paid by card, Pay Bill or a MOOKHPay balanceNo. Mobile money with a test number only

A test number on a real payment is refused with 422 and code 2838. Any other number on a test checkout or test charge is refused with 409 and code 2836.

What cannot be tested with a test key ​

You want to testWhat happens with a test keyHow to test it
A card charge and the card elementRefused: 400 and code 3004. MOOKHPay never offers card on a test charge, and there is no card sandbox behind a test keyOnly in production, with an mkp_live_ key, a real card and a small amount. Set your card element origins for live first
A Pay Bill chargeRefused: 400 and code 3004. Pay Bill is not offered in test modeIn production with a small amount
A hosted checkout from a secret keyIt is real, on staging too. Secret-key checkouts are never test checkoutsOn staging with a small amount and your own phone. Or use a pk_test_ checkout to rehearse the page
Seller accounts, balances, payouts, login linksReal on staging. A created account is a real MOOKHPay account; a payout sends real moneyOn staging with your own phone as the seller and a small amount
wrong_pin, phone_unreachable and other rail failuresNot produced by any test numberHandle them from the failure code table
Paying from a MOOKHPay balanceNot offered on a test checkoutOn staging with a real checkout and your own MOOKHPay account

Test your webhooks ​

There are three ways, and a full integration uses all three.

  1. Send a sample event from the hub. In API Integrations, Webhooks, choose Send Test on an endpoint and pick an event type. MOOKHPay sends one signed POST with a sample payload in that event's shape, with "test": true and ids like cs_test_…, ch_test_… and acct_test_…. It is sent once and not retried, and it appears in the endpoint's deliveries. You can send 20 an hour. Use it to check your signature verification and routing.
  2. Make a test charge. A test charge with a test number sends real deliveries of payment.succeeded or payment.failed (and charge.expired or charge.cancelled if you let it expire or cancel it), signed, retried and recorded like any other, with "test": true.
  3. Receive on your laptop. Endpoints must be public https addresses; MOOKHPay refuses localhost, private ranges and internal names. Run a tunnel (for example cloudflared tunnel --url http://localhost:3000 or ngrok http 3000) and register the https address it gives you as an endpoint.

Ignore or route events with "test": true so a test never fulfils a real order. See Set up webhooks and Verify signatures.

Errors ​

HTTPCodeNameWhenWhat to do
4092836CHECKOUT_TEST_MODEA number other than a test number on a test checkout or test charge, or a card or balance payment on a test checkoutUse a test number
4222838TEST_NUMBER_LIVEA test number on a real checkout or chargeUse a real number
4003004CHARGE_METHOD_UNAVAILABLEcard or paybill on a test chargeTest those in production

Staging documentation. A checkout made with a secret key on staging charges a real phone. See Environments.