Appearance
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
| Key | Where it comes from | What it makes |
|---|---|---|
pk_test_… | Pay Button, Test mode, in the hub | Test checkouts, paid only by the test numbers |
pk_live_… | Pay Button, Live mode | Real checkouts |
mkp_test_… | Any secret key issued by staging | Test direct charges (mobile_money only). Real hosted checkouts |
mkp_live_… | Any secret key issued by production | Real 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 +.
| Number | What it simulates | Answers after |
|---|---|---|
0700 000 000 | The payer approves the prompt | 3 seconds |
0700 000 001 | Declined for insufficient funds | 3 seconds |
0700 000 002 | The prompt is never answered and times out | 60 seconds |
0700 000 003 | The payer cancels the prompt | 3 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
| Number | Payment attempt ends | Checkout | Webhook |
|---|---|---|---|
0700 000 000 | completed | completed | payment.succeeded |
0700 000 001 | failed | Stays open, so the payer can try again until it expires | payment.failed |
0700 000 002 | failed | Stays open | payment.failed |
0700 000 003 | failed | Stays open | payment.failed |
The attempt's state is payment.status on GET /checkouts/:id.
What each number does to a test charge
| Number | Charge ends | failure.code | Webhook |
|---|---|---|---|
0700 000 000 | succeeded | null | payment.succeeded, with charge |
0700 000 001 | failed | insufficient_funds | payment.failed, with charge and failure |
0700 000 002 | failed | prompt_timed_out | payment.failed |
0700 000 003 | failed | payer_cancelled | payment.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 prompt | No. No phone is needed |
| Moves money or changes a balance | No |
| Is booked in the ledger | No. It never appears in balances or transactions |
| Goes through the same states as a real one | Yes |
| Sends webhooks | Yes, to your real endpoints, with "test": true in the body |
| Has a receipt | Yes: TEST followed by six characters |
| Can be paid by card, Pay Bill or a MOOKHPay balance | No. 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 test | What happens with a test key | How to test it |
|---|---|---|
| A card charge and the card element | Refused: 400 and code 3004. MOOKHPay never offers card on a test charge, and there is no card sandbox behind a test key | Only 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 charge | Refused: 400 and code 3004. Pay Bill is not offered in test mode | In production with a small amount |
| A hosted checkout from a secret key | It is real, on staging too. Secret-key checkouts are never test checkouts | On staging with a small amount and your own phone. Or use a pk_test_ checkout to rehearse the page |
| Seller accounts, balances, payouts, login links | Real on staging. A created account is a real MOOKHPay account; a payout sends real money | On staging with your own phone as the seller and a small amount |
wrong_pin, phone_unreachable and other rail failures | Not produced by any test number | Handle them from the failure code table |
| Paying from a MOOKHPay balance | Not offered on a test checkout | On staging with a real checkout and your own MOOKHPay account |
Test your webhooks
There are three ways, and a full integration uses all three.
- 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": trueand ids likecs_test_…,ch_test_…andacct_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. - Make a test charge. A test charge with a test number sends real deliveries of
payment.succeededorpayment.failed(andcharge.expiredorcharge.cancelledif you let it expire or cancel it), signed, retried and recorded like any other, with"test": true. - Receive on your laptop. Endpoints must be public
httpsaddresses; MOOKHPay refuseslocalhost, private ranges and internal names. Run a tunnel (for examplecloudflared tunnel --url http://localhost:3000orngrok http 3000) and register thehttpsaddress 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
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
409 | 2836 | CHECKOUT_TEST_MODE | A number other than a test number on a test checkout or test charge, or a card or balance payment on a test checkout | Use a test number |
422 | 2838 | TEST_NUMBER_LIVE | A test number on a real checkout or charge | Use a real number |
400 | 3004 | CHARGE_METHOD_UNAVAILABLE | card or paybill on a test charge | Test those in production |