mpesa-php-sdk icon indicating copy to clipboard operation
mpesa-php-sdk copied to clipboard

Wrong implementation of stk push function

Open AustineGwa opened this issue 6 years ago • 7 comments

The implementation of stk push function does not match the documentation in the developer portal
Timestamp parameter is missing and there is an added remarks parameter that does not exist in the documentation

this is what the documentation says: <?php

$curl_post_data = array( //Fill in the request parameters with valid values 'BusinessShortCode' => ' ', 'Password' => ' ', 'Timestamp' => ' ', 'TransactionType' => 'CustomerPayBillOnline', 'Amount"' => ' ', 'PartyA' => ' ', 'PartyB' => ' ', 'PhoneNumber' => ' ', 'CallBackURL' => 'https://ip_address:port/callback', 'AccountReference' => ' ', 'TransactionDesc' => ' ' );

$data_string = json_encode($curl_post_data);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);

$curl_response = curl_exec($curl); print_r($curl_response);

echo $curl_response; ?>

AustineGwa avatar Nov 03 '18 10:11 AustineGwa

true it keeps throwing error when you add the remarks field

kyien avatar Sep 12 '19 10:09 kyien

Was this one fixed?

Also, still on the function STKPushSimulation while the TransactionDesc is set in the function parameters, It's not being sent to the server, what is the point? But this line can easily be changed by developers. 'TransactionDesc' => $TransactionType

Another thing I don't understand is the timestamp generation: why the concatenation? $timestamp='20'.date( "ymdhis");

jaymoh avatar Oct 06 '19 11:10 jaymoh

@AustineGwa was it fixed?

StanleyMasinde avatar Dec 20 '20 18:12 StanleyMasinde

@AustineGwa @StanleyMasinde @kyien Let me have a look into this and will update on the progress in a day.

mossey avatar Jan 06 '21 08:01 mossey

@AustineGwa @StanleyMasinde @kyien Let me have a look into this and will update on the progress in a day.

mossey avatar Jan 06 '21 08:01 mossey

@jaymoh , This concatenation is to generate time in the form of YYYYMMDDHHmmss

mossey avatar Jan 06 '21 08:01 mossey

That's great @mossey. Thanks

StanleyMasinde avatar Jan 06 '21 08:01 StanleyMasinde