safaricom / mpesa-php-sdk

A PHP sdk for the new Mpesa RESTful APIs
188 stars 219 forks source link

No Reponse at the callback url #17

Closed nellycheboi closed 6 years ago

nellycheboi commented 6 years ago

I am interacting with the Mpesa Api test endpoint i.e https://sandbox.safaricom.co.ke/mpesa/b2b/v1/paymentrequest for B2B request. I am still not getting any data at my callback server. Do you send responses even tests or is it just for production/live purposes. I fully debugged my callback server. I am able to get pings/request just not from Mpesa.

mossey commented 6 years ago

Hey @nellycheboi12 please make sure that your Callback route is accessible from the internet. Callbacks are sent to applications on the sandbox too.

AMABK commented 5 years ago

Make sure your call back route is a POST and not GET. Also ensure no CSRF validation as in some frameworks

henimmans commented 5 years ago

You need to use a tool like ngrok to expose your routes to the outside world download it from here https://ngrok.com/ this tool will expose your app on the internet, therefore making it easy for MPesa to hit your callback endpoints properly

ABHISHEK8973 commented 5 years ago

Hello what we put in under callback url

weddingjuma commented 4 years ago

Php way have a look at https://3v4l.org/rYfdr

gondwe commented 4 years ago

I have my callback on new cpanel host. Im dumping all request data to text file via global $_REQUEST. Im not receiving anything yet. @weddingjuma @here Kindly advice. Thanks.

jeffmuts commented 3 years ago

Does the sandbox sometimes for no reason just refuse to push back to one's callback URL? Mine was working and now it seems it does not hit the endpoint at all.

WesleyGichana commented 3 years ago
    $callbackJSONData=file_get_contents('php://input');
    $callbackData=json_decode($callbackJSONData);
    $resultCode=$callbackData->Body->stkCallback->ResultCode;
    $resultDesc=$callbackData->Body->stkCallback->ResultDesc;
    $merchantRequestID=$callbackData->Body->stkCallback->MerchantRequestID;
    $checkoutRequestID=$callbackData->Body->stkCallback->CheckoutRequestID;

    $amount=$callbackData->stkCallback->Body->CallbackMetadata->Item[0]->Value;
    $mpesaReceiptNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[1]->Value;
    $balance=$callbackData->stkCallback->Body->CallbackMetadata->Item[2]->Value;
    $b2CUtilityAccountAvailableFunds=$callbackData->Body->stkCallback->CallbackMetadata->Item[3]->Value;
    $transactionDate=$callbackData->Body->stkCallback->CallbackMetadata->Item[4]->Value;
    $phoneNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[5]->Value;

    $result=[
        "resultDesc"=>$resultDesc,
        "resultCode"=>$resultCode,
        "merchantRequestID"=>$merchantRequestID,
        "checkoutRequestID"=>$checkoutRequestID,
        "amount"=>$amount,
        "mpesaReceiptNumber"=>$mpesaReceiptNumber,
        "balance"=>$balance,
        "b2CUtilityAccountAvailableFunds"=>$b2CUtilityAccountAvailableFunds,
        "transactionDate"=>$transactionDate,
        "phoneNumber"=>$phoneNumber
    ];

    return json_encode($result);

try this

jeffmuts commented 3 years ago

Hello,

Much appreciated.

Regards, Mutunga

On Thu, Apr 22, 2021 at 1:02 AM Wesley Gichana @.***> wrote:

$callbackJSONData=file_get_contents('php://input');
$callbackData=json_decode($callbackJSONData);
$resultCode=$callbackData->Body->stkCallback->ResultCode;
$resultDesc=$callbackData->Body->stkCallback->ResultDesc;
$merchantRequestID=$callbackData->Body->stkCallback->MerchantRequestID;
$checkoutRequestID=$callbackData->Body->stkCallback->CheckoutRequestID;

$amount=$callbackData->stkCallback->Body->CallbackMetadata->Item[0]->Value;
$mpesaReceiptNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[1]->Value;
$balance=$callbackData->stkCallback->Body->CallbackMetadata->Item[2]->Value;
$b2CUtilityAccountAvailableFunds=$callbackData->Body->stkCallback->CallbackMetadata->Item[3]->Value;
$transactionDate=$callbackData->Body->stkCallback->CallbackMetadata->Item[4]->Value;
$phoneNumber=$callbackData->Body->stkCallback->CallbackMetadata->Item[5]->Value;

$result=[
    "resultDesc"=>$resultDesc,
    "resultCode"=>$resultCode,
    "merchantRequestID"=>$merchantRequestID,
    "checkoutRequestID"=>$checkoutRequestID,
    "amount"=>$amount,
    "mpesaReceiptNumber"=>$mpesaReceiptNumber,
    "balance"=>$balance,
    "b2CUtilityAccountAvailableFunds"=>$b2CUtilityAccountAvailableFunds,
    "transactionDate"=>$transactionDate,
    "phoneNumber"=>$phoneNumber
];

return json_encode($result);

try this

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/safaricom/mpesa-php-sdk/issues/17#issuecomment-824386862, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJZXCFWTA3NMQYGPHXTYDTTJ5DOFANCNFSM4EYQQAMA .

Abdullahi254 commented 3 years ago

Your callback url should be accessible from the internet and should also be a https for you to be able to get a response from the safaricom api

boratechlife commented 2 years ago

Make sure you disable ufw firewall if you are using ubuntu. That work for me .sudo ufw disable

Kaburumwenda commented 2 years ago

experiencing the same problem

kalyangadgil commented 2 years ago

I am implementing Lipa Na Mpesa STK push and I am not getting response at my callback url after transaction .

kindly Help !

jeffmuts commented 2 years ago

@kalyangadgil ensure you are using HTTPS for your Callback URL. Sometimes this is the issue. You can use some tunneling software if you are testing on localhost -. I hope that helps

kalyangadgil commented 2 years ago

@jeffmuts

Yes . I am using HTTPS for my callback URL . right now I am using their test credentials .

AND in my callback function following is the code :

  $yourJsonHere = file_get_contents('php://input');
  $rooms = json_decode($yourJsonHere);
  var_dump($rooms);

Query : 1) Do I need to make my app live to receive response from Lipa na Mpesa at my callback url ?

Thank you !

jeffmuts commented 2 years ago

@kalyangadgil can you try to dump the contents into a file with file_put_contents('mpesa_push.txt',json_encode( $yourJsonHere)); Since the async might not happen immediately. Just wild thought then you can check the contents of the file

kiptalam25 commented 2 years ago

i have the same problem call back url not working

seffu commented 2 years ago

same here, I am getting a successful registration for the Validation and Confirmation URLs but during simulation it does not redirect to the validation URL. Is this a problem with sandbox?

davisbravinprograms commented 2 years ago

There has to be a problem with sandbox, i am not receiving any data either. Kindly let us know when any of you find a solution thanks.

oluoch12 commented 2 years ago

What is your problem and how can i help you

On Fri, 17 Jun 2022 at 12:08, kiptalam25 @.***> wrote:

i have the same problem call back url not working

— Reply to this email directly, view it on GitHub https://github.com/safaricom/mpesa-php-sdk/issues/17#issuecomment-1158667335, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZFHSAYYIFCBGJZEZS6QPCDVPQ6BBANCNFSM4EYQQAMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SmartGuyCodes commented 2 years ago

Hello,

I am having this problem too.

I have been working on an STK push integration on an API currently working on. The STK Push callback has been working well until 26th October 2022 when it just went silent.

What could be the issue?

How can it be solved?

Thanks in advance. Ogego

em-manuel commented 1 year ago

I am simulating a C2B transaction. The following are the steps I have taken:

  1. Get auth token.
  2. Register Callback URLs
  3. Simulate payment.

All the above are successful.

However the callback URL is not getting any hits. It is not a UFW issue cause another STK callback script running (m-pesa live) is getting hits of the callback.

What could I be missing here?

Gareba308 commented 1 year ago

Did anyone find a solution to this thread? Not getting the callback data from Mpesa Sandbox. Posting data using the same url path on postman gives data, but the sandbox callback data doesn't appear

Gloriahmutungi commented 1 year ago

Am getting the same issue yet i have i exposed the url on the internet

Gareba308 commented 1 year ago

Read in there daraja forum, a number of developers are facing the same issue. I guess they could be having an issue with callbacks in there API

GidieLegacy commented 1 year ago

Am getting the same issue yet i have i exposed the url on the internet

Hello @Gloriahmutungi I have the same issue. Did you find a solution?

Chepsain commented 1 year ago


Warning: file_get_contents(D:\xampp\htdocs\login\investpage/mpesa_public_cert.cer): Failed to open stream: No such file or directory in D:\xampp\htdocs\login\investpage\status.php on line 48

Warning: openssl_public_encrypt(): key parameter is not a valid public key in D:\xampp\htdocs\login\investpage\status.php on line 49

Warning: Undefined property: stdClass::$ResponseCode in D:\xampp\htdocs\login\investpage\status.php on line 88
Transaction doesnt exist

kindly help

Gloriahmutungi commented 1 year ago

Am getting the same issue yet i have i exposed the url on the internet

Hello @Gloriahmutungi I have the same issue. Did you find a solution?

There is just an issue with sandbox callback so i used live credentials for test and the response is coming ..you may test with live credentials you know if the issue is with you code as well

GidieLegacy commented 1 year ago

Am getting the same issue yet i have i exposed the url on the internet

Hello @Gloriahmutungi I have the same issue. Did you find a solution?

There is just an issue with sandbox callback so i used live credentials for test and the response is coming ..you may test with live credentials you know if the issue is with you code as well

Okay. Thanks for replying.

Developer-felix commented 10 months ago

Hello did anyone find solution to this since I am getting the same problem

davisbravinprograms commented 10 months ago

inbox me for help, i had the same issue but i found a way around it

On Thu, 25 Jan 2024 at 04:58, Anonymous @.***> wrote:

Hello did anyone find solution to this since I am getting the same problem

— Reply to this email directly, view it on GitHub https://github.com/safaricom/mpesa-php-sdk/issues/17#issuecomment-1910168079, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWO2NAFLVOD2TUPKSTE5MQ3YQJJHVAVCNFSM4EYQQAMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGAYTMOBQG44Q . You are receiving this because you commented.Message ID: @.***>

davisbravinprograms commented 10 months ago

Hello did anyone find solution to this since I am getting the same problem

Yes i did find a solution, what language are you using?

alvomade commented 10 months ago

inbox me for help, i had the same issue but i found a way around it On Thu, 25 Jan 2024 at 04:58, Anonymous @.> wrote: Hello did anyone find solution to this since I am getting the same problem — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWO2NAFLVOD2TUPKSTE5MQ3YQJJHVAVCNFSM4EYQQAMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGAYTMOBQG44Q . You are receiving this because you commented.Message ID: @.>

why dont you just share with the rest . why the inbox tena.

davisbravinprograms commented 10 months ago

I can help what language are u using?

alvomade commented 9 months ago

im using JS(Node js)

On Sat, Jan 27, 2024 at 1:13 AM davisbravinprograms < @.***> wrote:

I can help what language are u using?

— Reply to this email directly, view it on GitHub https://github.com/safaricom/mpesa-php-sdk/issues/17#issuecomment-1912764092, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3HNUSJ4FEQBNIIMO2CD6DYQQS7XAVCNFSM4EYQQAMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGI3TMNBQHEZA . You are receiving this because you commented.Message ID: @.***>

davisbravinprograms commented 9 months ago

im using JS(Node js) On Sat, Jan 27, 2024 at 1:13 AM davisbravinprograms < @.> wrote: I can help what language are u using? — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3HNUSJ4FEQBNIIMO2CD6DYQQS7XAVCNFSM4EYQQAMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJRGI3TMNBQHEZA . You are receiving this because you commented.Message ID: @.>

inbox me in the email, needs some explanations

jameskanyiri commented 8 months ago

i am getting the same issue i am using laravel.

samuelmaina commented 7 months ago

Well someone can get the result of the test transaction by querying mpesa with the CheckoutRequestID (this is returned in the body of initial sdk ).One can make a post request to https://sandbox.safaricom.co.ke/mpesa/stkpushquery/v1/query. I found how to query by login->select APIs->click on query button in the M-Pesa Express card. Hope this helps those in test env but I would suggest one moves to production to avoid the many hustle of dealing with CheckoutRequestIDs

jameskanyiri commented 7 months ago

Yes moving to production solved my issue @samuelmaina

bulej93 commented 6 months ago

Yes moving to production solved my issue @samuelmaina

@jameskanyiri you got a real paybill from safaricom or you deployed your app?

ah2k-dev commented 4 months ago

Was getting the same issue, reached out to the support team and they resolved the issue in less than an hour and it's working fine.