safaricom / mpesa-php-sdk

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

Trying to understand the $SecurtyCredential parameter in AccountBalance API #40

Closed qlint closed 4 years ago

qlint commented 4 years ago

I've been trying to figure out what exactly the $SecurityCredential is in the AccountBalance api request. From the documentation, it defines this parameter as

"Base64 encoded string of the M-Pesa short code and password, which is encrypted using M-Pesa public key and validates the transaction on M-Pesa Core system."

So my question is:

$SecurityCredential = base64_encode($shortCode.$password);

From the above statement, what exactly is $password? Is it the passkey given in the portal? Is $shortCode the short code 1 given in the portal in test credentials or is it the lipa na mpesa online short code?

It seems if I pass a variety of combinations to that parameter, I get the same result:

object(stdClass)#5 (4) {
  ["OriginatorConversationID"]=>
  string(14) "4137-1548347-1"
  ["ConversationID"]=>
  string(32) "AG_20191002_000055f9b17ae44e2f9e"
  ["ResponseCode"]=>
  string(1) "0"
  ["ResponseDescription"]=>
  string(40) "Accept the service request successfully."
}