Last Updated on May 1, 2023 https://en.wikipedia.org/wiki/M-Pesa is a popular payment gateway in Kenya and Africa and is used by more than https://www.statista.com/statistics/1139190/m-pesa-customer-numbers/ on a day-to-day basis. Mpesa Provides various https://developer.safaricom.co.ke/APIs which we can leverage and use to enhance business transactions.

In this tutorial, you will learn how to integrate Mpesa APIs into your Laravel application.

//App/Http/Controllers/MpesaSTKPUSHController.php confirm($request); if ($stk_push_confirm) { $this->result_code = 0; $this->result_desc = 'Success'; } return response()->json([ 'ResultCode' => $this->result_code, 'ResultDesc' => $this->result_desc ]); }}

// App/Http/Controllers/MPESAB2CController.php input('phonenumber'); $amount = $request->input('amount'); $remarks = $request->input('remarks'); $command = $request->input('command'); $response = Mpesa::b2c($phoneno, $command, $amount, $remarks); $result = json_decode((string)$response); return $result }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners