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 key pk_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)ResultM-Pesa result code
2Wrong PIN (failed)2001
3Cancelled by the customer1032
4No response from the phone (failed)1037
Any other amountPaid. 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": false at the top level and inside data. Never ship goods for those.
  • Answers from /api/payments/stkpush and /api/payments/status carry livemode too.
  • 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

  1. 1Verify your business. Finish Verification. Live keys get 403 KYC_REQUIRED until it is approved.
  2. 2Add a payment channel. Add the till, paybill or bank the money should go to.
  3. 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.

Read next

© 2026 JMSURF PAY. All rights reserved. · ODPC reg. no. 194-9812-26EBPowered by JMSURF TECHNOLOGIES LTD