Logo Lanfrica

GODFREY-EM/mpesa-payment-gateway

Domain:

digital infrastructure

Record type:

software
Creator:
GOD
Host:
A custom MPesa (Tanzania) payment gateway integration built with Laravel 11 conventions. ````markdown # πŸ” M-Pesa Payment Gateway for Laravel / PHP Projects A **custom Laravel M-Pesa Payment Gateway** built with Laravel 11+ standards. Supports **STK Push**, secure credential handling, and integrates easily into **any Laravel or PHP project** β€” perfect for developers targeting **Kenya, Tanzania, and East Africa**. --- ## πŸš€ Features - βœ… **STK Push Payment Integration** - βœ… **Reusable Service Class (`MpesaHelper`)** - βœ… **Live/Sandbox Environment Support** - βœ… **Custom Config File Support** - βœ… **Modular & Extendable Code Structure** - βœ… **Works with Laravel (9.x to 11.x) & Bagisto** --- ## πŸ“¦ Installation Install via Composer: ```bash composer require godfrey-em/mpesa-payment-gateway ```` Publish the configuration file (if applicable): ```bash php artisan vendor:publish --provider="Webkul\Mpesa\Providers\MpesaServiceProvider" ``` --- ## βš™οΈ Configuration Add the following to your `.env` file: ```env MPESA_ENV=sandbox MPESA_CONSUMER_KEY=your-consumer-key MPESA_CONSUMER_SECRET=your-consumer-secret MPESA_SHORTCODE=your-shortcode MPESA_PASSKEY=your-passkey MPESA_CALLBACK_URL=yourdomain.com ``` Make sure your `config/mpesa.php` is correctly mapped to use these variables. --- ## 🧠 Usage Example Use the service class to initiate an STK push request: ```php use Webkul\Mpesa\Lib\MpesaHelper; public function pay(Request $request) { $mpesa = new MpesaHelper(); $response = $mpesa->stkPush([ 'amount' => 500, 'phone' => '2557XXXXXXXX', 'reference' => 'Order1234', 'description' => 'Purchase Payment', ]); return response()->json($response); } ``` > πŸ” **Note**: Make sure you validate user input (especially phone numbers) before passing to the gateway. --- ## πŸ“‚ Directory Overview ``` Mpesa/ β”œβ”€β”€ config/ β”‚ └── mpesa.php β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ Lib/ β”‚ β”‚ └── MpesaHelper.php β”‚ β”œβ”€β”€ Payment/ β”‚ └── Providers/ β”œβ”€β”€ tests/ └── README.md ``` --- ## πŸ‘¨β€πŸ’» Author **Godfrey Ernest Mapunda** * GitHub: @GODFREY-EM * Emai …

Languages

Licenses