Skip to content

Commit

Permalink
small bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Iankumu committed Dec 16, 2023
1 parent bce5a90 commit 0402600
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Utils/MpesaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function generateAccessToken()
$consumer_key = config('mpesa.mpesa_consumer_key');
$consumer_secret = config('mpesa.mpesa_consumer_secret');

$url = $this->url.'/oauth/v1/generate?grant_type=client_credentials';
$url = $this->url . '/oauth/v1/generate?grant_type=client_credentials';

$response = Http::withBasicAuth($consumer_key, $consumer_secret)
->get($url);
Expand All @@ -53,9 +53,9 @@ public function MpesaRequest($url, $body)
// Generate a base64 password using the Safaricom PassKey and the Business ShortCode to be used in the Mpesa Transaction
public function LipaNaMpesaPassword()
{
$timestamp = Carbon::rawParse('now')->format('YmdHms');
$timestamp = Carbon::rawParse('now')->format('YmdHis');

return base64_encode(config('mpesa.shortcode').config('mpesa.passkey').$timestamp);
return base64_encode(config('mpesa.shortcode') . config('mpesa.passkey') . $timestamp);
}

public function phoneValidator($phoneno)
Expand All @@ -71,9 +71,9 @@ public function phoneValidator($phoneno)
public function generate_security_credential()
{
if (config('mpesa.environment') == 'sandbox') {
$pubkey = File::get(__DIR__.'/../certificates/SandboxCertificate.cer');
$pubkey = File::get(__DIR__ . '/../certificates/SandboxCertificate.cer');
} else {
$pubkey = File::get(__DIR__.'/../certificates/ProductionCertificate.cer');
$pubkey = File::get(__DIR__ . '/../certificates/ProductionCertificate.cer');
}
openssl_public_encrypt(config('mpesa.initiator_password'), $output, $pubkey, OPENSSL_PKCS1_PADDING);

Expand Down

0 comments on commit 0402600

Please sign in to comment.