Giter Site home page Giter Site logo

mpesa-3's Introduction

M-PESA API Package

Build Status Latest Stable Version Latest Unstable Version License

This is a PHP package with first class support to laravel for the Safaricom's M-Pesa REST API dubbed DARAJA API.

It implements all the exposed endpoints by Safaricom as listed below:-

    What it is?

The Lipa na M-Pesa Online Payment endpoint(STK push) allows you to request payment from your users/clients. With this endpoint all the user is required to do is input their M-PESA pin to a prompt to send a payment to you.

    How to implement it?

Read docs here.

    What it is?

When you request payment from your users/clients via Lipa na M-Pesa Online endpoint above you might want to know the status of that request. This endpoint facilitates that. It allows you to query the status of any STK push on demand.

    How to implement it?

Read docs here.

3. C2B

    What it is?

This endpoint enables developers to receive real time notifications when a client makes a payments to a merchant's Till number or Paybill number. It assumes the payment are made via the SIM card toolkit and as a developer you need to know when that payment hits the merchants till/paybill number for reconciliation and accounting purposes.

    How to implement it?

Read docs here.

4. B2C

    What it is?

This endpoints enables merchants to pay their customers from they paybill account. Some of the use cases are but not limited to paying salaries, paying promotions to customers etc.

    How to implement it?

Read docs here.

5. B2B

    What it is?

This endpoint allows merchants to transfer funds from business to business accounts.

    How to implement it?

Read docs here.

    What it is?

This endpoint enables developers to initiate status check of a B2B, B2C and C2B transactions. It really comes in handy where one party in a transactions fails/claims not to have received an acknowledgment for a transaction.

    How to implement it?

Read docs here.

    What it is?

This endpoint enables merchants to reverse a B2B, B2C or C2B transaction. It allows automation of reversal of erronous payment to a merchant's paybill/till number or payments to goods never delivered.

    How to implement it?

Read docs here.

    What it is?

This endpoint enables merchants to query their Till/Paybill numbers account balance on demand.

    How to implement it?

Read docs here.

Installation

This project is distributed via composer package manager and should be installed as one of your project's dependencies:

Laravel

  1. Pull the package using the command below:-
composer require kabangi/mpesa
  1. Make sure config/app.php under providers array the following line exists

Kabangi\Mpesa\Laravel\ServiceProvider::class, If not add it

Raw PHP (Vanilla)

  1. Modify your composer.json file to include:
  "scripts": {
        "post-update-cmd": [
            "Kabangi\\Mpesa\\Support\\Installer::install"
        ]
  },
  1. Run the following command
composer require kabangi/mpesa

Configuration

Laravel

Publish the package config file by running the following command: php artisan vendor:publish This will add mpesa.php config file into config directory.

Edit the file with the necessary values if you do not do this we will use the sandbox credentials automagically.

Raw PHP (Vanilla)

If you followed the installation details you should have a config directory and mpesa.php file.

Modify the config file where necessary to include your credentials

Usage

Raw PHP (Vanilla)

<?php
require "vendor/autoload.php";

use Kabangi\Mpesa\Native\Mpesa;

$mpesa = new Mpesa();

$response = $mpesa->STKPush([]);
header('Content-Type: application/json');
echo json_encode($response);

// $mpesa->STKStatus([]);

// $mpesa->C2BRegister([]);

// $mpesa->C2BSimulate([]);

// $mpesa->B2C([]);

// $mpesa->accountBalance([]);

// $mpesa->reversal([]);

// $mpesa->transactionStatus([]);

Inspiration

This package was inspired by the work from smodav work on the following project:- https://github.com/SmoDav/mpesa

Contributors

Gratitudes goes to the following Ninjas for their help during my integration process and the things I had to learn along the way fom them or their code:-

|
Julius Kabangi

Support

Need support using this package:- Send a quick message here

License

The M-Pesa Package is open-sourced software licensed under the MIT license.

mpesa-3's People

Contributors

kabangi avatar

Watchers

James Cloos avatar WwddingJuma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.