safaricom / mpesa-php-sdk

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

Wrong implementation of stk push function #30

Open AustineGwa opened 5 years ago

AustineGwa commented 5 years ago

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; ?>

kyien commented 4 years ago

true it keeps throwing error when you add the remarks field

jaymoh commented 4 years ago

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");

StanleyMasinde commented 3 years ago

@AustineGwa was it fixed?

mossey commented 3 years ago

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

mossey commented 3 years ago

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

mossey commented 3 years ago

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

StanleyMasinde commented 3 years ago

That's great @mossey. Thanks