Test M-Pesa payments with test keys
JMSURF PAY guide · updated 21 November 2026
Test mode lets you build and try your integration without sending real M-Pesa prompts. You get a test key as soon as your email is confirmed. It works before your business is verified and on every plan, including Free.
Test keys
- A test key looks like
sk_test_…, with the public keypk_test_…. Find it under API & keys, Test mode. - Use the same endpoints and the same request body as live. Only the key changes.
- Nothing is sent to M-Pesa and no phone is charged. The prompt is simulated and settles by itself in about 6 seconds.
Pick the result with the amount
| Amount (KES) | Result | M-Pesa result code |
|---|---|---|
| 2 | Wrong PIN (failed) | 2001 |
| 3 | Cancelled by the customer | 1032 |
| 4 | No response from the phone (failed) | 1037 |
| Any other amount | Paid. The receipt starts with TEST. | 0 |
cURL: a cancelled test payment
curl -X POST https://jmsurfpay.co.ke/api/payments/stkpush \
-H "X-API-Key: YOUR_TEST_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"phoneNumber": "2547XXXXXXXX",
"amount": 3,
"accountReference": "TEST1",
"transactionDesc": "Test payment"
}'Telling test from live
- Webhooks still fire, with
"livemode": falseat the top level and insidedata. Never ship goods for those. - Answers from
/api/payments/stkpushand/api/payments/statuscarrylivemodetoo. - Test payments never count in totals, Transactions, reports, customers, exports or your plan's monthly volume. You find them under API & keys, Test mode.
- A test key reads test payments only, and a live key live payments only. Idempotency keys are kept apart too.
What test keys cannot do
Test keys can send payments and read data. Endpoints that change live data or move real money, such as payouts, plan renewals and registering payment channels, answer 403 TEST_MODE_UNSUPPORTED.
Going live
- 1Verify your business. Finish Verification. Live keys get
403 KYC_REQUIREDuntil it is approved. - 2Add a payment channel. Add the till, paybill or bank the money should go to.
- 3Switch the key. Create a live key under API & keys, Live and put it on your server in place of the test key.
Start on the Free plan: 1 payment channel, up to KES 50,000 a month, test keys included. Questions? WhatsApp +254 712 504 593.