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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners