Skip to content

Commit

Permalink
Refactored Configs to Mpesa Class
Browse files Browse the repository at this point in the history
Refactored Configs to Mpesa Class
  • Loading branch information
stephencoduor authored Oct 21, 2022
1 parent 9a2dcd6 commit 5ed1804
Showing 1 changed file with 47 additions and 6 deletions.
53 changes: 47 additions & 6 deletions src/Mpesa.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
| *---------------------------------------------------------------------------------------
*/

class Mpesa extends Config
class Mpesa extends
{

public string $security_credential;
Expand All @@ -39,14 +39,55 @@ class Mpesa extends Config
private string $token;


public function __construct(array $config)
{
// $this->security_credential = $this->security_credential();
parent::__construct($config);
//public string $SecurityCredential;
protected string $consumer_key;
protected string $consumer_secret;
protected string $shortcode;
protected string $store;
protected string $pass_key;
protected string $TransactionType;
protected string $sandbox_endpoint;
public bool $environment;

protected function __construct(array $config) {


}
if(isset($config['consumer_key'])) {
$this->consumer_key = $config['consumer_key'];
} else {
throw new Exception('Missing Parameter consumer_key"', 400);
}
if(isset($config['consumer_secret'])) {
$this->consumer_secret = $config['consumer_secret'];
} else {
throw new Exception('Missing parameter "consumer_secret"', 400);
}

if(isset($config['pass_key'])) {
$this->pass_key = $config['pass_key'];
} else {
throw new InvalidRequestException('Missing parameter "pass_key"', 400);
}

$this->shortcode = (isset($config['shortcode'])) ? $config['shortcode'] :null;
$this->store = (isset($config['store'])) ? $config['store'] :null;
$this->TransactionType = (isset($config['TransactionType'])) ? $config['TransactionType'] :null;
$this->initiator_name = (isset($config['initiator_name'])) ? $config['initiator_name'] :null;
$this->initiator_pass = (isset($config['initiator_pass'])) ? $config['initiator_pass'] :null;

// $this->callback_url = (isset($config['callback_url'])) ? $config['callback_url'] :null;
// $this->confirmation_url = (isset($config['confirmation_url'])) ? $config['confirmation_url'] :null;
// $this->timeout_url = (isset($config['timeout_url'])) ? $config['timeout_url'] :null;
// $this->validation_url = (isset($config['validation_url'])) ? $config['validation_url'] :null;
// $this->result_url = (isset($config['result_url'])) ? $config['result_url'] :null;


$this->environment = (isset($config['environment'])) ? $config['$environment'] :true;
$this->live_endpoint = 'https://api.safaricom.co.ke/';
$this->sandbox_endpoint = 'https://sandbox.safaricom.co.ke/';


}



Expand Down

0 comments on commit 5ed1804

Please sign in to comment.