diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index f9fe552..27d4df4 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -10,9 +10,9 @@ jobs: strategy: fail-fast: true matrix: - php: [7.3, 7.4] + php: [7.4] laravel: [6.*, 7.*, 8.*] - dependency-version: [prefer-lowest, prefer-stable] + dependency-version: [prefer-stable] include: - laravel: 8.* testbench: 6.* diff --git a/.phpunit.result.cache b/.phpunit.result.cache index 200bbc8..203b1ea 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":997:{a:2:{s:7:"defects";a:5:{s:42:"Gathuku\Mpesa\Tests\BaseTest::true_is_true";i:4;s:55:"Gathuku\Mpesa\Tests\Unit\InstallMpesaTest::true_is_true";i:4;s:57:"Gathuku\Mpesa\Tests\Unit\MpesaAuthTokenTest::true_is_true";i:4;s:47:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::test_b2c";i:3;s:61:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::test_mpesa_express";i:3;}s:5:"times";a:9:{s:42:"Gathuku\Mpesa\Tests\BaseTest::true_is_true";d:1.556;s:55:"Gathuku\Mpesa\Tests\Unit\InstallMpesaTest::true_is_true";d:0.14;s:57:"Gathuku\Mpesa\Tests\Unit\MpesaAuthTokenTest::true_is_true";d:0.14;s:60:"Gathuku\Mpesa\Tests\Unit\MpesaRegisterUrlsTest::true_is_true";d:0.152;s:47:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::test_b2c";d:3.461;s:51:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::true_is_true";d:0.146;s:61:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::test_mpesa_express";d:12.852;s:55:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::true_is_true";d:0.148;s:60:"Gathuku\Mpesa\Tests\Unit\MpesaSimeulateC2BTest::true_is_true";d:0.142;}}} \ No newline at end of file +C:37:"PHPUnit\Runner\DefaultTestResultCache":998:{a:2:{s:7:"defects";a:5:{s:42:"Gathuku\Mpesa\Tests\BaseTest::true_is_true";i:4;s:55:"Gathuku\Mpesa\Tests\Unit\InstallMpesaTest::true_is_true";i:4;s:57:"Gathuku\Mpesa\Tests\Unit\MpesaAuthTokenTest::true_is_true";i:4;s:47:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::test_b2c";i:3;s:61:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::test_mpesa_express";i:5;}s:5:"times";a:9:{s:42:"Gathuku\Mpesa\Tests\BaseTest::true_is_true";d:0.164;s:55:"Gathuku\Mpesa\Tests\Unit\InstallMpesaTest::true_is_true";d:0.003;s:57:"Gathuku\Mpesa\Tests\Unit\MpesaAuthTokenTest::true_is_true";d:0.003;s:60:"Gathuku\Mpesa\Tests\Unit\MpesaRegisterUrlsTest::true_is_true";d:0.004;s:47:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::test_b2c";d:0.846;s:51:"Gathuku\Mpesa\Tests\Unit\MpesaB2CTest::true_is_true";d:0.004;s:61:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::test_mpesa_express";d:2.148;s:55:"Gathuku\Mpesa\Tests\Unit\MpesaExpressTest::true_is_true";d:0.004;s:60:"Gathuku\Mpesa\Tests\Unit\MpesaSimeulateC2BTest::true_is_true";d:0.003;}}} \ No newline at end of file diff --git a/src/Mpesa.php b/src/Mpesa.php index 85bf1fc..d373ce8 100644 --- a/src/Mpesa.php +++ b/src/Mpesa.php @@ -96,9 +96,9 @@ class Mpesa public function __construct() { if (config('mpesa.mpesa_env')=='sandbox') { - $this->base_url = 'https://sandbox.safaricom.co.ke/mpesa/'; + $this->base_url = 'https://sandbox.safaricom.co.ke'; } else { - $this->base_url = 'https://api.safaricom.co.ke/mpesa/'; + $this->base_url = 'https://api.safaricom.co.ke'; } //Base URL for the API endpoints. This is basically the 'common' part of the API endpoints $this->consumer_key = config('mpesa.consumer_key'); //App Key. Get it at https://developer.safaricom.co.ke @@ -150,7 +150,7 @@ public function getAccessToken() { $credentials = base64_encode($this->consumer_key.':'.$this->consumer_secret); $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, 'https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials'); + curl_setopt($ch, CURLOPT_URL, $this->base_url.'/oauth/v1/generate?grant_type=client_credentials'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$credentials, 'Content-Type: application/json')); $response = curl_exec($ch); @@ -221,7 +221,7 @@ public function b2c($amount, $phone, $command_id, $remarks) 'Occasion' => '' //Optional ); $data = json_encode($request_data); - $url = $this->base_url.'b2c/v1/paymentrequest'; + $url = $this->base_url.'/mpesa/b2c/v1/paymentrequest'; $response = $this->submit_request($url, $data); return $response; } @@ -253,7 +253,7 @@ public function b2b($amount, $shortcode) 'ResultURL' => $this->bbresult, ); $data = json_encode($request_data); - $url = $this->base_url.'b2b/v1/paymentrequest'; + $url = $this->base_url.'/mpesa/b2b/v1/paymentrequest'; $response = $this->submit_request($url, $data); return $response; } @@ -279,7 +279,7 @@ public function c2bRegisterUrls() $data = json_encode($request_data); //header('Content-Type: application/json'); - $url = $this->base_url.'c2b/v1/registerurl'; + $url = $this->base_url.'/mpesa/c2b/v1/registerurl'; $response = $this->submit_request($url, $data); //\Log::info($response); return $response; @@ -306,7 +306,7 @@ public function simulateC2B($amount, $msisdn, $ref) 'BillRefNumber' => $ref ); $data = json_encode($data); - $url = $this->base_url.'c2b/v1/simulate'; + $url = $this->base_url.'/c2b/v1/simulate'; $response = $this->submit_request($url, $data); return $response; } @@ -331,7 +331,7 @@ public function check_balance() 'ResultURL' => $this->balresult ); $data = json_encode($data); - $url = $this->base_url.'accountbalance/v1/query'; + $url = $this->base_url.'/mpesa/accountbalance/v1/query'; $response = $this->submit_request($url, $data); return $response; } @@ -360,7 +360,7 @@ public function status_request($transaction = 'LH7819VXPE') 'Occassion' => 'Test' ); $data = json_encode($data); - $url = $this->base_url.'transactionstatus/v1/query'; + $url = $this->base_url.'/mpesa/transactionstatus/v1/query'; $response = $this->submit_request($url, $data); return $response; } @@ -391,7 +391,7 @@ public function reverse_transaction($receiver, $trx_id, $amount) 'TransactionID' => 'LIE81C8EFI' ); $data = json_encode($data); - $url = $this->base_url.'reversal/v1/request'; + $url = $this->base_url.'/mpesa/reversal/v1/request'; $response = $this->submit_request($url, $data); return $response; } @@ -424,7 +424,7 @@ public function express($amount, $phone, $ref = "Payment", $desc="Payment") 'TransactionDesc' => $desc, ); $data = json_encode($data); - $url = $this->base_url.'stkpush/v1/processrequest'; + $url = $this->base_url.'/mpesa/stkpush/v1/processrequest'; $response = $this->submit_request($url, $data); if (isset($response)) { @@ -458,7 +458,7 @@ private function lnmoQuery($checkoutRequestID = null) 'CheckoutRequestID' => $checkoutRequestID ); $data = json_encode($data); - $url = $this->base_url.'stkpushquery/v1/query'; + $url = $this->base_url.'/mpesa/stkpushquery/v1/query'; $response = $this->submit_request($url, $data); return $response; }