kchizi / mpesa by kchizi
forked from lawrence615/mpesa

Package to integrate MPesa Services i.e. C2B, B2C, B2B and Online Checkout in your Laravel app. It allows you to receive and process soap sent by Safaricom. The package is still under heavy development and thus subject to bugs and changes.
8
0
2
Package Data
Maintainer Username: kchizi
Maintainer Contact: samuel@imanilabs.com (Samuel Ngoda)
Package Create Date: 2017-07-17
Package Last Update: 2017-08-07
Language: PHP
License: MIT
Last Refreshed: 2024-05-18 15:11:45
Package Statistics
Total Downloads: 8
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Mpesa API Implementation

Latest Stable Version Total Downloads Latest Unstable Version License

This package is created to integrate MPesa Services i.e. C2B, B2C, B2B and Online Checkout in your Laravel app. It allows you to receive and process soap sent by Safaricom. The package is still under heavy development and thus subject to bugs and changes.

Requirements

Quick Installation

composer require "lawrence615/mpesa:dev-master"

Service Provider

Ngodasamuel\Mpesa\MpesaServiceProvider::class

Configuration and Assets

php artisan vendor:publish --provider="Ngodasamuel\Mpesa\MpesaServiceProvider"

Then run php artisan migrate to create the tables in you database. This will create two tables;

  1. mpesa_payment_logs table - logs everything received from Safaricom

  2. payments table - breaks down what is received from Safaricom into a number of columns

Receiver Route

The route that receives the IPN is c2b/payments/receiver i.e. http://example.com/c2b/payments/receiver. This is the endpoint you give to Safaricom.

Events

There are events triggered when certain actions happen. You can extend the package's behaviour by setting up your own event listeners to provide custom functionality.

These are the events triggered by the package. The list will grow with time as more events come up;

| Event | Available data | |----------------------|-------------------------| |c2b.received.payment | Full C2B Payment Object

C2B Payment Event Listener

Create a Controller i.e. PaymentsController then create a function c2bPayment

    //$payload will have the data from the event
    public function c2bPayment($payload){
       
    }

Register an event listener in the boot method of your EventServiceProvider:

Event::listen('c2b.received.payment', 'App\Http\Controllers\PaymentsController@c2bPayment');