Go live
Check secrets, invoice ids, webhooks, and a real paid payment before you switch on customers.
Go live
Run one real payment on your server, including a failure, before you point customers at it.
Checklist
| Check | Done when |
|---|---|
| Secret stays on the server | No page, app, or log that a customer can read contains api_secret. |
| Invoice id is yours | Each order sends its own account_reference. You stored checkout_request_id from the STK response. |
| Paid means settled | You fulfill on paid: true or mpesa.payment.received, after the amount and reference match the order. |
| Webhook and status | The callback URL is HTTPS, the signature check uses the raw body and the API secret, you return 2xx, and a status poll covers a missed webhook. |
| Duplicates | You store Idempotency-Key and the M-Pesa receipt so a second delivery does not fulfill again. |
| Prepaid balance | The service-token wallet can cover the fee, or the account is postpaid. A 402 is handled in your UI. |
| Channel | The Channel ID is active on that Account ID. A 422 is logged with the id you sent. |
If a test fails
| What you see | Look at |
|---|---|
401 | All three auth fields, from the same API Keys card. Authentication. |
422 | Channel inactive or on another account. Payment channels. |
402 INSUFFICIENT_PREPAID | Top up service tokens. The body includes required_kes and balance_kes. |
| STK stays pending | The customer may not have confirmed. Poll payment status with the stored checkout_request_id. |
| Your webhook returns 401 | HMAC is over the raw body, with the API secret. A parsed JSON string will not match. |