Giter VIP home page Giter VIP logo

mpesa-php-sdk's Introduction

Mpesa Mozambique PHP SDK

Latest Version on Packagist Build Status Quality Score Total Downloads

This package seeks to help php developers implement the various Mpesa APIs without much hustle. It is based on the REST API whose documentation is available on https://developer.mpesa.vm.co.mz/.

Installation

You can install the package via composer:

composer require karson/mpesa-php-sdk

Usage

// Set the api and public key as follows . Copy it from Mpesa Developer Console (https://developer.mpesa.vm.co.mz/) .
$mpesa = new \Karson\MpesaPhpSdk\Mpesa();
$mpesa->setApiKey('your api key');
$mpesa->setPublicKey('your public key');
$mpesa->setServiceProviderCode('your public key');
$mpesa->setEnv('test');// 'live' production environment 

//This creates transaction between an M-Pesa service provider code to a phone number registered on M-Pesa.
$invoice_id = "FT0001"; // Eg: Invoice number
$phone_number = "258841234567"; // Prefixed with country code (258)
$amount = "10"; // Payment amount
$reference_id = "XBRAND001"; // Should be unique for each transaction

$result = $mpesa->c2b($invoice_id, $phone_number, $amount, $reference_id);

var_dump($result);

Instalation in Laravel

// Set the api, public key, provider and environment secret as follows in your .env file

MPESA_API_KEY ="Your API Key";
MPESA_PUBLIC_KEY='You Public Key'
MPESA_ENV='test' // 'live' production environment
MPESA_SERVICE_PROVIDER_CODE=171717

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.

mpesa-php-sdk's People

Contributors

joseseie avatar karson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mpesa-php-sdk's Issues

B2C support

Support for B2C transactions is missing.

After updating or adding support for BC2 transactions, it will be necessary to update the readme so that the community knows how to carry out this type of transaction.

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.