Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test STK Push Failed HttpCode:"500" #1

Open
abdazz25 opened this issue Aug 30, 2022 · 14 comments
Open

Test STK Push Failed HttpCode:"500" #1

abdazz25 opened this issue Aug 30, 2022 · 14 comments

Comments

@abdazz25
Copy link

Hi Felix,
Hope you are keeping well.
I am trying to test your Arduino Library on ESP32 module.
It connect to the Wifi the access token seems to work cause if I change the consumer_key , pass_key or secret_key. I get the invalid access token error.
How ever the STK Push fails with the error below.

Waiting for WiFi to connect... connected
Sending STK request
{"Result":"failed","HttpCode":"500"}

Could you kindly assist.

Thanks and regards,
Abdalla

@fbiego
Copy link
Owner

fbiego commented Aug 30, 2022

Check you callback url, it should be secured (https)

fbiego added a commit that referenced this issue Aug 30, 2022
callback url must be secured #1
@abdazz25
Copy link
Author

Hi Felix,
I am testing it using your call back URL from the examples and it is https.

I have tried to remove the s from the http url still the error code is the same.

Though I am using credentials from my live Buy_Goods in Production.
Will that cause this issue?

@abdazz25
Copy link
Author

I have uploaded the stkHandler to my site. It is https.
The daraja.txt was created with below data even though the transaction failed with error 500.

{"success":true,"paid":true,"message":"Payment successful","amount":null,"txID":null,"balance":null,"date":null,"number":null,"merchantID":null,"checkoutID":null,"resultCode":null,"resultDesc":null}

@fbiego
Copy link
Owner

fbiego commented Aug 30, 2022

Hello, I have not tested the code in a production environment.
Can you check if it works in the sandbox? Use the default settings from the example first i.e

mpesa.begin(TEST_CODE, PAYBILL, "https://mycallbackurl.com/checkout.php");

@abdazz25
Copy link
Author

Hi Felix,
I modified the .cpp file to show the error message. This guided me to fix the issue. I was using the Till Number insted of the Store Number.

Waiting for WiFi to connect... connected
{"requestId":"12566-20270757-1","errorCode":"500.001.1001","errorMessage":"Merchantdoesnotexist","Result":"success","HttpCode":"500"}

After changing the Buy_Code to Store Number the stk push came though then followed by an SMS from Safaricom as below.

Failed. M-PESA cannot complete this operation. The parameter value is incorrect. No till is found. for CustomerPayMerchant. For more information call or SMS customer services on 100.

Kindly see if you are passing this CustomerPayMerchant to the API

{"MerchantRequestID":"19978-16256822-1","CheckoutRequestID":"ws_CO_30082022171926235716594139","ResponseCode":"0","ResponseDescription":"Success.Requestacceptedforprocessing","CustomerMessage":"Success.Requestacceptedforprocessing","Result":"success","HttpCode":"200"}

@fbiego
Copy link
Owner

fbiego commented Aug 30, 2022

Okay, noted. I will implement that

@abdazz25
Copy link
Author

abdazz25 commented Aug 30, 2022 via email

@abdazz25
Copy link
Author

abdazz25 commented Oct 17, 2022 via email

@fbiego
Copy link
Owner

fbiego commented Oct 17, 2022

Hello,
I've been quite busy and haven't had time to work on this.
Can you submit a PR with the changes?

@jumla-online
Copy link

hello abdazz25, which callback url are you using?

@abdazz25
Copy link
Author

abdazz25 commented Jan 4, 2023

@fbiego I am not very familiar with GitHub Pull Request.

However, from my previous tests above.
There are two scenarios on using the MpesaSTK

  1. One is using a Till Number
  2. Using a Paybill Number
    The tests I have done above is using a Till Number.
    When using a Till Number, you have to use both your Till Number and something called a Store Number. The Store Number does not apply when using a Paybill Number for STK Push.

So, this error which generated is because in your code the concept of Store Number is not taken care of.
Below error was from the API.
After changing the Buy_Code to Store Number the stk push came though then followed by an SMS from Safaricom as below.

"Failed. M-PESA cannot complete this operation. The parameter value is incorrect. No till is found. for CustomerPayMerchant. For more information call or SMS customer services on 100."

What I am requesting is, if you can handle this Store Number issue. So that it can work with Till Numbers.

@jumla-online
The call back url, I uploaded the files from this to my cpanel.
// the callback & check URL is based on the PHP files @
// https://github.com/fbiego/stkHandler

@abdazz25
Copy link
Author

Hi guys,
I just wanted to confirm here that, I have tested the library on PRODUCTION and with a Paybil number. It works perfectily with the callback and check urls.
However, it does not work with Till Number.

{"success":true,"paid":true,"message":"Payment successful","amount":1,"txID":"RHP2ZDY10O","balance":null,"date":20230825115858,"number":254716594xxx,"merchantID":"7609-145740404-1","checkoutID":"ws_CO_25082023115851612716594139","resultCode":0,"resultDesc":"The service request is processed successfully."}

@fbiego
Copy link
Owner

fbiego commented Aug 25, 2023

Hi guys, I just wanted to confirm here that, I have tested the library on PRODUCTION and with a Paybil number. It works perfectily with the callback and check urls. However, it does not work with Till Number.

{"success":true,"paid":true,"message":"Payment successful","amount":1,"txID":"RHP2ZDY10O","balance":null,"date":20230825115858,"number":254716594xxx,"merchantID":"7609-145740404-1","checkoutID":"ws_CO_25082023115851612716594139","resultCode":0,"resultDesc":"The service request is processed successfully."}

Thanks for the information. Could you share if Till numbers are already supported in the API?

@abdazz25
Copy link
Author

@fbiego yes till numbers are supported. I have it working on a WordPress website checkout. However as mentioned earlier on one of my earlier comments, when using a Till Number, there is something called Store Number, this has to be sent as part of the parameters to the API for authentication. This is not taken care of on your Library. Every Till Number has a Store Number assigned to it. Kindly make some time to check on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants