Skip to content

Commit

Permalink
Refactored constructor by removing callback urls
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencoduor committed Oct 4, 2022
1 parent 1210c51 commit 43798f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
7 changes: 4 additions & 3 deletions src/B2B.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function __construct(array $config)
* @param string $remarks
* @return array object
*/
public function b2bSend($Amount, $commandId, $PartyB, $RecieverIdentifierType, $SenderIdentifierType, $AccountReference, $Remarks, $timeout_url, $result_url)
public function b2bSend($Amount, $commandId, $PartyB, $RecieverIdentifierType, $SenderIdentifierType, $AccountReference, $Remarks, $timeout_url,
$result_url)
{
$url = $this->env('/mpesa/b2b/v1/paymentrequest');

Expand All @@ -42,8 +43,8 @@ public function b2bSend($Amount, $commandId, $PartyB, $RecieverIdentifierType, $
'PartyB' => $PartyB,
'AccountReference' => $AccountReference,
'Remarks' => $Remarks,
'QueueTimeOutURL' => $this->timeout_url . $timeout_url,
'ResultURL' => $this->result_url . $result_url
'QueueTimeOutURL' => $timeout_url,
'ResultURL' => $result_url
);

$this->query($url, $curl_post_data);
Expand Down
4 changes: 2 additions & 2 deletions src/B2C.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function b2cSend($amount, $commandId, $receiver, $remark, $occassion = nu
'PartyA' => $this->shortcode1,
'PartyB' => $receiver,
'Remarks' => $remark,
'QueueTimeOutURL' => $this->timeout_url . $timeout_url,
'ResultURL' => $this->result_url . $result_url,
'QueueTimeOutURL' => $timeout_url,
'ResultURL' => $result_url,
'Occasion' => $occassion
);

Expand Down
6 changes: 3 additions & 3 deletions src/C2B.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ public function __construct(array $config)
*
* @return json
*/
public function register_url()
public function register_url($confirmation_url,$validation_url)
{
$url = $this->env('mpesa/c2b/v1/registerurl');

//Fill in the request parameters with valid values
$curl_post_data = array(
'ShortCode' => $this->shortcode1,
'ResponseType' => 'Completed',
'ConfirmationURL' => $this->confirmation_url,
'ValidationURL' => $this->validation_url
'ConfirmationURL' => $confirmation_url,
'ValidationURL' => $validation_url
);

$this->query($url, $curl_post_data);
Expand Down
20 changes: 10 additions & 10 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Config
protected string $initiator_name;
protected string $initiator_pass;
protected string $security_credential;
protected string $confirmation_url;
protected string $timeout_url;
protected string $validation_url;
protected string $callback_url;
protected string $result_url;
// protected string $confirmation_url;
// protected string $timeout_url;
// protected string $validation_url;
// protected string $callback_url;
// protected string $result_url;
protected string $live_endpoint;
protected string $sandbox_endpoint;

Expand Down Expand Up @@ -50,11 +50,11 @@ protected function __construct(array $config) {
$this->initiator_name = (isset($config['initiator_name'])) ? $config['initiator_name'] :null;
$this->initiator_pass = (isset($config['initiator_pass'])) ? $config['initiator_pass'] :null;
$this->store = (isset($config['store'])) ? $config['store'] :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->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->env = (isset($config['env'])) ? $config['env'] :true;

$this->live_endpoint = 'https://api.safaricom.co.ke/';
Expand Down
4 changes: 2 additions & 2 deletions src/STK.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(array $config)
* @return array object
*/

public function stkPush($Amount, $PartyA, $AccountReference, $TransactionDesc)
public function stkPush($Amount, $PartyA, $AccountReference, $TransactionDesc,$callback_url)
{
$url = $this->env('mpesa/stkpush/v1/processrequest');

Expand All @@ -37,7 +37,7 @@ public function stkPush($Amount, $PartyA, $AccountReference, $TransactionDesc)
'PartyA' => $PartyA,
'PartyB' => $this->shortcode,
'PhoneNumber' => $PartyA,
'CallBackURL' => $this->callback_url,
'CallBackURL' => $callback_url,
'AccountReference' => $AccountReference,
'TransactionDesc' => $TransactionDesc
);
Expand Down

0 comments on commit 43798f3

Please sign in to comment.