× This category encapsulates all discussions, tutorials and answers about Mpesa Express APIs integration | Mpesa Express APIs integration | STK push | STK push integration in PHP

Common errors on MPESA STK push you need to be aware

  • Sir Brian M. W
  • Sir Brian M. W's Avatar Topic Author
  • Offline
  • Administrator
  • Administrator
More
1 year 2 months ago #404 by Sir Brian M. W
When doing STK push request on the Mpesa express integration, there are some errors you need to be aware and filter with if, else statements to help your customers with human readable error messages that direct them on what to do.

Without these, you will confuse your app or website users who cannot understand the messages as sent by Mpesa Api.

1. Error number one: Status code: if not 0, it means the request didnt go through. When there is this status code, there will be an errorMessage index output. You need to display this and echo a human readable error message.
If status code is 0, it means the request went through. Output a success message directing the client on what to do with the popup that appears on his phone.

2. Error number two: errorMessage itself. This is the error message output when status code is not 0.

3. Error message three: The specific error messages that you can filter are:
a). if
($message == 'Bad Request - Invalid Amount')
//This means that the amount is invalid. Mpesa will allow whole number amounts between 1 and 70,000.

b).if
$message =='[STK] - Unable to lock subscriber, a transaction is already in process for the current subscriber')
//this means you cannot send two consecutive STK push requests when the first one has not been cancelled.

c). if
($message =='[CBS - ] No ICCID found'){

//This means the provided phone is not a safaricom phone number or is not Mpesa registered.


d).
($message =='Service is currently under maintenance. Please try again later')

//Here, Mpesa is simply experiencing delays. Very normal and you can do nothing about it. Just wait and try again later.


Well, these are some of the error message to consider to help your app and website users who pay via Mpesa express API gateway.

Please Log in to join the conversation.

Time to create page: 0.175 seconds
Powered by Kunena Forum