Download the PHP package wasksofts/mpesa-library without Composer

On this page you can find all versions of the php package wasksofts/mpesa-library. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
wasksofts/mpesa-library
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package mpesa-library

mpesa-library

Mpesa Api library you can use also https://github.com/wasksofts/mpesa

Install

Instal the gateway using require depedencies.

usage

Initialize mpesa library

 $mpesa  = new Mpesa();
//get result returned by functions
echo  $mpesa->get_message();

access_token

To get access token

 echo " Token : " .$mpesa->oauth_token();  
 Token : zlfUeamewm24r2NjnsgjBlQQANNP

STKPushQuery

 print_r($mpesa->STKPushQuery('ws_CO_DMZ_297481201_09042019174418021'));        
  //Success Result 
 { "ResponseCode": "0", 
   "ResponseDescription":"The service request has been accepted successsfully", 
  "MerchantRequestID":"28415-165347-1",
  "CheckoutRequestID":"ws_CO_DMZ_297481201_09042019174418021",
  "ResultCode": "1032", 
  "ResultDesc":"[STK_CB - ]Request cancelled by user" 
  }

STKPushSimulation

This feature allows the transaction initiation to be moved from the paying customer's side to the payee Organization's side. This eliminates the challenge of having to remember business paybill numbers and account numbers and allows customers to simply confirm the transaction by entering their MPesa PIN on their mobile phone. This is done via the STK push/Pop-up which appears on a customer's phone that prompts them to enter their PIN.

  print_r($mpesa->STKPushSimulation('20','254708374149','pay now','test'));
//Success Result 
  { 
   "MerchantRequestID":"16658-1455367-1", 
   "CheckoutRequestID":"ws_CO_DMZ_435322918_09042019180550656", 
   "ResponseCode": "0",        
   "ResponseDescription":"Success. Request accepted for processing", 
   "CustomerMessage":"Success. Request accepted for processing"
  }

register url

The Register URL API under C2B APIs. It is the first half of the C2B API for receiving payment notifications to your paybill. This API enables you to register the callback URLs via which you shall receive payment notifications for payments to your paybill/till number. The URLs are used by the C2B payment simulation API for sending the transaction details to you.

 print_r( $mpesa->register_url());   
 //Success Result 
 {
  "ConversationID": "", 
  "OriginatorCoversationID": "", 
  "ResponseDescription": "success"
 }

c2b

This API is used for payment requests from clients to your API. You can use the sandbox to simulates a payment made from the client phone's STK/SIM Toolkit menu, and enables you to receive the payment requests in real time. It uses URL as described in the Register URL API and requires the URLs registered to work. For better understanding of this API, consider going through the Register URL section above to better understand the process flow of a C2B transaction and the requirements of URL

 print_r($mpesa->c2b('120','254708374149','account'));
 //Success Result 
   { 
     "ConversationID": "AG_20190409_000079ec780236c1f54f", 
     "OriginatorCoversationID": "6896-31171-1",
     "ResponseDescription": "Accept the service request successfully."
   }

b2c

B2C simply means Business to Customer. This is a transaction that comes from a Business (Bank) to Customer (Client). This API enables a Businesses or Organization to pay their customers. The most common reasons a business can pay their customer include salary payments, promotion payments or normal business payments (e.g. transfers from bank to mobile). Each of these scenarios has their own unique characteristics, but all lie under the B2C (Business to Customer) API category.

 print_r($mpesa->b2c('20','BusinessPayment','254708374149','payment'));
//Success Result 
 { 
   "ConversationID": "AG_20190409_0000515207592fa5723a", 
   "OriginatorConversationID": "28412-215980-1", 
   "ResponseCode":"0",
   "ResponseDescription": "Accept the service request successfully." 
 }

b2b

This API enables a Business or Organization to perform transactions between each other. The transaction flow is the same as the B2C API transaction flow, but this time the Credit Party is another Business/Company/Organization. It requires the same credentials and information as the B2C API.

Currently the B2B API allows an organization to perform 5 types of transfers: Business Pay Bill: This is a transfer of funds from one Organization's Working Account to another Organization's Utility Account. Business Buy Goods: A transfer of funds from one Organization's Working Account to another Organization's Merchant Account. Disburse Funds To Business: A transfer of funds from one Organization's Utility Account to another Organization's Working Account. Business To Business Transfer: A transfer of funds from one Organization's Working Account to another Organization's Working Account. Merchant To Merchant Transfer: A transfer of funds from one Organization's Merchant Account to another Organization's Merchant Account.

print_r($mpesa->b2b('10000','BusinessPayBill','60000','4','4','paytest','cool'));
//Success Result 
 { 
   "ConversationID": "AG_20190409_0000515207592fa5723a", 
   "OriginatorConversationID": "28412-215980-1", 
   "ResponseCode":"0",
   "ResponseDescription": "Accept the service request successfully." 
 }

reversal

This API enables reversal of transactions done

 print_r( $mpesa->reversal('2','254708374149','1','NCR7S1UXBT','PAY NOW VIA WASKSOFT'));

accountbalance

 print_r($mpesa->accountbalance('600443','4','remarks'));

transaction status

 print_r($mpesa->transaction_status('NCR7S1UXBT','254708374149','4','apitest'));

All versions of mpesa-library with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6|^7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package wasksofts/mpesa-library contains the following files

Loading the files please wait ....