STK Push and Query
Start a push
Section titled “Start a push”const response = await mpesa.stkPush({ phoneNumber: "254708374149", amount: 100, callbackUrl: "https://example.com/mpesa/stk", accountReference: "invoice-001", transactionDesc: "Subscription payment",});Query later
Section titled “Query later”const status = await mpesa.stkQuery({ checkoutRequestId: response.CheckoutRequestID,});Operational guidance
Section titled “Operational guidance”- Treat the callback as the primary source of truth for successful payments.
- Use STK query when the callback is delayed or your receiver was unavailable.
- Keep
accountReferenceandtransactionDescmeaningful enough to correlate the payment on your side.
Validation done by the SDK
Section titled “Validation done by the SDK”- Phone number normalization to Kenyan
254...format - Positive amount enforcement
- Callback URL validation
- Shortcode and passkey presence checks